diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js index 4b80d47b4cf1d305fde28b27484597f1d9a54650..9394dbe5aa72bd448bb7f595da8818c38d6e81ec 100644 --- a/src/store/modules/feature.js +++ b/src/store/modules/feature.js @@ -168,10 +168,10 @@ const feature = { function redirect(featureId) { dispatch( - 'GET_PROJECT_FEATURES', + 'GET_PROJECT_FEATURE', { project_slug: rootState.project_slug, - feature_type__slug: rootState.feature_type.current_feature_type_slug + feature_id: featureId } ) .then(() => { diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index 981b12d9a19a8c5b1e56906d770b34449fbf7a38..8ce75b2a79765073b41396ac138a70ec04769b78 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() {