AW-784 Reapply from Farmmaps commits

- a4bb051a: AW-738 fixed bug
This commit is contained in:
Peter Bastiani 2019-12-20 09:19:53 +01:00
parent e1ff44ed3c
commit 2059b48abb

View File

@ -20,17 +20,19 @@ export class SelectedItemContainerComponent {
loadComponent() { loadComponent() {
let componentFactory: ComponentFactory<AbstractSelectedItemComponent> = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default let componentFactory: ComponentFactory<AbstractSelectedItemComponent> = this.componentFactoryResolver.resolveComponentFactory(SelectedItemComponent); // default
for (let i = 0; i < this.selectedItemComponents.length; i++) { let firstComponentWithTypeAndTask = this.selectedItemComponents
let hasSourceTask = this.selectedItemComponents[i]['forSourceTask'] != null && .find(value => value['forSourceTask'] == this.item.sourceTask &&
this.selectedItemComponents[i]['forSourceTask'] != undefined; value['forItemType'] == this.item.itemType
);
if (this.selectedItemComponents[i]['forItemType'] == this.item.itemType && if (firstComponentWithTypeAndTask) {
hasSourceTask && this.selectedItemComponents[i]['forSourceTask'] == this.item.sourceTask) { 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); if (firstComponentWithType) {
break; componentFactory = this.componentFactoryResolver.resolveComponentFactory(firstComponentWithType['constructor'] as any);
} else if (this.selectedItemComponents[i]['forItemType'] == this.item.itemType) {
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.selectedItemComponents[i]['constructor'] as any);
} }
} }
const viewContainerRef = this.widgetHost.viewContainerRef; const viewContainerRef = this.widgetHost.viewContainerRef;