diff client/src/store/fairway.js @ 3044:c71373594719

client: map: prepared store to hold multiple map objects This will be necessary to sync maps, toggle layers per map, etc. Therefore the methods to move the map (moveToExtent, etc.) became actions instead of mutations.
author Markus Kottlaender <markus@intevation.de>
date Sat, 13 Apr 2019 16:02:06 +0200
parents 44493664d40e
children 051a3f446ac2
line wrap: on
line diff
--- a/client/src/store/fairway.js	Sat Apr 13 15:28:48 2019 +0200
+++ b/client/src/store/fairway.js	Sat Apr 13 16:02:06 2019 +0200
@@ -132,12 +132,12 @@
     }
   },
   actions: {
-    clearSelection({ commit, dispatch, rootState }) {
+    clearSelection({ commit, dispatch, rootState, rootGetters }) {
       dispatch("bottlenecks/setSelectedBottleneck", null, { root: true });
       dispatch("map/enableIdentifyTool", null, { root: true });
       commit("clearCurrentProfile");
       rootState.map.cutTool.setActive(false);
-      rootState.map.openLayersMap
+      rootGetters["map/openLayersMap"]
         .getLayer("CUTTOOL")
         .getSource()
         .clear();
@@ -178,7 +178,7 @@
         });
       }
     },
-    cut({ commit, dispatch, rootState }, cut) {
+    cut({ commit, dispatch, rootState, rootGetters }, cut) {
       return new Promise(resolve => {
         const length = getLength(cut.getGeometry());
         commit(
@@ -219,7 +219,7 @@
           Promise.all(profileLoaders)
             .then(() => {
               rootState.map.cutTool.setActive(false);
-              const los3 = rootState.map.openLayersMap.getLayer(
+              const los3 = rootGetters["map/openLayersMap"].getLayer(
                 "FAIRWAYDIMENSIONSLOS3"
               );
               los3.getSource().forEachFeatureIntersectingExtent(
@@ -241,7 +241,7 @@
                   }
                 }
               );
-              const los2 = rootState.map.openLayersMap.getLayer(
+              const los2 = rootGetters["map/openLayersMap"].getLayer(
                 "FAIRWAYDIMENSIONSLOS2"
               );
               los2.getSource().forEachFeatureIntersectingExtent(
@@ -263,7 +263,7 @@
                   }
                 }
               );
-              const los1 = rootState.map.openLayersMap.getLayer(
+              const los1 = rootGetters["map/openLayersMap"].getLayer(
                 "FAIRWAYDIMENSIONSLOS1"
               );
               los1.getSource().forEachFeatureIntersectingExtent(
@@ -311,7 +311,7 @@
                       bn.properties.name ===
                       rootState.bottlenecks.selectedBottleneck
                   );
-                  commit(
+                  dispatch(
                     "map/moveToExtent",
                     {
                       feature: bottleneck,