Skip to content
Snippets Groups Projects
Commit 1d25d813 authored by Sébastien DA ROCHA's avatar Sébastien DA ROCHA :bicyclist:
Browse files

Merge branch 'redmine-issues/12013' into 'develop'

parents 68c8cfbb d7a58f07
No related branches found
No related tags found
No related merge requests found
...@@ -37,7 +37,11 @@ ...@@ -37,7 +37,11 @@
</div> </div>
<div <div
v-if="project && feature_types && permissions.can_create_feature" v-if="
project &&
feature_types.length > 0 &&
permissions.can_create_feature
"
class="item right" class="item right"
> >
<div <div
...@@ -322,10 +326,10 @@ export default { ...@@ -322,10 +326,10 @@ export default {
}, },
onFilterChange() { onFilterChange() {
var features = this.filteredFeatures; if (this.featureGroup) {
this.featureGroup.clearLayers(); const features = this.filteredFeatures;
this.featureGroup = mapUtil.addFeatures(features, {}); this.featureGroup.clearLayers();
if (features.length > 0) { this.featureGroup = mapUtil.addFeatures(features, {});
mapUtil mapUtil
.getMap() .getMap()
.fitBounds(this.featureGroup.getBounds(), { padding: [25, 25] }); .fitBounds(this.featureGroup.getBounds(), { padding: [25, 25] });
...@@ -356,9 +360,8 @@ export default { ...@@ -356,9 +360,8 @@ export default {
}); });
// --------- End sidebar events ---------- // --------- End sidebar events ----------
if (this.$store.state.map.geojsonFeatures) { if (this.features && this.features.length > 0) {
this.loadFeatures(this.$store.state.map.geojsonFeatures); //* features are updated consistently, then if features exists, we can fetch the geojson version
} else {
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`;
this.$store.commit( this.$store.commit(
"DISPLAY_LOADER", "DISPLAY_LOADER",
...@@ -367,7 +370,9 @@ export default { ...@@ -367,7 +370,9 @@ export default {
axios axios
.get(url) .get(url)
.then((response) => { .then((response) => {
this.loadFeatures(response.data.features); if (response.status === 200 && response.data.features.length > 0) {
this.loadFeatures(response.data.features);
}
this.$store.commit("DISCARD_LOADER"); this.$store.commit("DISCARD_LOADER");
}) })
.catch((error) => { .catch((error) => {
......
...@@ -590,7 +590,6 @@ export default { ...@@ -590,7 +590,6 @@ export default {
if (this.project && this.permissions.can_view_project) { if (this.project && this.permissions.can_view_project) {
this.$store.dispatch("map/INITIATE_MAP"); this.$store.dispatch("map/INITIATE_MAP");
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`;
let self = this;
axios axios
.get(url) .get(url)
.then((response) => { .then((response) => {
...@@ -600,7 +599,9 @@ export default { ...@@ -600,7 +599,9 @@ export default {
mapUtil mapUtil
.getMap() .getMap()
.fitBounds(featureGroup.getBounds(), { padding: [25, 25] }); .fitBounds(featureGroup.getBounds(), { padding: [25, 25] });
self.$store.commit("map/SET_GEOJSON_FEATURES", features); this.$store.commit("map/SET_GEOJSON_FEATURES", features);
} else {
this.$store.commit("map/SET_GEOJSON_FEATURES", []);
} }
}) })
.catch((error) => { .catch((error) => {
......
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