changeset 3700:2d77a7447d09

import_soundingresult: restrict users to import only data for bottlenecks they are responsible for
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 19 Jun 2019 11:27:14 +0200
parents a925e4e323a8
children 519c6e01607f
files client/src/components/importconfiguration/types/Soundingresults.vue
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/components/importconfiguration/types/Soundingresults.vue	Wed Jun 19 11:24:30 2019 +0200
+++ b/client/src/components/importconfiguration/types/Soundingresults.vue	Wed Jun 19 11:27:14 2019 +0200
@@ -201,7 +201,7 @@
  */
 import { HTTP } from "@/lib/http";
 import { displayError, displayInfo } from "@/lib/errors";
-import { mapState } from "vuex";
+import { mapState, mapGetters } from "vuex";
 
 const IMPORTSTATE = { UPLOAD: "UPLOAD", EDIT: "EDIT" };
 
@@ -351,6 +351,8 @@
   computed: {
     ...mapState("application", ["showContextBox"]),
     ...mapState("bottlenecks", ["bottlenecks"]),
+    ...mapState("user", ["user"]),
+    ...mapGetters("usermanagement", ["userCountries"]),
     importSoundingresultsLabel() {
       return this.$gettext("Import Soundingresults");
     },
@@ -366,7 +368,11 @@
       return this.disableUpload;
     },
     availableBottlenecks() {
-      return this.bottlenecks;
+      const userCountrycode = this.userCountries[this.user];
+      if (userCountrycode === "global") return this.bottlenecks;
+      return this.bottlenecks.filter(
+        bn => bn.properties.responsible_country === userCountrycode
+      );
     },
     placeholder() {
       return this.$gettext("Select bottleneck");