changeset 3272:a9d047ccf408

client: fairway availability: set stretch in dialog when selecting stretch from map/list
author Markus Kottlaender <markus@intevation.de>
date Wed, 15 May 2019 14:54:53 +0200
parents b74e9768231d
children 050e72ce5cf7
files client/src/components/fairway/AvailableFairwayDepthDialogue.vue client/src/components/stretches/Stretches.vue
diffstat 2 files changed, 18 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/AvailableFairwayDepthDialogue.vue	Wed May 15 14:15:45 2019 +0200
+++ b/client/src/components/fairway/AvailableFairwayDepthDialogue.vue	Wed May 15 14:54:53 2019 +0200
@@ -181,7 +181,6 @@
           LOS: this.los
         })
         .then(() => {
-          this.loading = false;
           this.$store.commit("application/paneSetup", "AVAILABLEFAIRWAYDEPTH");
         })
         .catch(error => {
@@ -191,6 +190,9 @@
             title: this.$gettext("Backend Error"),
             message: `${status}: ${data.message || data}`
           });
+        })
+        .finally(() => {
+          this.loading = false;
         });
     },
     close() {
@@ -229,6 +231,13 @@
         "fairwayavailability/setSelectedFairwayAvailability",
         bn
       );
+    },
+    setSelectedStretch() {
+      const stretch = this.stretches.find(x => x.id === this.selectedStretchId);
+      this.$store.commit(
+        "fairwayavailability/setSelectedFairwayAvailability",
+        stretch
+      );
     }
   },
   computed: {
@@ -244,7 +253,7 @@
       "frequency",
       "LOS"
     ]),
-    ...mapState("imports", ["stretches"]),
+    ...mapState("imports", ["stretches", "selectedStretchId"]),
     ...mapState("bottlenecks", ["bottlenecksList", "selectedBottleneck"]),
     ...mapGetters("map", ["openLayersMap"]),
     ...mapGetters("bottlenecks", ["orderedBottlenecks"]),
@@ -332,6 +341,11 @@
     type() {
       if (this.type === this.$options.BOTTLENECKS && this.selectedBottleneck) {
         this.setSelectedBottleneck();
+      } else if (
+        this.type === this.$options.STRETCHES &&
+        this.selectedStretchId
+      ) {
+        this.setSelectedStretch();
       } else {
         this.$store.commit(
           "fairwayavailability/setSelectedFairwayAvailability",
--- a/client/src/components/stretches/Stretches.vue	Wed May 15 14:15:45 2019 +0200
+++ b/client/src/components/stretches/Stretches.vue	Wed May 15 14:54:53 2019 +0200
@@ -457,6 +457,8 @@
     },
     moveMapToStretch(stretch) {
       this.$store.commit("imports/selectedStretchId", stretch.id);
+      this.$store.commit("fairwayavailability/type", "stretches");
+      this.$store.commit("application/showFairwayDepth", true);
       this.openLayersMap()
         .getLayer("STRETCHES")
         .setVisible(true);