From 185344c86653da7e1f6c26514bec7aa493c38bd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Wed, 1 Dec 2021 11:41:54 +0100 Subject: [PATCH] fix unexisting feature at creation not prevented --- src/views/feature/Feature_edit.vue | 51 ++++++++++++++++-------------- 1 file changed, 28 insertions(+), 23 deletions(-) diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index 981b12d9..8ce75b2a 100644 --- a/src/views/feature/Feature_edit.vue +++ b/src/views/feature/Feature_edit.vue @@ -267,7 +267,7 @@ import featureAPI from "@/services/feature-api"; import L from "leaflet"; import "leaflet-draw"; import { mapUtil } from "@/assets/js/map-util.js"; -import axios from '@/axios-client.js'; +import axios from "@/axios-client.js"; import flip from "@turf/flip"; // axios.defaults.headers.common["X-CSRFToken"] = ((name) => { @@ -367,9 +367,8 @@ export default { return this.$route.name; }, - feature: function () { - const result = this.$store.state.feature.current_feature; - return result; + feature () { + return this.$store.state.feature.current_feature; }, orderedCustomFields() { @@ -1008,25 +1007,31 @@ export default { }, mounted() { - axios.all([this.$store - .dispatch("GET_PROJECT_INFO", this.$route.params.slug), - this.$store.dispatch('feature/GET_PROJECT_FEATURE', { - project_slug: this.$route.params.slug, - feature_id: this.$route.params.slug_signal - })]) - .then(() => { - this.initForm(); - this.initMap(); - this.onFeatureTypeLoaded(); - this.initExtraForms(this.feature); - - setTimeout( - function () { - mapUtil.addGeocoders(this.$store.state.configuration); - }.bind(this), - 1000 - ); - }); + let promises = [ + this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug), + ]; + if (this.$route.params.slug_signal) { + promises.push( + this.$store.dispatch("feature/GET_PROJECT_FEATURE", { + project_slug: this.$route.params.slug, + feature_id: this.$route.params.slug_signal, + }) + ); + } + + Promise.all(promises).then(() => { + this.initForm(); + this.initMap(); + this.onFeatureTypeLoaded(); + if (this.feature) this.initExtraForms(this.feature); + + setTimeout( + function () { + mapUtil.addGeocoders(this.$store.state.configuration); + }.bind(this), + 1000 + ); + }); }, destroyed() { -- GitLab