Fix template selection
All checks were successful
FarmMaps.Develop/FarmMapsLib/pipeline/head This commit looks good

This commit is contained in:
Willem Dantuma 2020-06-30 09:11:46 +02:00
parent 214dc3ffa1
commit 09fa8b4f1f
4 changed files with 43 additions and 18 deletions

View File

@ -34,13 +34,20 @@ export class FeatureListContainerComponent {
let showItem = true; let showItem = true;
for (let i = 0; i < this.featureLists.length; i++) { for (let i = 0; i < this.featureLists.length; i++) {
let matches=0; let matches=0;
if (this.featureLists[i]['forItemType'] && this.featureLists[i]['forItemType'].indexOf(queryState.itemType) >= 0) { let criteria=0;
matches++; 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 != "") { if(this.featureLists[i]['forChild'] ) {
matches++; criteria++;
if(queryState.parentCode && queryState.parentCode != "") {
matches++;
}
} }
if(matches > maxMatches) { if(criteria == matches && matches > maxMatches) {
selected=i; selected=i;
maxMatches = matches; maxMatches = matches;
} }

View File

@ -28,10 +28,14 @@ export class FeatureListFeatureContainerComponent {
let maxMatches =0; let maxMatches =0;
for (let i = 0; i < this.featureLists.length; i++) { for (let i = 0; i < this.featureLists.length; i++) {
let matches=0; let matches=0;
if (this.featureLists[i]['forItemType'] == this.feature.get("itemType")) { let criteria=0;
matches++; 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; selected=i;
maxMatches = matches; maxMatches = matches;
} }

View File

@ -29,14 +29,21 @@ export class ItemListItemContainerComponent {
let showItem = true; let showItem = true;
for (let i = 0; i < this.itemComponentList.length; i++) { for (let i = 0; i < this.itemComponentList.length; i++) {
let matches=0; let matches=0;
if (this.itemComponentList[i]['forItemType'] && this.itemComponentList[i]['forItemType'].indexOf(this.item.itemType) >= 0) { let criteria=0;
matches++; 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) { if (this.itemComponentList[i]['forSourceTask']) {
matches++; criteria++;
if(this.itemComponentList[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
matches++;
}
} }
if(matches > maxMatches) { if(criteria == matches && matches > maxMatches) {
selected=i; selected=i;
maxMatches = matches; maxMatches = matches;
} }

View File

@ -29,14 +29,21 @@ export class SelectedItemContainerComponent {
let showItem = true; let showItem = true;
for (let i = 0; i < this.selectedItemComponents.length; i++) { for (let i = 0; i < this.selectedItemComponents.length; i++) {
let matches=0; let matches=0;
if (this.selectedItemComponents[i]['forItemType'] && this.selectedItemComponents[i]['forItemType'].indexOf(this.item.itemType) >= 0) { let criteria=0;
matches++; 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) { if (this.selectedItemComponents[i]['forSourceTask']) {
matches++; criteria++;
if( this.selectedItemComponents[i]['forSourceTask'].indexOf(this.item.sourceTask) >= 0) {
matches++;
}
} }
if(matches > maxMatches) { if(criteria==matches && matches > maxMatches) {
selected=i; selected=i;
maxMatches = matches; maxMatches = matches;
} }