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

fix modal style, click event in button not icon & reload only features after delete

parent b55d545e
No related branches found
No related tags found
No related merge requests found
...@@ -112,7 +112,9 @@ export default { ...@@ -112,7 +112,9 @@ export default {
setTimeout(() => { setTimeout(() => {
this.isOpen = false; this.isOpen = false;
}, 0); }, 0);
if (this.filteredOptions) this.$emit("update:selection", this.filteredOptions[index]); if (this.filteredOptions) {
this.$emit("update:selection", this.filteredOptions[index]);
}
this.input = ""; this.input = "";
}, },
......
...@@ -75,12 +75,13 @@ ...@@ -75,12 +75,13 @@
<div <div
v-if="checkedFeatures.length" v-if="checkedFeatures.length"
@click="modalAllDelete"
class="ui button compact button-hover-red margin-left-25" class="ui button compact button-hover-red margin-left-25"
data-tooltip="Effacer tous les types de signalements sélectionnés" data-tooltip="Effacer tous les types de signalements sélectionnés"
data-position="left center" data-position="left center"
data-variation="mini" data-variation="mini"
> >
<i class="grey trash fitted icon" @click="modalAllDelete"></i> <i class="grey trash fitted icon"></i>
</div> </div>
</div> </div>
</div> </div>
...@@ -170,7 +171,7 @@ ...@@ -170,7 +171,7 @@
<button <button
@click="deleteAllFeatureSelection" @click="deleteAllFeatureSelection"
type="button" type="button"
class="ui red compact fluid button" class="ui red compact fluid button no-margin"
> >
Confirmer la suppression Confirmer la suppression
</button> </button>
...@@ -303,12 +304,14 @@ export default { ...@@ -303,12 +304,14 @@ export default {
}, },
deleteFeature(feature) { deleteFeature(feature) {
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${feature.feature_id}`; const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}features/${feature.feature_id}/?project__slug=${this.project.slug}`;
axios axios
.delete(url, {}) .delete(url, {})
.then(() => { .then(() => {
if (!this.modalAllDeleteOpen) { if (!this.modalAllDeleteOpen) {
this.$router.go(); this.$store
.dispatch("feature/GET_PROJECT_FEATURES", this.project.slug)
.then(() => this.getFeaturesAsGeojson());
} }
}) })
.catch(() => { .catch(() => {
...@@ -329,27 +332,27 @@ export default { ...@@ -329,27 +332,27 @@ export default {
if (this.featureGroup) { if (this.featureGroup) {
const features = this.filteredFeatures; const features = this.filteredFeatures;
this.featureGroup.clearLayers(); this.featureGroup.clearLayers();
this.featureGroup = mapUtil.addFeatures(features, {},false,this.$store.state.feature_type.feature_types); this.featureGroup = mapUtil.addFeatures(
features,
{},
false,
this.$store.state.feature_type.feature_types
);
mapUtil.getMap().invalidateSize(); mapUtil.getMap().invalidateSize();
mapUtil.getMap()._onResize();// force refresh for vector tiles mapUtil.getMap()._onResize(); // force refresh for vector tiles
if(this.featureGroup.getLayers().length>0){ if (this.featureGroup.getLayers().length > 0) {
mapUtil mapUtil
.getMap() .getMap()
.fitBounds(this.featureGroup.getBounds(), { padding: [25, 25] }); .fitBounds(this.featureGroup.getBounds(), { padding: [25, 25] });
} else {
mapUtil.getMap().zoomOut(1);
} }
else{
mapUtil
.getMap()
.zoomOut(1);
}
} }
}, },
initMap() { initMap() {
console.log(this) console.log(this);
this.zoom = this.$route.query.zoom || ""; this.zoom = this.$route.query.zoom || "";
this.lat = this.$route.query.lat || ""; this.lat = this.$route.query.lat || "";
this.lng = this.$route.query.lng || ""; this.lng = this.$route.query.lng || "";
...@@ -373,47 +376,60 @@ export default { ...@@ -373,47 +376,60 @@ export default {
}); });
// --------- End sidebar events ---------- // --------- End sidebar events ----------
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`; this.getFeaturesAsGeojson();
this.$store.commit(
"DISPLAY_LOADER",
"Récupération des signalements en cours..."
);
axios
.get(url)
.then((response) => {
if (response.status === 200 && response.data.features.length > 0) {
this.loadFeatures(response.data.features);
}
this.$store.commit("DISCARD_LOADER");
})
.catch((error) => {
this.$store.commit("DISCARD_LOADER");
throw error;
});
setTimeout( setTimeout(
function () { function () {
let project_id=this.$route.params.slug.split('-')[0]; let project_id = this.$route.params.slug.split("-")[0];
const mvtUrl = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}/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(mvtUrl,this.$route.params.slug,this.$store.state.feature_type.feature_types,this.form); mapUtil.addVectorTileLayer(
mvtUrl,
this.$route.params.slug,
this.$store.state.feature_type.feature_types,
this.form
);
mapUtil.addGeocoders(this.$store.state.configuration); mapUtil.addGeocoders(this.$store.state.configuration);
}.bind(this), }.bind(this),
1000 1000
); );
}, },
getFeaturesAsGeojson() {
const url = `${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.$route.params.slug}/feature/?output=geojson`;
this.$store.commit(
"DISPLAY_LOADER",
"Récupération des signalements en cours..."
);
axios
.get(url)
.then((response) => {
if (response.status === 200 && response.data.features.length > 0) {
this.loadFeatures(response.data.features);
}
this.$store.commit("DISCARD_LOADER");
})
.catch((error) => {
this.$store.commit("DISCARD_LOADER");
throw error;
});
},
loadFeatures(features) { loadFeatures(features) {
this.geojsonFeatures = features; this.geojsonFeatures = features;
const urlParams = new URLSearchParams(window.location.search); const urlParams = new URLSearchParams(window.location.search);
const featureType = urlParams.get("feature_type"); const featureType = urlParams.get("feature_type");
const featureStatus = urlParams.get("status"); const featureStatus = urlParams.get("status");
const featureTitle = urlParams.get("title"); const featureTitle = urlParams.get("title");
this.featureGroup = mapUtil.addFeatures(this.geojsonFeatures, { this.featureGroup = mapUtil.addFeatures(
featureType, this.geojsonFeatures,
featureStatus, {
featureTitle, featureType,
},false,this.$store.state.feature_type.feature_types); featureStatus,
featureTitle,
},
false,
this.$store.state.feature_type.feature_types
);
// Fit the map to bound only if no initial zoom and center are defined // Fit the map to bound only if no initial zoom and center are defined
if ( if (
(this.lat === "" || this.lng === "" || this.zoom === "") && (this.lat === "" || this.lng === "" || this.zoom === "") &&
......
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