Mercurial > gemma
comparison client/src/components/importconfiguration/types/Soundingresults.vue @ 5586:215e6ba9651b surveysperbottleneckid
Added property "displayName" to bottlenecks.
Before displayed, bottlenecks ordered by country
are now checked for doubles per country.
In case a double is found the displayName is enriched with the
bottleneck_id. Otherwise the displayName is equal to "name" or "objnam".
Example:
const testList = [
{
properties: {
responsible_country: "AT",
name: "Bananas",
bottleneck_id: "BN1"
}
},
{
properties: {
responsible_country: "DE",
name: "Bananas",
bottleneck_id: "BN2"
}
},
{
properties: {
responsible_country: "DE",
name: "Bananas",
bottleneck_id: "BN3"
}
}
];
is rendered to:
AT
Bananas
DE
Bananas / BN2
Bananas / BN3
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Mon, 04 Apr 2022 15:12:43 +0200 |
parents | 0f258757e73a |
children | 2576a399c2cf |
comparison
equal
deleted
inserted
replaced
5585:7e8830c808ba | 5586:215e6ba9651b |
---|---|
23 <option | 23 <option |
24 v-for="bn in bottlenecksForCountry" | 24 v-for="bn in bottlenecksForCountry" |
25 :key="bn.properties.bottleneck_id" | 25 :key="bn.properties.bottleneck_id" |
26 :value="bn" | 26 :value="bn" |
27 > | 27 > |
28 {{ bn.properties.objnam }} | 28 {{ bn.properties.displayName }} |
29 <!-- objnam for label is okay --> | 29 <!-- objnam for label is okay --> |
30 </option> | 30 </option> |
31 </optgroup> | 31 </optgroup> |
32 </select> | 32 </select> |
33 <span class="text-danger"> | 33 <span class="text-danger"> |
418 }, | 418 }, |
419 placeholder() { | 419 placeholder() { |
420 return this.$gettext("Select bottleneck"); | 420 return this.$gettext("Select bottleneck"); |
421 }, | 421 }, |
422 orderedBottlenecks() { | 422 orderedBottlenecks() { |
423 let groupedBottlenecks = {}, | 423 const groupedBottlenecks = {}; |
424 orderedGroups = {}; | 424 const orderedGroups = {}; |
425 | 425 |
426 // group bottlenecks by cc | 426 // group bottlenecks by cc |
427 this.availableBottlenecks.forEach(bn => { | 427 this.availableBottlenecks.forEach(bn => { |
428 let cc = bn.properties.responsible_country; | 428 let cc = bn.properties.responsible_country; |
429 if (groupedBottlenecks.hasOwnProperty(cc)) { | 429 if (groupedBottlenecks.hasOwnProperty(cc)) { |
434 }); | 434 }); |
435 | 435 |
436 // order groups by cc | 436 // order groups by cc |
437 Object.keys(groupedBottlenecks) | 437 Object.keys(groupedBottlenecks) |
438 .sort() | 438 .sort() |
439 .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); | 439 .forEach(cc => { |
440 | 440 const names = {}; |
441 const doubleNames = {}; | |
442 groupedBottlenecks[cc].forEach(bn => { | |
443 const name = bn.properties.name || bn.properties.objnam; | |
444 if (!names[name]) { | |
445 names[name] = name; | |
446 } else { | |
447 doubleNames[name] = name; | |
448 } | |
449 }); | |
450 groupedBottlenecks[cc].forEach(bn => { | |
451 const name = bn.properties.name || bn.properties.objnam; | |
452 if (doubleNames[name]) { | |
453 bn.properties.displayName = `${name} / ${bn.properties.bottleneck_id}`; | |
454 } else { | |
455 bn.properties.displayName = name; | |
456 } | |
457 }); | |
458 orderedGroups[cc] = groupedBottlenecks[cc]; | |
459 }); | |
441 return orderedGroups; | 460 return orderedGroups; |
442 }, | 461 }, |
443 editState() { | 462 editState() { |
444 return this.importState === IMPORTSTATE.EDIT; | 463 return this.importState === IMPORTSTATE.EDIT; |
445 }, | 464 }, |