comparison client/src/store/bottlenecks.js @ 3236:5914d615f703

available_fairway_depth: use the store luke
author Thomas Junk <thomas.junk@intevation.de>
date Fri, 10 May 2019 11:33:46 +0200
parents 1253fe15e3e3
children 7ea54c3b3fd6
comparison
equal deleted inserted replaced
3235:0c5a28ffe9ee 3236:5914d615f703
30 30
31 export default { 31 export default {
32 init, 32 init,
33 namespaced: true, 33 namespaced: true,
34 state: init(), 34 state: init(),
35 getters: {
36 orderedBottlenecks: state => {
37 let groupedBottlenecks = {},
38 orderedGroups = {};
39
40 // group bottlenecks by cc
41 state.bottlenecksList.forEach(bn => {
42 let cc = bn.properties.responsible_country;
43 if (groupedBottlenecks.hasOwnProperty(cc)) {
44 groupedBottlenecks[cc].push(bn);
45 } else {
46 groupedBottlenecks[cc] = [bn];
47 }
48 });
49
50 // order groups by cc
51 Object.keys(groupedBottlenecks)
52 .sort()
53 .forEach(cc => (orderedGroups[cc] = groupedBottlenecks[cc]));
54
55 return orderedGroups;
56 }
57 },
35 mutations: { 58 mutations: {
36 setBottlenecks: (state, bottlenecks) => { 59 setBottlenecks: (state, bottlenecks) => {
37 state.bottlenecks = bottlenecks; 60 state.bottlenecks = bottlenecks;
38 }, 61 },
39 setBottlenecksList: (state, bottlenecksList) => { 62 setBottlenecksList: (state, bottlenecksList) => {