changeset 2844:77cef49d93ca

client: profiles: bottleneck list sorted by country
author Markus Kottlaender <markus@intevation.de>
date Thu, 28 Mar 2019 11:53:19 +0100
parents 451d73940c81
children 7cd708b98239
files client/src/components/fairway/Profiles.vue
diffstat 1 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/Profiles.vue	Thu Mar 28 11:26:04 2019 +0100
+++ b/client/src/components/fairway/Profiles.vue	Thu Mar 28 11:53:19 2019 +0100
@@ -268,16 +268,25 @@
       "waterLevels"
     ]),
     orderedBottlenecks() {
-      let orderedBottlenecks = {};
+      let groupedBottlenecks = {},
+        orderedGroups = {};
+
+      // group bottlenecks by cc
       this.bottlenecksList.forEach(bn => {
         let cc = bn.properties.responsible_country;
-        if (orderedBottlenecks.hasOwnProperty(cc)) {
-          orderedBottlenecks[cc].push(bn);
+        if (groupedBottlenecks.hasOwnProperty(cc)) {
+          groupedBottlenecks[cc].push(bn);
         } else {
-          orderedBottlenecks[cc] = [bn];
+          groupedBottlenecks[cc] = [bn];
         }
       });
-      return orderedBottlenecks;
+
+      // order groups by cc
+      Object.keys(groupedBottlenecks)
+        .sort()
+        .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc]));
+
+      return orderedGroups;
     },
     profilesLable() {
       return this.$gettext("Profiles");