Refactor template selection logic add forpackage decorator
Some checks failed
FarmMaps.Develop/FarmMapsLib/pipeline/head There was a failure building this commit

This commit is contained in:
Willem Dantuma
2020-06-24 08:35:34 +02:00
parent cd156ab1bc
commit cbe27c2add
6 changed files with 88 additions and 43 deletions

View File

@@ -23,11 +23,23 @@ export class FeatureListFeatureContainerComponent {
loadComponent() {
var componentFactory: ComponentFactory<AbstractFeatureListFeatureComponent> = this.componentFactoryResolver.resolveComponentFactory(FeatureListFeatureComponent); // default
for (var i = 0; i < this.featureLists.length; i++) {
let selected = -1;
let maxMatches =0;
for (let i = 0; i < this.featureLists.length; i++) {
let matches=0;
if (this.featureLists[i]['forItemType'] == this.feature.get("itemType")) {
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[i]['constructor'] as any);
matches++;
}
if(matches > maxMatches) {
selected=i;
maxMatches = matches;
}
}
}
if (selected >= 0) {
componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.featureLists[selected]['constructor'] as any);
}
const viewContainerRef = this.widgetHost.viewContainerRef;
viewContainerRef.clear();