From 1e6a2824296fadfd04e85659e4571797dc5187b1 Mon Sep 17 00:00:00 2001 From: leandro <leandroalmada86@gmail.com> Date: Wed, 25 Aug 2021 15:13:02 +0200 Subject: [PATCH] update import geojson --- .../feature_type/FeatureTypeCustomForm.vue | 10 ++++++++++ src/store/modules/feature_type.js | 7 +++++-- src/views/feature_type/Feature_type_edit.vue | 2 +- src/views/project/Project_detail.vue | 18 +++++------------- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/components/feature_type/FeatureTypeCustomForm.vue b/src/components/feature_type/FeatureTypeCustomForm.vue index 8879a61f..7d7ef4c4 100644 --- a/src/components/feature_type/FeatureTypeCustomForm.vue +++ b/src/components/feature_type/FeatureTypeCustomForm.vue @@ -217,5 +217,15 @@ export default { this.$store.commit("feature_type/UPDATE_COLOR_STYLE"); }, }, + beforeDestroy(){ + this.$store.commit("feature_type/EMPTY_CUSTOM_FORM"); + + }, + mounted() { + for (let el in this.customForm) { + if (el && this.form[el]) this.form[el].value = this.customForm[el].value; + } + + }, }; </script> diff --git a/src/store/modules/feature_type.js b/src/store/modules/feature_type.js index f762ad60..68916bf7 100644 --- a/src/store/modules/feature_type.js +++ b/src/store/modules/feature_type.js @@ -47,6 +47,9 @@ const feature_type = { feature_types: [], }, mutations: { + EMPTY_CUSTOM_FORM(state) { + state.customForms = []; + }, SET_FEATURE_TYPES(state, feature_types) { state.feature_types = feature_types; }, @@ -56,8 +59,8 @@ const feature_type = { UPDATE_FORM(state, payload) { state.form = payload; }, - ADD_CUSTOM_FORM(state, dataKey) { - state.customForms = [...state.customForms, { dataKey }]; + ADD_CUSTOM_FORM(state, customForm) { + state.customForms = [...state.customForms, customForm ]; }, UPDATE_CUSTOM_FORM(state, payload) { const index = state.customForms.findIndex((el) => el.dataKey === payload.dataKey); diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 2a355eae..c63a7e2f 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -198,7 +198,7 @@ export default { }, addCustomForm() { this.dataKey += 1; // * increment counter for key in v-for - this.$store.commit("feature_type/ADD_CUSTOM_FORM", this.dataKey); // * create an object with the counter in store + this.$store.commit("feature_type/ADD_CUSTOM_FORM", {dataKey: this.dataKey}); // * create an object with the counter in store }, iniateColorsStyleFields() { const selected = this.colorsStyleList.find( diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index d5740585..f65d3376 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -543,7 +543,7 @@ export default { for (const [key, value] of Object.entries(this.jsonDict['features'])) { console.log('key', key) this.form.title.value = value['properties']['feature_type'] - this.form.geom_type.value= this.toFormatGeom(value['geometry']['type']) + this.form.geom_type.value = this.toFormatGeom(value['geometry']['type']) // TODO : FILL A ARRAY CUSTOMFORM -> VOIR AVEC TIM let customForm = { @@ -553,15 +553,9 @@ export default { } // FOR for (const [k, val] of Object.entries(value['properties'])) { - - // console.log('k', k) - // console.log('val', val) - // console.log('customForm label', customForm['label']) if (k=='title'){ - console.log('title', val) customForm['label']['value'] = val customForm['name']['value'] = val - console.log(customForm) } if (! this.isLabelProperties(k)){ customForm['field_type']['value'] = val @@ -569,17 +563,15 @@ export default { } //ENDFOR } - console.log(customForm) - this.customForms.push(customForm) - console.log(this.customForms) + this.addCustomForm(customForm); } // GO TO NEW FORM this.toNewFeatureType() - - - } }, + addCustomForm(customForm) { + this.$store.commit("feature_type/ADD_CUSTOM_FORM", customForm); // * create an object with the counter in store + }, onFileChange(e) { var files = e.target.files || e.dataTransfer.files; if (!files.length) -- GitLab