Skip to content
Snippets Groups Projects
Commit 462fcc38 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

check right to edit feature in attributes modification mode

parent fbea2979
No related branches found
No related tags found
No related merge requests found
......@@ -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;
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment