changeset 4572:04a428766321 iso-areas

Merged default into iso-area branch.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 07 Oct 2019 10:35:55 +0200
parents a413b4a89bcc (current diff) 245e6215361e (diff)
children 26e9846ed69f
files
diffstat 1 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/fairway/BottleneckDialogue.vue	Sun Oct 06 11:41:31 2019 +0200
+++ b/client/src/components/fairway/BottleneckDialogue.vue	Mon Oct 07 10:35:55 2019 +0200
@@ -88,6 +88,7 @@
                   >
                 </select>
                 <button
+                  v-if="isAllowedToDelete"
                   class="btn btn-dark btn-xs ml-2"
                   @click="deleteSelectedSurvey"
                 >
@@ -347,6 +348,9 @@
     };
   },
   computed: {
+    ...mapState("user", ["user"]),
+    ...mapGetters("user", ["isWaterwayAdmin", "isSysAdmin"]),
+    ...mapGetters("usermanagement", ["userCountries"]),
     ...mapState("application", ["showProfiles", "paneSetup"]),
     ...mapState("map", ["openLayersMaps", "syncedMaps", "cutToolEnabled"]),
     ...mapState("bottlenecks", [
@@ -354,6 +358,22 @@
       "surveys",
       "surveysLoading"
     ]),
+    isAllowedToDelete() {
+      const userCountryCode = this.userCountries[this.user];
+      const bottleneck = this.bottlenecksList.find(
+        bn => bn.properties.name === this.selectedBottleneck
+      );
+      if (!bottleneck) return;
+      if (this.isWaterwayAdmin || this.isSysAdmin) {
+        if (
+          userCountryCode === "global" ||
+          bottleneck.properties.responsible_country === userCountryCode
+        ) {
+          return true;
+        }
+      }
+      return false;
+    },
     ...mapState("fairwayprofile", [
       "previousCuts",
       "startPoint",
@@ -757,6 +777,13 @@
     }
   },
   mounted() {
+    this.$store.dispatch("usermanagement/loadUsers").catch(error => {
+      const { status, data } = error.response;
+      displayError({
+        title: this.$gettext("Backend Error"),
+        message: `${status}: ${data.message || data}`
+      });
+    });
     this.$store.dispatch("bottlenecks/loadBottlenecksList");
   }
 };