From 54c031db14c43500af7fc71c26b65add5ed10610 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Mon, 6 Dec 2021 11:57:39 +0100 Subject: [PATCH] WIP: buildFilterParams automatic --- src/components/feature/FeatureListTable.vue | 22 ++++++------- src/views/feature/Feature_list.vue | 36 ++++++++++++--------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/components/feature/FeatureListTable.vue b/src/components/feature/FeatureListTable.vue index 524b23f5..7b360361 100644 --- a/src/components/feature/FeatureListTable.vue +++ b/src/components/feature/FeatureListTable.vue @@ -10,33 +10,33 @@ Statut <i :class="{ - down: isSortedAsc('statut'), - up: isSortedDesc('statut'), + down: isSortedAsc('status'), + up: isSortedDesc('status'), }" class="icon sort" - @click="changeSort('statut')" + @click="changeSort('status')" /> </th> <th class="center"> Type <i :class="{ - down: isSortedAsc('type'), - up: isSortedDesc('type'), + down: isSortedAsc('feature_type'), + up: isSortedDesc('feature_type'), }" class="icon sort" - @click="changeSort('type')" + @click="changeSort('feature_type')" /> </th> <th class="center"> Nom <i :class="{ - down: isSortedAsc('nom'), - up: isSortedDesc('nom'), + down: isSortedAsc('title'), + up: isSortedDesc('title'), }" class="icon sort" - @click="changeSort('nom')" + @click="changeSort('title')" /> </th> <th class="center"> @@ -267,10 +267,10 @@ export default { sortedFeatures = sortedFeatures.sort((a, b) => { let aProp = this.getFeatureDisplayName(a); let bProp = this.getFeatureDisplayName(b); - if (this.sort.column === "statut") { + if (this.sort.column === "status") { aProp = a.properties.status.value; bProp = b.properties.status.value; - } else if (this.sort.column === "type") { + } else if (this.sort.column === "feature_type") { aProp = a.properties.feature_type.title; bProp = b.properties.feature_type.title; } else if (this.sort.column === "updated_on") { diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index 533d6b0d..fb21c3df 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -234,6 +234,10 @@ export default { }, title: null, }, +/* filters: { + type: "", + value: "", + }, */ paginatedFeatures: [], baseUrl: this.$store.state.configuration.BASE_URL, map: null, @@ -389,7 +393,8 @@ export default { return featureType ? featureType.slug : null; }, - buildFilterParams({ filterType, filterValue }) { + buildFilterParams() { + const { filterType, filterValue } = this.filters; let params = ""; let typeFilter, statusFilter; //*** feature type ***// @@ -444,30 +449,31 @@ export default { return params; }, - updateTypeFeatures(filterValue) { + updateTypeFeatures(value) { //* only update:selection custom event can trigger the filter update, //* but it happens before the value is updated, thus using selected value from event to update query - this.fetchPagedFeatures({ filterType: "featureType", filterValue }); + //this.fetchPagedFeatures({ filterType: "featureType", filterValue }); + this.filters = { type: "featureType", value }; + this.fetchPagedFeatures(); }, - updateStatusFeatures(filterValue) { - this.fetchPagedFeatures({ filterType: "status", filterValue }); + updateStatusFeatures(value) { + //this.fetchPagedFeatures({ filterType: "status", filterValue }); + this.filters = { type: "status", value }; + this.fetchPagedFeatures(); }, fetchPagedFeatures(params) { this.onFilterChange(); //* temporary, use paginated event to watch change in filters, to modify geojson on map let url = `${this.API_BASE_URL}projects/${this.$route.params.slug}/feature-paginated/?output=geojson&limit=${this.pagination.pagesize}&offset=${this.pagination.start}`; + const filterParams = this.buildFilterParams(params); + if (filterParams === "abort") return; // ? to adapt ??? + url += filterParams; if (params) { - if (typeof params === "object") { - const filterParams = this.buildFilterParams(params); - if (filterParams === "abort") return; - url += filterParams; - } else { - //console.error("ONLY FOR DEV !!!!!!!!!!!!!"); - //params = params.replace("8000", "8010"); //* for dev uncomment to use proxy link - url = params; - } + //console.error("ONLY FOR DEV !!!!!!!!!!!!!"); + //params = params.replace("8000", "8010"); //* for dev uncomment to use proxy link + url = params; } this.$store.commit( @@ -499,7 +505,7 @@ export default { }, handleSortChange(ordering) { - console.log("ORDERING", ordering) + console.log("ORDERING", ordering); }, toPage(pageNumber) { -- GitLab