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() {
let componentFactory: ComponentFactory<AbstractSelectedItemComponent> = 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;