From 96ce2b749b1fa6595ae72f98ba0e07b093aa07b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Thu, 28 Dec 2023 10:06:15 +0100 Subject: [PATCH] toggle JSON import button --- src/views/FeatureType/FeatureTypeDetail.vue | 26 ++++++++++++--------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/views/FeatureType/FeatureTypeDetail.vue b/src/views/FeatureType/FeatureTypeDetail.vue index 6d9e72bf..b140f7ca 100644 --- a/src/views/FeatureType/FeatureTypeDetail.vue +++ b/src/views/FeatureType/FeatureTypeDetail.vue @@ -219,7 +219,7 @@ style="margin-bottom: 1em;" > <option value="GeoJSON"> - GeoJSON + {{ feature_type.geom_type === 'none' ? 'JSON' : 'GeoJSON' }} </option> <option v-if="feature_type.geom_type === 'point' || feature_type.geom_type === 'none'" @@ -446,12 +446,6 @@ export default { }; }, - watch: { - feature_type(newValue) { - this.toggleJsonUploadOption(newValue); - } - }, - computed: { ...mapGetters([ 'permissions', @@ -497,6 +491,12 @@ export default { }, }, + watch: { + feature_type(newValue) { + this.toggleJsonUploadOption(newValue); + } + }, + created() { if (!this.project) { this.$store.dispatch('projects/GET_PROJECT', this.slug); @@ -515,7 +515,7 @@ export default { } // empty prerecorded lists in case the list has been previously loaded with a limit in other component like FeatureExtraForm this.SET_PRERECORDED_LISTS([]); - // This function is already called by watcher at this stage, but to be safe in edge case + // This function is also called by watcher at this stage, but to be safe in edge case this.toggleJsonUploadOption(this.feature_type); }, @@ -566,7 +566,10 @@ export default { */ toggleJsonUploadOption(featureType) { if (featureType && featureType.geom_type === 'none') { - this.geojsonFileToImport.name = 'Sélectionner un fichier JSON ...'; + this.geojsonFileToImport = { + name: 'Sélectionner un fichier JSON ...', + size: 0, + }; } }, @@ -906,15 +909,16 @@ export default { exportFeatures() { this.exportLoading = true; + let exportFormat = this.feature_type.geom_type === 'none' && this.exportFormat === 'GeoJSON' ? 'json' : this.exportFormat.toLowerCase(); const url = ` - ${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.slug}/feature-type/${this.featureTypeSlug}/export/?format_export=${this.exportFormat.toLowerCase()} + ${this.$store.state.configuration.VUE_APP_DJANGO_API_BASE}projects/${this.slug}/feature-type/${this.featureTypeSlug}/export/?format_export=${exportFormat} `; featureAPI.getFeaturesBlob(url) .then((blob) => { if (blob) { const link = document.createElement('a'); link.href = URL.createObjectURL(blob); - link.download = `${this.project.title}-${this.feature_type.title}.${this.exportFormat === 'GeoJSON' ? 'json' : 'csv'}`; + link.download = `${this.project.title}-${this.feature_type.title}.${exportFormat}`; link.click(); setTimeout(function(){ URL.revokeObjectURL(link.href); -- GitLab