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 @@
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") {
......
......@@ -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) {
......
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