Mercurial > gemma
changeset 4521:245e6215361e
Client: BottleneckDialogue: fix rights on creating the deletion job for (SR)
author | Fadi Abbud <fadi.abbud@intevation.de> |
---|---|
date | Mon, 07 Oct 2019 09:29:30 +0200 |
parents | aeb2aedd3abd |
children | 7fb29172befa 04a428766321 |
files | client/src/components/fairway/BottleneckDialogue.vue |
diffstat | 1 files changed, 27 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/fairway/BottleneckDialogue.vue Fri Oct 04 19:29:28 2019 +0200 +++ b/client/src/components/fairway/BottleneckDialogue.vue Mon Oct 07 09:29:30 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"); } };