diff client/src/components/fairway/AvailableFairwayDepthDialogue.vue @ 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 94e966ebef35
children 5f0c6e931e7f
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",