diff client/src/fairway/store.js @ 1056:28eb62f7c676 crossprofile

additional survey as dynamic property
author Thomas Junk <thomas.junk@intevation.de>
date Thu, 25 Oct 2018 16:19:46 +0200
parents f8a4ec146d47
children 7242b5a427bc
line wrap: on
line diff
--- a/client/src/fairway/store.js	Thu Oct 25 15:01:59 2018 +0200
+++ b/client/src/fairway/store.js	Thu Oct 25 16:19:46 2018 +0200
@@ -24,6 +24,7 @@
 const FairwayProfile = {
   namespaced: true,
   state: {
+    additionalSurvey: "",
     availableSurveys: null,
     totalLength: 0,
     minAlt: 0,
@@ -39,9 +40,15 @@
   getters: {
     length: state => {
       return state.totalLength;
+    },
+    additionalSurvey: state => {
+      return state.additionalSurvey;
     }
   },
   mutations: {
+    setAdditionalSurvey: (state, additionalSurvey) => {
+      state.additionalSurvey = additionalSurvey;
+    },
     setSelectedMorph: (state, selectedMorph) => {
       state.selectedMorph = selectedMorph;
     },
@@ -63,9 +70,15 @@
       // Use Vue.set() to make new object properties rective
       // https://vuejs.org/v2/guide/reactivity.html#Change-Detection-Caveats
       Vue.set(state.currentProfile, surveyDate, result.points);
-      state.minAlt = result.minAlt;
-      state.maxAlt = result.maxAlt;
-      state.totalLength = result.lengthPolyLine;
+      if (!state.minAlt || state.minAlt > result.minAlt) {
+        state.minAlt = result.minAlt;
+      }
+      if (!state.maxAlt || state.maxAlt < result.maxAlt) {
+        state.maxAlt = result.maxAlt;
+      }
+      if (!state.totalLength || state.totalLength < result.totalLength) {
+        state.totalLength = result.lengthPolyLine;
+      }
     },
     setStartPoint: (state, start) => {
       state.startPoint = start;
@@ -77,6 +90,7 @@
       state.fairwayCoordinates = coordinates;
     },
     clearCurrentProfile: state => {
+      state.additionalSurvey = "";
       state.currentProfile = {};
     }
   },