changeset 5590:826e67e959c9 surveysperbottleneckid

For BN Overview display id for all doubles
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 05 Apr 2022 13:02:13 +0200
parents f24c9a7b3e82
children 0011f50cf216
files client/src/components/Bottlenecks.vue client/src/store/bottlenecks.js
diffstat 2 files changed, 22 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/Bottlenecks.vue	Tue Apr 05 12:18:17 2022 +0200
+++ b/client/src/components/Bottlenecks.vue	Tue Apr 05 13:02:13 2022 +0200
@@ -7,7 +7,7 @@
     />
     <UITableHeader
       :columns="[
-        { id: 'properties.name', title: `${nameLabel}`, width: '230px' },
+        { id: 'properties.displayName', title: `${nameLabel}`, width: '230px' },
         {
           id: 'properties.responsible_country',
           title: `${countryLabel}`,
--- a/client/src/store/bottlenecks.js	Tue Apr 05 12:18:17 2022 +0200
+++ b/client/src/store/bottlenecks.js	Tue Apr 05 13:02:13 2022 +0200
@@ -42,16 +42,27 @@
         return o;
       }, {});
     },
-    bottlenecksForDisplay: (state, getters) => {
-      const groupedBottlenecks = getters.orderedBottlenecks;
-      return Object.keys(groupedBottlenecks)
-        .map(country => {
-          return groupedBottlenecks[country];
-        })
-        .reduce((o, n) => {
-          o = o.concat(n);
-          return o;
-        }, []);
+    bottlenecksForDisplay: state => {
+      const names = {};
+      const doubleNames = {};
+      const bottlenecks = state.bottlenecksList.map(bn => {
+        const name = bn.properties.name || bn.properties.objnam;
+        if (!names[name]) {
+          names[name] = name;
+        } else {
+          doubleNames[name] = name;
+        }
+        return bn;
+      });
+      return bottlenecks.map(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;
+        }
+        return bn;
+      });
     },
     orderedBottlenecks: state => {
       const groupedBottlenecks = {};