[APM-419] Adding data input to dynamic component (#4084)

* Extract ComponentRegisterService from ExtensionService

* Make DynamicExtensionComponent smarter

* Add component existence safeguards

* hasComponentById

* Fixing spell check for the sake of mankind

* Add more proper tests and remove double ngOnDestroy call

* Remove lifecycle patches
This commit is contained in:
Popovics András
2018-12-17 13:43:04 +01:00
committed by GitHub
parent ffd72b853f
commit 074225970d
6 changed files with 256 additions and 20 deletions

View File

@@ -22,6 +22,7 @@ import { ExtensionLoaderService } from './extension-loader.service';
import { RouteRef } from '../config/routing.extensions';
import { ActionRef } from '../config/action.extensions';
import * as core from '../evaluators/core.evaluators';
import { ComponentRegisterService } from './component-register.service';
@Injectable({
providedIn: 'root'
@@ -35,10 +36,12 @@ export class ExtensionService {
actions: Array<ActionRef> = [];
authGuards: { [key: string]: Type<{}> } = {};
components: { [key: string]: Type<{}> } = {};
evaluators: { [key: string]: RuleEvaluator } = {};
constructor(private loader: ExtensionLoaderService) {}
constructor(
private loader: ExtensionLoaderService,
private componentRegister: ComponentRegisterService
) {}
async load(): Promise<ExtensionConfig> {
const config = await this.loader.load(
@@ -79,9 +82,7 @@ export class ExtensionService {
}
setComponents(values: { [key: string]: Type<{}> }) {
if (values) {
this.components = Object.assign({}, this.components, values);
}
this.componentRegister.setComponents(values);
}
getRouteById(id: string): RouteRef {
@@ -125,8 +126,8 @@ export class ExtensionService {
return false;
}
getComponentById(id: string): Type<{}> {
return this.components[id];
getComponentById<T>(id: string) {
return this.componentRegister.getComponentById<T>(id);
}
getRuleById(id: string): RuleRef {