From 09fa8b4f1f3a4677c811eb8271d88a10c8ca10b5 Mon Sep 17 00:00:00 2001 From: Willem Dantuma Date: Tue, 30 Jun 2020 09:11:46 +0200 Subject: [PATCH] Fix template selection --- .../feature-list-container.component.ts | 17 ++++++++++++----- .../feature-list-feature-container.component.ts | 10 +++++++--- .../item-list-item-container.component.ts | 17 ++++++++++++----- .../selected-item-container.component.ts | 17 ++++++++++++----- 4 files changed, 43 insertions(+), 18 deletions(-) diff --git a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts index f8dcf9f..151ee7b 100644 --- a/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-container/feature-list-container.component.ts @@ -34,13 +34,20 @@ export class FeatureListContainerComponent { let showItem = true; for (let i = 0; i < this.featureLists.length; i++) { let matches=0; - if (this.featureLists[i]['forItemType'] && this.featureLists[i]['forItemType'].indexOf(queryState.itemType) >= 0) { - matches++; + let criteria=0; + if (this.featureLists[i]['forItemType']) { + criteria++; + if( this.featureLists[i]['forItemType'].indexOf(queryState.itemType) >= 0) { + matches++; + } } - if(this.featureLists[i]['forChild'] && queryState.parentCode && queryState.parentCode != "") { - matches++; + if(this.featureLists[i]['forChild'] ) { + criteria++; + if(queryState.parentCode && queryState.parentCode != "") { + matches++; + } } - if(matches > maxMatches) { + if(criteria == matches && matches > maxMatches) { selected=i; maxMatches = matches; } diff --git a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts b/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts index 7678535..04b14cb 100644 --- a/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts +++ b/projects/common-map/src/fm-map/components/feature-list-feature-container/feature-list-feature-container.component.ts @@ -28,10 +28,14 @@ export class FeatureListFeatureContainerComponent { let maxMatches =0; for (let i = 0; i < this.featureLists.length; i++) { let matches=0; - if (this.featureLists[i]['forItemType'] == this.feature.get("itemType")) { - matches++; + let criteria=0; + if (this.featureLists[i]['forItemType']) { + criteria++; + if(this.featureLists[i]['forItemType'].indexOf(this.feature.get("itemType")) >= 0) { + matches++; + } } - if(matches > maxMatches) { + if(criteria == matches && matches > maxMatches) { selected=i; maxMatches = matches; } diff --git a/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts b/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts index 7d79ef7..afb8b80 100644 --- a/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts +++ b/projects/common-map/src/fm-map/components/item-list-item-container/item-list-item-container.component.ts @@ -29,14 +29,21 @@ export class ItemListItemContainerComponent { let showItem = true; for (let i = 0; i < this.itemComponentList.length; i++) { let matches=0; - if (this.itemComponentList[i]['forItemType'] && this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0) { - matches++; + let criteria=0; + if (this.itemComponentList[i]['forItemType']) { + criteria++; + if(this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0) { + matches++; + } } - if (this.itemComponentList[i]['forSourceTask'] && this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) { - matches++; + if (this.itemComponentList[i]['forSourceTask']) { + criteria++; + if(this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) { + matches++; + } } - if(matches > maxMatches) { + if(criteria == matches && matches > maxMatches) { selected=i; maxMatches = matches; } 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 49bee47..f4e1db4 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 @@ -29,14 +29,21 @@ export class SelectedItemContainerComponent { let showItem = true; for (let i = 0; i < this.selectedItemComponents.length; i++) { let matches=0; - if (this.selectedItemComponents[i]['forItemType'] && this.selectedItemComponents[i]['forItemType'].indexOf(this.item.itemType) >= 0) { - matches++; + let criteria=0; + if (this.selectedItemComponents[i]['forItemType'] ) { + criteria++; + if(this.selectedItemComponents[i]['forItemType'].indexOf(this.item.itemType) >= 0) { + matches++; + } } - if (this.selectedItemComponents[i]['forSourceTask'] && this.selectedItemComponents[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) { - matches++; + if (this.selectedItemComponents[i]['forSourceTask']) { + criteria++; + if( this.selectedItemComponents[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) { + matches++; + } } - if(matches > maxMatches) { + if(criteria==matches && matches > maxMatches) { selected=i; maxMatches = matches; }