diff client/src/store/bottlenecks.js @ 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 94ef43fac0eb
children
line wrap: on
line diff
--- 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 = {};