From 998d026d3ffbd54b275dd8400c05aeac8b4d15ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Poussard?= <tpoussard@neogeo.fr> Date: Wed, 1 Sep 2021 16:43:36 +0200 Subject: [PATCH] Add function on button export features and some improvements --- src/store/modules/feature.js | 3 ++ src/store/modules/feature_type.js | 2 +- src/views/feature/Feature_list.vue | 9 ++++-- .../feature_type/Feature_type_detail.vue | 30 ++++++++++++------- src/views/project/Project_mapping.vue | 6 ++++ 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/store/modules/feature.js b/src/store/modules/feature.js index 50c56a5c..dddb6444 100644 --- a/src/store/modules/feature.js +++ b/src/store/modules/feature.js @@ -133,6 +133,9 @@ const feature = { commit("SET_USER", false) }); */ }, + EXPORT_FEATURES({state}) { + console.log("Export features", state.features) + } }, } diff --git a/src/store/modules/feature_type.js b/src/store/modules/feature_type.js index df91b49e..03b43c26 100644 --- a/src/store/modules/feature_type.js +++ b/src/store/modules/feature_type.js @@ -99,7 +99,7 @@ const feature_type = { console.log("data", data) axios - .post(`${process.env.VUE_APP_DJANGO_API_BASE}feature_type/`, data) + .post(`${process.env.VUE_APP_DJANGO_API_BASE}feature-types/`, data) .then((response) => { const routerHistory = this.$router.options.routerHistory store.commit("SET_USER", response.data.user); diff --git a/src/views/feature/Feature_list.vue b/src/views/feature/Feature_list.vue index ed161fdb..8fe46db3 100644 --- a/src/views/feature/Feature_list.vue +++ b/src/views/feature/Feature_list.vue @@ -191,7 +191,11 @@ {{ feature.display_creator }} </td> </tr> - <tr v-if="filteredFeatures.length === 0" class="odd"><td colspan="5" class="dataTables_empty" valign="top">Aucune donnée disponible</td></tr> + <tr v-if="filteredFeatures.length === 0" class="odd"> + <td colspan="5" class="dataTables_empty" valign="top"> + Aucune donnée disponible + </td> + </tr> </tbody> </table> </div> @@ -277,7 +281,8 @@ export default { created() { if (!this.project) { - this.$store.dispatch("GET_PROJECT_MESSAGES", this.$route.params.slug); + //this.$store.dispatch("GET_PROJECT_MESSAGES", this.$route.params.slug); + this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); } }, mounted() { diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index 86f7328e..7204cc59 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -101,12 +101,9 @@ Vous pouvez télécharger l'ensemble des signalements ayant le statut publiés pour ce type. </p> - <a - class="ui fluid teal icon button" - href="{% url 'api:project-export' slug=project.slug feature_type_slug=feature_type.slug %}" - > + <button type="button" class="ui fluid teal icon button" @click="exportFeatures"> <i class="download icon"></i> Exporter - </a> + </button> // todo gérer export </div> </div> @@ -134,11 +131,18 @@ <span v-else-if="feature.status == 'draft'" data-tooltip="Brouillon"> <i class="orange pencil alternate icon"></i> </span> - <a - href="{% url 'geocontrib:feature_detail' slug=project.slug feature_type_slug=feature.feature_type.slug feature_id=feature.feature_id %}" + <router-link + :to="{ + name: 'details-signalement', + params: { + slug: project.slug, + slug_type_signal: feature.feature_type.slug, + slug_signal: feature.feature_id, + }, + }" > {{ feature.title }} - </a> + </router-link> <div class="sub header"> <div> {{ feature.description.substring(0, 200) }} @@ -218,9 +222,6 @@ export default { }, methods: { - // forceRerender(key) { - // return key += 1; - // }, onFileChange(e) { var files = e.target.files || e.dataTransfer.files; if (!files.length) return; @@ -272,6 +273,13 @@ export default { console.log(err); }); }, + exportFeatures() { + console.log("TEST", this.$store) + this.$store.dispatch( + "feature/EXPORT_FEATURES", + this.$route.params.slug_type_signal + ); + }, }, created() { diff --git a/src/views/project/Project_mapping.vue b/src/views/project/Project_mapping.vue index 0820aca6..6331c2f9 100644 --- a/src/views/project/Project_mapping.vue +++ b/src/views/project/Project_mapping.vue @@ -65,5 +65,11 @@ export default { this.$store.dispatch("map/SAVE_BASEMAPS"); }, }, + + created() { + if (!this.$store.getters.project) { + this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); + } + }, }; </script> \ No newline at end of file -- GitLab