diff --git a/src/store/modules/feature_type.js b/src/store/modules/feature_type.js index a8c4e34daf38ca640c166b3aa961742128df4dbf..7d2f2a675ebe020e1e78d7f8f6eaab3e322b6ca1 100644 --- a/src/store/modules/feature_type.js +++ b/src/store/modules/feature_type.js @@ -20,6 +20,8 @@ const feature_type = { state.feature_types = feature_types; }, SET_CURRENT_FEATURE_TYPE_SLUG(state, payload) { + //* reset import status of features for a specific feature_type when changing + state.importFeatureTypeData = null; state.current_feature_type_slug = payload; }, UPDATE_FORM(state, payload) { diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index 594d19bc149ae4c96e3a4a4f1381e558dc0f6495..be60179fbee5113baba003379096f89c9a7b0daa 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -57,13 +57,13 @@ <!-- <div v-if="permissions.can_create_feature" class="ui styled accordion"> --> <div class="ui styled accordion"> <div - @click="showImport = !showImport" - :class="['title', { active: !showImport }]" + @click="toggleShowImport" + :class="['title', { active: showImport }]" > <i class="dropdown icon"></i> Importer des signalements </div> - <div :class="['content', { active: !showImport }]"> + <div :class="['content', { active: showImport }]"> <div id="form-import-features" class="ui form"> <div class="field"> <label class="ui icon button" for="json_file"> @@ -93,13 +93,13 @@ </div> </div> <div - @click="showImport = !showImport" - :class="['title', { active: showImport }]" + @click="toggleShowImport" + :class="['title', { active: !showImport }]" > <i class="dropdown icon"></i> Exporter les signalements </div> - <div :class="['content', { active: showImport }]"> + <div :class="['content', { active: !showImport }]"> <p> Vous pouvez télécharger l'ensemble des signalements ayant le statut publiés pour ce type. @@ -227,15 +227,20 @@ export default { }, }, - watch: { + /* watch: { structure(newVal, oldVal) { if (newVal !== oldVal) { - this.$store.dispatch("feature_type/GET_IMPORTS", this.structure.slug); - } + } }, - }, + }, */ methods: { + toggleShowImport() { + this.showImport = !this.showImport; + if (this.showImport) { + this.$store.dispatch("feature_type/GET_IMPORTS", this.structure.slug); + } + }, onFileChange(e) { const files = e.target.files || e.dataTransfer.files; if (!files.length) return; diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index ce8b04bbd4e9e695e71e1e1aefb1e7921b105372..1c6744c0400f8d46b45ea60080f24076f3d223f3 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -443,7 +443,7 @@ export default { return "char"; //* string by default, most accepted type in database }, - importGeoJson() { + importGeoJsonFeatureType() { if (this.geojson.features && this.geojson.features.length) { //* in order to get feature_type properties, the first feature is enough const { properties, geometry } = this.geojson.features[0]; @@ -499,7 +499,7 @@ export default { } //* when creation from a geojson if (this.geojson) { - this.importGeoJson(); + this.importGeoJsonFeatureType(); if (this.$store.state.feature_type.fileToImport.name) { this.form.title.value = // * use the filename as title by default this.$store.state.feature_type.fileToImport.name.split(".")[0];