From 3d1516cf694713c6bb4e8cc0fd8131237995afd8 Mon Sep 17 00:00:00 2001 From: DESPRES Damien <ddespres@neogeo.fr> Date: Fri, 24 Sep 2021 16:59:58 +0200 Subject: [PATCH] fix #11735 --- src/store/index.js | 27 ++++++++++++++----------- src/store/modules/feature.js | 2 +- src/store/modules/feature_type.js | 2 +- src/store/modules/map.js | 2 +- src/views/feature/Feature_edit.vue | 32 ++++++++++++++++-------------- 5 files changed, 35 insertions(+), 30 deletions(-) diff --git a/src/store/index.js b/src/store/index.js index cb00de20..f0de8a56 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -101,12 +101,12 @@ export default new Vuex.Store({ }, actions: { - async GET_ALL_PROJECTS({ commit }) { + GET_ALL_PROJECTS({ commit }) { function parseDate(date) { let dateArr = date.split("/").reverse() return new Date(dateArr[0], dateArr[1] - 1, dateArr[2]) } - await axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}projects/`) .then((response) => { if (response.status === 200 && response.data) { @@ -118,8 +118,8 @@ export default new Vuex.Store({ throw error; }); }, - async GET_STATIC_PAGES({ commit }) { - await axios + GET_STATIC_PAGES({ commit }) { + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}flat-pages/`) .then((response) => (commit("SET_STATIC_PAGES", response.data))) .catch((error) => { @@ -158,7 +158,7 @@ export default new Vuex.Store({ }, USER_INFO({ commit }) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user_info/`) .then((response) => { if (response && response.status === 200) { @@ -199,7 +199,7 @@ export default new Vuex.Store({ }); }, GET_USER_LEVEL_PROJECTS({ commit }) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user-level-projects/`) .then((response) => { if (response && response.status === 200) { @@ -212,7 +212,7 @@ export default new Vuex.Store({ }, GET_USER_LEVEL_PERMISSIONS({ commit }) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}user-permissions/`) .then((response) => { if (response && response.status === 200) { @@ -226,14 +226,17 @@ export default new Vuex.Store({ GET_PROJECT_INFO({ commit, dispatch }, slug) { commit("SET_PROJECT_SLUG", slug); - dispatch("GET_PROJECT_LAST_MESSAGES", slug); - dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug); - dispatch("feature/GET_PROJECT_FEATURES", slug); - dispatch("map/GET_BASEMAPS", slug); + return Promise.all([ + dispatch("GET_PROJECT_LAST_MESSAGES", slug), + dispatch("feature_type/GET_PROJECT_FEATURE_TYPES", slug), + dispatch("feature/GET_PROJECT_FEATURES", slug), + dispatch("map/GET_BASEMAPS", slug), + ]); + }, GET_PROJECT_LAST_MESSAGES({ commit }, project_slug) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/comments/`) .then((response) => { if (response && response.status === 200) { diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js index c13ad732..37f00afd 100644 --- a/src/store/modules/feature.js +++ b/src/store/modules/feature.js @@ -65,7 +65,7 @@ const feature = { }, actions: { GET_PROJECT_FEATURES({ commit, /* dispatch */ }, project_slug) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/feature/`) .then((response) => { if (response.status === 200 && response.data) { diff --git a/src/store/modules/feature_type.js b/src/store/modules/feature_type.js index f4148c17..68ef9d09 100644 --- a/src/store/modules/feature_type.js +++ b/src/store/modules/feature_type.js @@ -71,7 +71,7 @@ const feature_type = { }, actions: { GET_PROJECT_FEATURE_TYPES({ commit }, project_slug) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${project_slug}/feature-types/`) .then((response) => commit("SET_FEATURE_TYPES", response.data.feature_types)) .catch((error) => { diff --git a/src/store/modules/map.js b/src/store/modules/map.js index f29ef9f4..3631f82b 100644 --- a/src/store/modules/map.js +++ b/src/store/modules/map.js @@ -88,7 +88,7 @@ const map = { actions: { GET_LAYERS({ commit }) { - axios + return axios .get(`${this.state.configuration.VUE_APP_DJANGO_API_BASE}layers/`) .then((response) => (commit("SET_LAYERS", response.data))) .catch((error) => { diff --git a/src/views/feature/Feature_edit.vue b/src/views/feature/Feature_edit.vue index 900bb1b0..9fd5c74a 100644 --- a/src/views/feature/Feature_edit.vue +++ b/src/views/feature/Feature_edit.vue @@ -226,7 +226,7 @@ <script> import frag from "vue-frag"; -import { mapGetters, mapState } from "vuex"; +import { mapState } from "vuex"; import FeatureAttachmentForm from "@/components/feature/FeatureAttachmentForm"; import FeatureLinkedForm from "@/components/feature/FeatureLinkedForm"; import FeatureExtraForm from "@/components/feature/FeatureExtraForm"; @@ -265,6 +265,7 @@ export default { data() { return { map: null, + feature_type:null, file: null, showGeoRef: false, showGeoPositionBtn: true, @@ -325,8 +326,6 @@ export default { "features", "extra_form", ]), - ...mapGetters("feature_type", ["feature_type"]), - field_title() { if (this.feature_type) { if (this.feature_type.title_optional) { @@ -358,11 +357,6 @@ export default { }, watch: { - feature_type() { - this.onFeatureTypeLoaded(); - this.initExtraForms(); - }, - feature(newValue) { if (this.$route.name === "editer-signalement") { this.initForm(); @@ -798,8 +792,6 @@ export default { }, initMap() { - //console.log(drawnItems); - //console.log(configuration); var mapDefaultViewCenter = this.$store.state.configuration.DEFAULT_MAP_VIEW.center; var mapDefaultViewZoom = @@ -857,9 +849,7 @@ export default { }, created() { - if (!this.project) { - this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); - } + this.$store.commit( "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.$route.params.slug_type_signal @@ -877,8 +867,20 @@ export default { }, mounted() { - this.initForm(); - this.initMap(); + let ftSlug=this.$route.params.slug_type_signal; + this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug).then(data=>{ + console.log(data) + this.initForm(); + this.initMap(); + this.feature_type=this.$store.state.feature_type.feature_types.find( + (el) => el.slug === ftSlug + ); + this.onFeatureTypeLoaded(); + this.initExtraForms(); + }) + + + }, }; </script> -- GitLab