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

WIP

parent a81194fb
No related branches found
No related tags found
1 merge request!162REDMINE_ISSUE-11784
...@@ -30,9 +30,7 @@ ...@@ -30,9 +30,7 @@
></a> ></a>
<div class="item"> <div class="item">
<h4> <h4>
{{ filteredFeatures.length }} signalement{{ {{ featuresCount }} signalement{{ featuresCount > 1 ? "s" : "" }}
filteredFeatures.length > 1 ? "s" : ""
}}
</h4> </h4>
</div> </div>
...@@ -139,11 +137,11 @@ ...@@ -139,11 +137,11 @@
<div v-show="showMap" class="ui tab active map-container" data-tab="map"> <div v-show="showMap" class="ui tab active map-container" data-tab="map">
<div id="map" ref="map"></div> <div id="map" ref="map"></div>
<SidebarLayers v-if="baseMaps && map" /> <SidebarLayers v-if="basemaps && map" />
</div> </div>
<FeatureListTable <FeatureListTable
v-show="!showMap" v-show="!showMap"
:filteredFeatures="filteredFeatures" :filteredFeatures="geojsonFeatures"
:checkedFeatures.sync="checkedFeatures" :checkedFeatures.sync="checkedFeatures"
/> />
...@@ -188,11 +186,11 @@ import FeatureListTable from "@/components/feature/FeatureListTable"; ...@@ -188,11 +186,11 @@ import FeatureListTable from "@/components/feature/FeatureListTable";
import Dropdown from "@/components/Dropdown.vue"; import Dropdown from "@/components/Dropdown.vue";
const axios = require("axios"); const axios = require("axios");
axios.defaults.headers.common['X-CSRFToken'] = (name => { axios.defaults.headers.common["X-CSRFToken"] = ((name) => {
var re = new RegExp(name + "=([^;]+)"); var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie); var value = re.exec(document.cookie);
return (value !== null) ? unescape(value[1]) : null; return value !== null ? unescape(value[1]) : null;
})('csrftoken'); })("csrftoken");
export default { export default {
name: "Feature_list", name: "Feature_list",
...@@ -239,6 +237,9 @@ export default { ...@@ -239,6 +237,9 @@ export default {
}, },
geojsonFeatures: [], geojsonFeatures: [],
featuresCount: 0,
previous: null,
next: null,
filterStatus: null, filterStatus: null,
filterType: null, filterType: null,
baseUrl: this.$store.state.configuration.BASE_URL, baseUrl: this.$store.state.configuration.BASE_URL,
...@@ -246,6 +247,8 @@ export default { ...@@ -246,6 +247,8 @@ export default {
zoom: null, zoom: null,
lat: null, lat: null,
lng: null, lng: null,
limit: 15,
offset: 0,
showMap: true, showMap: true,
showAddFeature: false, showAddFeature: false,
}; };
...@@ -255,12 +258,13 @@ export default { ...@@ -255,12 +258,13 @@ export default {
...mapGetters(["project", "permissions"]), ...mapGetters(["project", "permissions"]),
...mapState("feature", ["checkedFeatures"]), ...mapState("feature", ["checkedFeatures"]),
...mapState("feature_type", ["feature_types"]), ...mapState("feature_type", ["feature_types"]),
...mapState("map", ["basemaps"]),
baseMaps() { API_BASE_URL() {
return this.$store.state.map.basemaps; return this.$store.state.configuration.VUE_APP_DJANGO_API_BASE;
}, },
filteredFeatures() { /* filteredFeatures() {
let results = this.geojsonFeatures; let results = this.geojsonFeatures;
if (this.form.type.selected) { if (this.form.type.selected) {
results = results.filter( results = results.filter(
...@@ -283,7 +287,7 @@ export default { ...@@ -283,7 +287,7 @@ export default {
}); });
} }
return results; return results;
}, }, */
statusChoices() { statusChoices() {
//* if project is not moderate, remove pending status //* if project is not moderate, remove pending status
...@@ -293,13 +297,13 @@ export default { ...@@ -293,13 +297,13 @@ export default {
}, },
}, },
watch: { /* watch: {
filteredFeatures(newValue, oldValue) { filteredFeatures(newValue, oldValue) {
if (newValue && newValue !== oldValue) { if (newValue && newValue !== oldValue) {
this.onFilterChange(); this.onFilterChange();
} }
}, },
}, }, */
methods: { methods: {
modalAllDelete() { modalAllDelete() {
...@@ -307,15 +311,15 @@ export default { ...@@ -307,15 +311,15 @@ export default {
}, },
deleteFeature(feature_id) { deleteFeature(feature_id) {
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${feature_id}/?project__slug=${this.project.slug}`; const url = `${this.API_BASE_URL}features/${feature_id}/?project__slug=${this.project.slug}`;
axios axios
.delete(url, {}) .delete(url, {})
.then(() => { .then(() => {
if (!this.modalAllDeleteOpen) { if (!this.modalAllDeleteOpen) {
this.$store this.$store
.dispatch("feature/GET_PROJECT_FEATURES", this.project.slug) .dispatch("feature/GET_PROJECT_FEATURES", this.project.slug) // ? Toujours nécessaire de mettre à jour les features classiques ?
.then(() => { .then(() => {
this.getNloadGeojsonFeatures(); this.updateFeatures();
this.checkedFeatures.splice(feature_id); this.checkedFeatures.splice(feature_id);
}); });
} }
...@@ -335,8 +339,10 @@ export default { ...@@ -335,8 +339,10 @@ export default {
}, },
onFilterChange() { onFilterChange() {
// ? Besoin de faire un fetch avec nouveau filtres ici ?
if (this.featureGroup) { if (this.featureGroup) {
const features = this.filteredFeatures; //const features = this.filteredFeatures;
const features = this.geojsonFeatures;
this.featureGroup.clearLayers(); this.featureGroup.clearLayers();
this.featureGroup = mapUtil.addFeatures( this.featureGroup = mapUtil.addFeatures(
features, features,
...@@ -381,26 +387,23 @@ export default { ...@@ -381,26 +387,23 @@ export default {
}); });
// --------- End sidebar events ---------- // --------- End sidebar events ----------
this.getNloadGeojsonFeatures(); this.updateFeatures();
setTimeout( setTimeout(() => {
function () { let project_id = this.$route.params.slug.split("-")[0];
let project_id = this.$route.params.slug.split("-")[0]; const mvtUrl = `${this.API_BASE_URL}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`;
const mvtUrl = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features.mvt/?tile={z}/{x}/{y}&project_id=${project_id}`; mapUtil.addVectorTileLayer(
mapUtil.addVectorTileLayer( mvtUrl,
mvtUrl, this.$route.params.slug,
this.$route.params.slug, this.$store.state.feature_type.feature_types,
this.$store.state.feature_type.feature_types, this.form
this.form );
); mapUtil.addGeocoders(this.$store.state.configuration);
mapUtil.addGeocoders(this.$store.state.configuration); }, 1000);
}.bind(this),
1000
);
}, },
getNloadGeojsonFeatures() { updateFeatures() {
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; const url = `${this.API_BASE_URL}projects/${this.$route.params.slug}/feature-paginated/?output=geojson&limit=${this.limit}&offset=${this.offset}`;
this.$store.commit( this.$store.commit(
"DISPLAY_LOADER", "DISPLAY_LOADER",
"Récupération des signalements en cours..." "Récupération des signalements en cours..."
...@@ -408,8 +411,13 @@ export default { ...@@ -408,8 +411,13 @@ export default {
axios axios
.get(url) .get(url)
.then((response) => { .then((response) => {
if (response.status === 200 && response.data.features.length > 0) { if (response.status === 200) {
this.loadFeatures(response.data.features); this.featuresCount = response.data.count;
this.previous = response.data.previous;
this.next = response.data.next;
if (response.data.results.features.length > 0) {
this.loadFeatures(response.data.results.features);
}
} }
this.$store.commit("DISCARD_LOADER"); this.$store.commit("DISCARD_LOADER");
}) })
...@@ -455,7 +463,11 @@ export default { ...@@ -455,7 +463,11 @@ export default {
created() { created() {
if (!this.project) { if (!this.project) {
this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug, "noFeatures"); this.$store.dispatch(
"GET_PROJECT_INFO",
this.$route.params.slug,
"noFeatures"
);
} }
}, },
......
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