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

reset pagination after filter change in feature list

parent 746dbb21
No related branches found
No related tags found
No related merge requests found
......@@ -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;
}
......
......@@ -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) {
......
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