diff --git a/src/components/feature/FeatureListTable.vue b/src/components/feature/FeatureListTable.vue index f9fc303eda1d4d5745921d7bcc3a042ce86139ab..53edfe567fa6e300b08105bc3b0e1d5bda81b3e7 100644 --- a/src/components/feature/FeatureListTable.vue +++ b/src/components/feature/FeatureListTable.vue @@ -390,6 +390,7 @@ export default { return this.pageNumbers.slice(firstPageInList, firstPageInList + pagesQuantity); }, }, + destroyed() { this.$store.commit('feature/UPDATE_CHECKED_FEATURES', []); }, @@ -400,6 +401,17 @@ export default { }, canDeleteFeature(feature) { + const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug]; + console.log(this.user.username); + console.log(feature.properties.creator.username); + if (feature.properties.creator.username === this.user.username) { + console.log(userStatus); + console.log(userStatus === 'Super Contributeur'); + } + if ((userStatus === 'Super Contributeur' || userStatus === 'Modérateur') && + feature.properties.creator.username !== this.user.username) { + return false; + } return feature.properties.creator.username !== this.user.username && !this.user.is_superuser && !this.permissions.is_project_administrator; @@ -407,18 +419,17 @@ export default { canEditFeature(feature) { const userStatus = this.USER_LEVEL_PROJECTS[this.project.slug]; - const access = { + const permissions = { 'Administrateur projet' : ['draft', 'published', 'archived'], - Modérateur : ['pending'], - 'Super Contributeur' : ['draft', this.project.moderation ? 'pending' : 'published'], + Modérateur : ['pending', 'published'], + 'Super Contributeur' : ['draft', 'pending', 'published'], Contributeur : ['draft', this.project.moderation ? 'pending' : 'published'], }; - //if (userStatus === "Super Contributeur" || userStatus === "Contributeur") { //? should super contributeur behave the same, I don't think so if (userStatus === 'Contributeur' && feature.properties.creator.username !== this.user.username) { return false; - } else if (access[userStatus]) { - return access[userStatus].includes(feature.properties.status.value); + } else if (permissions[userStatus]) { + return permissions[userStatus].includes(feature.properties.status.value); } else { return false; } diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index eb359d3c0601fe00cc197e219fc05b577bc712e1..8b5ee05bacc3ed7ea057f712f9bb3646d193cfa6 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -147,12 +147,12 @@ v-model="form.title" type="text" name="title" - @keyup.enter="fetchPagedFeatures" + @keyup.enter="resetPaginationNfetchFeatures" > <button id="submit-search" class="ui teal icon button" - @click="fetchPagedFeatures" + @click="resetPaginationNfetchFeatures" > <i class="search icon" /> </button> @@ -399,10 +399,10 @@ export default { watch: { 'form.type.selected'() { - this.fetchPagedFeatures(); + this.resetPaginationNfetchFeatures(); }, 'form.status.selected.value'() { - this.fetchPagedFeatures(); + this.resetPaginationNfetchFeatures(); }, map(newValue) { if (newValue && this.paginatedFeatures && this.paginatedFeatures.length) { @@ -670,6 +670,7 @@ export default { featureAPI.getPaginatedFeatures(url) .then((data) => { if (data) { + console.log({ data }); this.featuresCount = data.count; this.previous = data.previous; this.next = data.next; @@ -681,6 +682,16 @@ export default { }); }, + resetPaginationNfetchFeatures() { + this.pagination = { + currentPage: 1, + pagesize: 15, + start: 0, + end: 15, + }, + this.fetchPagedFeatures(); + }, + //* Pagination for table *// handlePageChange(page) {