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

WIP: buildFilterParams automatic

parent 3e9b65cb
No related branches found
No related tags found
2 merge requests!2132.3.2-rc1,!198REDMINE_ISSUE-12567
...@@ -10,33 +10,33 @@ ...@@ -10,33 +10,33 @@
Statut Statut
<i <i
:class="{ :class="{
down: isSortedAsc('statut'), down: isSortedAsc('status'),
up: isSortedDesc('statut'), up: isSortedDesc('status'),
}" }"
class="icon sort" class="icon sort"
@click="changeSort('statut')" @click="changeSort('status')"
/> />
</th> </th>
<th class="center"> <th class="center">
Type Type
<i <i
:class="{ :class="{
down: isSortedAsc('type'), down: isSortedAsc('feature_type'),
up: isSortedDesc('type'), up: isSortedDesc('feature_type'),
}" }"
class="icon sort" class="icon sort"
@click="changeSort('type')" @click="changeSort('feature_type')"
/> />
</th> </th>
<th class="center"> <th class="center">
Nom Nom
<i <i
:class="{ :class="{
down: isSortedAsc('nom'), down: isSortedAsc('title'),
up: isSortedDesc('nom'), up: isSortedDesc('title'),
}" }"
class="icon sort" class="icon sort"
@click="changeSort('nom')" @click="changeSort('title')"
/> />
</th> </th>
<th class="center"> <th class="center">
...@@ -267,10 +267,10 @@ export default { ...@@ -267,10 +267,10 @@ export default {
sortedFeatures = sortedFeatures.sort((a, b) => { sortedFeatures = sortedFeatures.sort((a, b) => {
let aProp = this.getFeatureDisplayName(a); let aProp = this.getFeatureDisplayName(a);
let bProp = this.getFeatureDisplayName(b); let bProp = this.getFeatureDisplayName(b);
if (this.sort.column === "statut") { if (this.sort.column === "status") {
aProp = a.properties.status.value; aProp = a.properties.status.value;
bProp = b.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; aProp = a.properties.feature_type.title;
bProp = b.properties.feature_type.title; bProp = b.properties.feature_type.title;
} else if (this.sort.column === "updated_on") { } else if (this.sort.column === "updated_on") {
......
...@@ -234,6 +234,10 @@ export default { ...@@ -234,6 +234,10 @@ export default {
}, },
title: null, title: null,
}, },
/* filters: {
type: "",
value: "",
}, */
paginatedFeatures: [], paginatedFeatures: [],
baseUrl: this.$store.state.configuration.BASE_URL, baseUrl: this.$store.state.configuration.BASE_URL,
map: null, map: null,
...@@ -389,7 +393,8 @@ export default { ...@@ -389,7 +393,8 @@ export default {
return featureType ? featureType.slug : null; return featureType ? featureType.slug : null;
}, },
buildFilterParams({ filterType, filterValue }) { buildFilterParams() {
const { filterType, filterValue } = this.filters;
let params = ""; let params = "";
let typeFilter, statusFilter; let typeFilter, statusFilter;
//*** feature type ***// //*** feature type ***//
...@@ -444,30 +449,31 @@ export default { ...@@ -444,30 +449,31 @@ export default {
return params; return params;
}, },
updateTypeFeatures(filterValue) { updateTypeFeatures(value) {
//* only update:selection custom event can trigger the filter update, //* 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 //* 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) { updateStatusFeatures(value) {
this.fetchPagedFeatures({ filterType: "status", filterValue }); //this.fetchPagedFeatures({ filterType: "status", filterValue });
this.filters = { type: "status", value };
this.fetchPagedFeatures();
}, },
fetchPagedFeatures(params) { fetchPagedFeatures(params) {
this.onFilterChange(); //* temporary, use paginated event to watch change in filters, to modify geojson on map 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}`; 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 (params) {
if (typeof params === "object") { //console.error("ONLY FOR DEV !!!!!!!!!!!!!");
const filterParams = this.buildFilterParams(params); //params = params.replace("8000", "8010"); //* for dev uncomment to use proxy link
if (filterParams === "abort") return; url = params;
url += filterParams;
} else {
//console.error("ONLY FOR DEV !!!!!!!!!!!!!");
//params = params.replace("8000", "8010"); //* for dev uncomment to use proxy link
url = params;
}
} }
this.$store.commit( this.$store.commit(
...@@ -499,7 +505,7 @@ export default { ...@@ -499,7 +505,7 @@ export default {
}, },
handleSortChange(ordering) { handleSortChange(ordering) {
console.log("ORDERING", ordering) console.log("ORDERING", ordering);
}, },
toPage(pageNumber) { toPage(pageNumber) {
......
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