changeset 1115:1b160eda22cf store-refactoring

moved drawMode to map store
author Markus Kottlaender <markus@intevation.de>
date Mon, 05 Nov 2018 14:05:01 +0100
parents 8d12056d602a
children 7e788814cbde
files client/src/linetool/Linetool.vue client/src/map/Maplayer.vue client/src/morphtool/Morphtool.vue client/src/store/application.js client/src/store/map.js
diffstat 5 files changed, 20 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/linetool/Linetool.vue	Mon Nov 05 13:41:53 2018 +0100
+++ b/client/src/linetool/Linetool.vue	Mon Nov 05 14:05:01 2018 +0100
@@ -1,5 +1,5 @@
 <template>
-    <div @click="drawLine" class="ui-element d-flex shadow drawtool">
+    <div @click="cycleDrawMode" class="ui-element d-flex shadow drawtool">
         <i :class="icon"></i>
     </div>
 </template>
@@ -44,17 +44,16 @@
 export default {
   name: "linetool",
   methods: {
-    drawLine() {
+    cycleDrawMode() {
       if (!this.selectedSurvey && this.drawMode === "LineString") {
-        this.$store.commit("application/activateDrawModePolygon");
+        this.$store.commit("map/activateDrawModePolygon");
       } else {
-        this.$store.commit("application/toggleDrawModeLine");
+        this.$store.commit("map/toggleDrawModeLine");
       }
     }
   },
   computed: {
-    ...mapState("application", ["drawMode"]),
-    ...mapState("map", ["identifiedFeatures"]),
+    ...mapState("map", ["identifiedFeatures", "drawMode"]),
     ...mapState("bottlenecks", ["selectedSurvey"]),
     icon() {
       return {
--- a/client/src/map/Maplayer.vue	Mon Nov 05 13:41:53 2018 +0100
+++ b/client/src/map/Maplayer.vue	Mon Nov 05 14:05:01 2018 +0100
@@ -72,8 +72,7 @@
   },
   computed: {
     ...mapGetters("map", ["layers", "getLayerByName"]),
-    ...mapState("application", ["drawMode"]),
-    ...mapState("map", ["openLayersMap"]),
+    ...mapState("map", ["openLayersMap", "drawMode"]),
     ...mapState("bottlenecks", ["selectedSurvey"]),
     mapStyle() {
       return {
--- a/client/src/morphtool/Morphtool.vue	Mon Nov 05 13:41:53 2018 +0100
+++ b/client/src/morphtool/Morphtool.vue	Mon Nov 05 14:05:01 2018 +0100
@@ -112,7 +112,7 @@
 export default {
   name: "morphtool",
   computed: {
-    ...mapState("application", ["drawMode"]),
+    ...mapState("map", ["drawMode"]),
     ...mapState("bottlenecks", ["selectedBottleneck", "surveys", "selectedSurvey"])
   },
   methods: {
@@ -120,7 +120,7 @@
       this.$store.dispatch("bottlenecks/setSelectedBottleneck", null);
       this.$store.commit("application/closeSplitScreen");
       if (this.drawMode) {
-        this.$store.commit("application/toggleDrawModeLine");
+        this.$store.commit("map/toggleDrawModeLine");
       }
     }
   }
--- a/client/src/store/application.js	Mon Nov 05 13:41:53 2018 +0100
+++ b/client/src/store/application.js	Mon Nov 05 14:05:01 2018 +0100
@@ -39,8 +39,6 @@
       iscollapsed: defaultCollapseState
     },
     countries: ["AT", "SK", "HU", "HR", "RS", "BiH", "BG", "RO", "UA"],
-    // there are three states of drawMode: null, "LineString", "Polygon"
-    drawMode: null,
     version
   },
   getters: {
@@ -114,16 +112,6 @@
     },
     resetSplitScreen: state => {
       state.splitsceen = initializeSplitScreen();
-    },
-    toggleDrawModeLine: state => {
-      if (state.drawMode) {
-        state.drawMode = null;
-      } else {
-        state.drawMode = "LineString";
-      }
-    },
-    activateDrawModePolygon: state => {
-      state.drawMode = "Polygon";
     }
   },
   actions: {}
--- a/client/src/store/map.js	Mon Nov 05 13:41:53 2018 +0100
+++ b/client/src/store/map.js	Mon Nov 05 14:05:01 2018 +0100
@@ -29,6 +29,8 @@
     openLayersMap: null,
     identifiedFeatures: [],
     currentMeasurement: null,
+    // there are three states of drawMode: null, "LineString", "Polygon"
+    drawMode: null,
     layers: [
       {
         name: "Open Streetmap",
@@ -236,6 +238,16 @@
     },
     setCurrentMeasurement: (state, measurement) => {
       state.currentMeasurement = measurement;
+    },
+    toggleDrawModeLine: state => {
+      if (state.drawMode) {
+        state.drawMode = null;
+      } else {
+        state.drawMode = "LineString";
+      }
+    },
+    activateDrawModePolygon: state => {
+      state.drawMode = "Polygon";
     }
   }
 };