diff --git a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts index 5bece46..716013f 100644 --- a/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts +++ b/projects/common-map/src/fm-map/components/selected-item-container/selected-item-container.component.ts @@ -20,19 +20,21 @@ export class SelectedItemContainerComponent { loadComponent() { let componentFactory: ComponentFactory = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default - for (let i = 0; i < this.selectedItemComponents.length; i++) { - let hasSourceTask = this.selectedItemComponents[i]['forSourceTask'] != null && - this.selectedItemComponents[i]['forSourceTask'] != undefined; + let firstComponentWithTypeAndTask = this.selectedItemComponents + .find(value => value['forSourceTask'] == this.item.sourceTask && + value['forItemType'] == this.item.itemType + ); - if (this.selectedItemComponents[i]['forItemType'] == this.item.itemType && - hasSourceTask && this.selectedItemComponents[i]['forSourceTask'] == this.item.sourceTask) { + if (firstComponentWithTypeAndTask) { + componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithTypeAndTask['constructor'] as any); + } else { + let firstComponentWithType = this.selectedItemComponents + .find(value => value['forItemType'] == this.item.itemType); - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[i]['constructor'] as any); - break; - } else if (this.selectedItemComponents[i]['forItemType'] == this.item.itemType) { - componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[i]['constructor'] as any); + if (firstComponentWithType) { + componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithType['constructor'] as any); } - } + } const viewContainerRef = this.widgetHost.viewContainerRef; viewContainerRef.clear();