From 462fcc38cde2945a5ea3fcdb1cf8e96f4f39bbd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e?= <tpoussard@neogeo.fr> Date: Tue, 9 Aug 2022 18:52:26 +0200 Subject: [PATCH] check right to edit feature in attributes modification mode --- .../FeaturesListAndMap/FeatureListTable.vue | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/components/Project/FeaturesListAndMap/FeatureListTable.vue b/src/components/Project/FeaturesListAndMap/FeatureListTable.vue index b000cb66..d8cd0573 100644 --- a/src/components/Project/FeaturesListAndMap/FeatureListTable.vue +++ b/src/components/Project/FeaturesListAndMap/FeatureListTable.vue @@ -415,6 +415,12 @@ export default { } }, + data() { + return { + editAttributesFeatureType: null, + }; + }, + computed: { ...mapGetters(['permissions']), ...mapState(['user', 'USER_LEVEL_PROJECTS']), @@ -427,6 +433,8 @@ export default { }, set(newMode) { this.TOGGLE_MASS_MODE(newMode); + this.UPDATE_CLICKED_FEATURES([]); + this.UPDATE_CHECKED_FEATURES([]); }, }, @@ -486,6 +494,9 @@ export default { ]), storeClickedFeature(feature) { + if (this.checkedFeatures.length === 0 && this.massMode === 'modify-attributes') { // if modifying attributes + this.editAttributesFeatureType = feature.feature_type.slug; // store feature type slug to restrict selection for next selected features + } this.UPDATE_CLICKED_FEATURES([ ...this.clickedFeatures, { feature_id: feature.feature_id, feature_type: feature.feature_type.slug } @@ -508,7 +519,11 @@ export default { Contributeur : ['draft', 'pending', 'published'], }; - if (this.user.is_superuser) { + if (this.checkedFeatures.length > 0 && // check if selection should be restricted to a specific feature type, for attributes modification + feature.feature_type.slug !== this.editAttributesFeatureType && + this.massMode === 'modify-attributes') { + return false; + } else if (this.user.is_superuser) { return true; } else if (this.userStatus === 'Contributeur' && feature.display_creator !== `${this.user.first_name} ${this.user.last_name}`) { return false; @@ -520,20 +535,13 @@ export default { }, checkRights(feature) { - switch (this.massMode) { - case 'modify-status': + if (this.massMode.includes('modify')) { return this.canEditFeature(feature); - case 'delete-features': + } else if (this.massMode === 'delete-features') { return this.canDeleteFeature(feature); } }, - switchMode() { - this.$emit('update:mode', this.mode === 'modify' ? 'delete' : 'modify'); - this.UPDATE_CLICKED_FEATURES([]); - this.$store.commit('feature/UPDATE_CHECKED_FEATURES', []); - }, - isSortedAsc(column) { return this.sort.column === column && this.sort.ascending; }, -- GitLab