diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index f62de2ccefdc53b6cc17c2029b50cde0af788de7..42538f7d45a6d3d89d4d85acca5ba81fcb1b167f 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -191,7 +191,7 @@ import { mapUtil } from "@/assets/js/map-util.js"; import SidebarLayers from "@/components/map-layers/SidebarLayers"; import FeatureListTable from "@/components/feature/FeatureListTable"; import Dropdown from "@/components/Dropdown.vue"; -import axios from '@/axios-client.js'; +import axios from "@/axios-client.js"; // axios.defaults.headers.common['X-CSRFToken'] = (name => { // var re = new RegExp(name + "=([^;]+)"); @@ -280,7 +280,7 @@ export default { statusChoices() { //* if project is not moderate, remove pending status return this.form.status.choices.filter((el) => - this.project.moderation ? true : el.value !== "pending" + this.project && this.project.moderation ? true : el.value !== "pending" ); }, @@ -293,17 +293,6 @@ export default { return pageNumb; }); }, - - /* displayedPageNumbers() { - return this.pageNumbers; - //return [...this.pageNumbers].splice(0, 4); - }, */ - - /* displayedPageEnd() { - return this.featuresCount <= this.pagination.end - ? this.featuresCount - : this.pagination.end; - }, */ }, methods: { @@ -318,11 +307,9 @@ export default { .then(() => { if (!this.modalAllDeleteOpen) { this.$store - .dispatch("feature/GET_PROJECT_FEATURES", - { - project_slug: this.project.slug - } - ) + .dispatch("feature/GET_PROJECT_FEATURES", { + project_slug: this.project.slug, + }) .then(() => { this.updateFeatures(); this.checkedFeatures.splice(feature_id); @@ -343,7 +330,8 @@ export default { this.modalAllDelete(); }, - updateFeaturesOnMap() { + onFilterChange() { + console.log("onFilterChange", this.featureGroup); if (this.featureGroup) { const features = this.geojsonFeatures; this.featureGroup.clearLayers(); @@ -370,13 +358,12 @@ export default { this.zoom = this.$route.query.zoom || ""; this.lat = this.$route.query.lat || ""; this.lng = this.$route.query.lng || ""; - + var mapDefaultViewCenter = this.$store.state.configuration.DEFAULT_MAP_VIEW.center; var mapDefaultViewZoom = this.$store.state.configuration.DEFAULT_MAP_VIEW.zoom; - this.map = mapUtil.createMap(this.$refs.map, { zoom: this.zoom, lat: this.lat, @@ -408,7 +395,7 @@ export default { }, handlePageChange(page) { - console.log("handlePageChange", page, typeof page) + console.log("handlePageChange", page, typeof page); if (page === "next") { this.toNextPage(); } else if (page === "previous") { @@ -553,7 +540,7 @@ export default { this.geojsonFeatures = response.data.results.features; //if (response.data.results.features.length > 0) { this.loadFeatures(); - this.updateFeaturesOnMap(); + this.onFilterChange(); //} } this.$store.commit("DISCARD_LOADER"); @@ -597,32 +584,17 @@ export default { }, }, -/* created() { - if (!this.project) { - this.$store.dispatch( - "GET_PROJECT_INFO", - this.$route.params.slug, - "noFeatures" //* not fetching classic features, too heavy, using paginated features instead - ); - } - }, */ - mounted() { if (!this.project) { // Chargements des features et infos projet en cas d'arrivée directe sur la page ou de refresh - axios.all([ - this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug), - this.$store.dispatch('feature/GET_PROJECT_FEATURES', { - project_slug: this.$route.params.slug - })]) + this.$store + .dispatch("GET_PROJECT_INFO", this.$route.params.slug) .then(() => { this.initMap(); }); - } - else { + } else { this.initMap(); } - }, destroyed() {