Mercurial > gemma
changeset 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 | 7e8830c808ba |
children | 2576a399c2cf |
files | client/src/components/fairway/AvailableFairwayDepthDialogue.vue client/src/components/fairway/BottleneckDialogue.vue client/src/components/importconfiguration/types/Soundingresults.vue client/src/store/bottlenecks.js |
diffstat | 4 files changed, 49 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Fri Apr 01 18:51:23 2022 +0200 +++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue Mon Apr 04 15:12:43 2022 +0200 @@ -73,7 +73,7 @@ :key="bn.properties.id" :value="bn" > - {{ bn.properties.name }} + {{ bn.properties.displayName }} <!-- name for display is okay --> </option> </optgroup>
--- a/client/src/components/fairway/BottleneckDialogue.vue Fri Apr 01 18:51:23 2022 +0200 +++ b/client/src/components/fairway/BottleneckDialogue.vue Mon Apr 04 15:12:43 2022 +0200 @@ -31,7 +31,7 @@ :key="bn.properties.id" :value="bn.properties.bottleneck_id" > - {{ bn.properties.name }} + {{ bn.properties.displayName }} <!-- name for display is okay--> </option> </optgroup>
--- a/client/src/components/importconfiguration/types/Soundingresults.vue Fri Apr 01 18:51:23 2022 +0200 +++ b/client/src/components/importconfiguration/types/Soundingresults.vue Mon Apr 04 15:12:43 2022 +0200 @@ -25,7 +25,7 @@ :key="bn.properties.bottleneck_id" :value="bn" > - {{ bn.properties.objnam }} + {{ bn.properties.displayName }} <!-- objnam for label is okay --> </option> </optgroup> @@ -420,8 +420,8 @@ return this.$gettext("Select bottleneck"); }, orderedBottlenecks() { - let groupedBottlenecks = {}, - orderedGroups = {}; + const groupedBottlenecks = {}; + const orderedGroups = {}; // group bottlenecks by cc this.availableBottlenecks.forEach(bn => { @@ -436,8 +436,27 @@ // order groups by cc Object.keys(groupedBottlenecks) .sort() - .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); - + .forEach(cc => { + const names = {}; + const doubleNames = {}; + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (!names[name]) { + names[name] = name; + } else { + doubleNames[name] = name; + } + }); + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (doubleNames[name]) { + bn.properties.displayName = `${name} / ${bn.properties.bottleneck_id}`; + } else { + bn.properties.displayName = name; + } + }); + orderedGroups[cc] = groupedBottlenecks[cc]; + }); return orderedGroups; }, editState() {
--- a/client/src/store/bottlenecks.js Fri Apr 01 18:51:23 2022 +0200 +++ b/client/src/store/bottlenecks.js Mon Apr 04 15:12:43 2022 +0200 @@ -43,9 +43,8 @@ }, {}); }, orderedBottlenecks: state => { - let groupedBottlenecks = {}, - orderedGroups = {}; - + const groupedBottlenecks = {}; + const orderedGroups = {}; // group bottlenecks by cc state.bottlenecksList.forEach(bn => { let cc = bn.properties.responsible_country; @@ -59,7 +58,27 @@ // order groups by cc Object.keys(groupedBottlenecks) .sort() - .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc])); + .forEach(cc => { + const names = {}; + const doubleNames = {}; + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (!names[name]) { + names[name] = name; + } else { + doubleNames[name] = name; + } + }); + groupedBottlenecks[cc].forEach(bn => { + const name = bn.properties.name || bn.properties.objnam; + if (doubleNames[name]) { + bn.properties.displayName = `${name} / ${bn.properties.bottleneck_id}`; + } else { + bn.properties.displayName = name; + } + }); + orderedGroups[cc] = groupedBottlenecks[cc]; + }); return orderedGroups; }