Skip to content
Snippets Groups Projects
Commit 0e7b2993 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmine-issues/11834' into 'develop'

parents 6fc4642b e1c0c4f8
No related branches found
No related tags found
No related merge requests found
...@@ -343,6 +343,10 @@ export default { ...@@ -343,6 +343,10 @@ export default {
...mapState(['user', 'USER_LEVEL_PROJECTS']), ...mapState(['user', 'USER_LEVEL_PROJECTS']),
...mapState('projects', ['project']), ...mapState('projects', ['project']),
userStatus() {
return this.USER_LEVEL_PROJECTS[this.project.slug];
},
checked: { checked: {
get() { get() {
return this.checkedFeatures; return this.checkedFeatures;
...@@ -390,6 +394,7 @@ export default { ...@@ -390,6 +394,7 @@ export default {
return this.pageNumbers.slice(firstPageInList, firstPageInList + pagesQuantity); return this.pageNumbers.slice(firstPageInList, firstPageInList + pagesQuantity);
}, },
}, },
destroyed() { destroyed() {
this.$store.commit('feature/UPDATE_CHECKED_FEATURES', []); this.$store.commit('feature/UPDATE_CHECKED_FEATURES', []);
}, },
...@@ -400,25 +405,23 @@ export default { ...@@ -400,25 +405,23 @@ export default {
}, },
canDeleteFeature(feature) { canDeleteFeature(feature) {
return feature.properties.creator.username !== this.user.username && if (this.userStatus === 'Administrateur projet') return true; //* can delete all
!this.user.is_superuser && //* others can delete only their own features
!this.permissions.is_project_administrator; return feature.properties.creator.username === this.user.username;
}, },
canEditFeature(feature) { canEditFeature(feature) {
const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug]; const permissions = {
const access = {
'Administrateur projet' : ['draft', 'published', 'archived'], 'Administrateur projet' : ['draft', 'published', 'archived'],
Modérateur : ['pending'], Modérateur : ['pending', 'published'],
'Super Contributeur' : ['draft', this.project.moderation ? 'pending' : 'published'], 'Super Contributeur' : ['draft', 'pending', 'published'],
Contributeur : ['draft', this.project.moderation ? 'pending' : 'published'], Contributeur : ['draft', 'pending', 'published'],
}; };
//if (userStatus === "Super Contributeur" || userStatus === "Contributeur") { //? should super contributeur behave the same, I don't think so if (this.userStatus === 'Contributeur' && feature.properties.creator.username !== this.user.username) {
if (userStatus === 'Contributeur' && feature.properties.creator.username !== this.user.username) {
return false; return false;
} else if (access[userStatus]) { } else if (permissions[this.userStatus]) {
return access[userStatus].includes(feature.properties.status.value); return permissions[this.userStatus].includes(feature.properties.status.value);
} else { } else {
return false; return false;
} }
......
...@@ -147,12 +147,12 @@ ...@@ -147,12 +147,12 @@
v-model="form.title" v-model="form.title"
type="text" type="text"
name="title" name="title"
@keyup.enter="fetchPagedFeatures" @keyup.enter="resetPaginationNfetchFeatures"
> >
<button <button
id="submit-search" id="submit-search"
class="ui teal icon button" class="ui teal icon button"
@click="fetchPagedFeatures" @click="resetPaginationNfetchFeatures"
> >
<i class="search icon" /> <i class="search icon" />
</button> </button>
...@@ -399,10 +399,10 @@ export default { ...@@ -399,10 +399,10 @@ export default {
watch: { watch: {
'form.type.selected'() { 'form.type.selected'() {
this.fetchPagedFeatures(); this.resetPaginationNfetchFeatures();
}, },
'form.status.selected.value'() { 'form.status.selected.value'() {
this.fetchPagedFeatures(); this.resetPaginationNfetchFeatures();
}, },
map(newValue) { map(newValue) {
if (newValue && this.paginatedFeatures && this.paginatedFeatures.length) { if (newValue && this.paginatedFeatures && this.paginatedFeatures.length) {
...@@ -681,6 +681,16 @@ export default { ...@@ -681,6 +681,16 @@ export default {
}); });
}, },
resetPaginationNfetchFeatures() {
this.pagination = {
currentPage: 1,
pagesize: 15,
start: 0,
end: 15,
},
this.fetchPagedFeatures();
},
//* Pagination for table *// //* Pagination for table *//
handlePageChange(page) { handlePageChange(page) {
......
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