diff --git a/src/views/Catalog.vue b/src/views/Catalog.vue index 82cf434e58b471d7e10e49aa47f73a81722109a3..42cc0a530ee6ff84d545427e5db351001cb490eb 100644 --- a/src/views/Catalog.vue +++ b/src/views/Catalog.vue @@ -334,6 +334,7 @@ export default { computed: { ...mapGetters(["project", "permissions"]), + ...mapGetters("feature_type", ["feature_type"]), paginatedRessources() { return this.ressources.slice(this.pagination.start, this.pagination.end); @@ -383,16 +384,16 @@ export default { } }, - toNewFeatureType() { - //this.featureTypeImporting = true; + redirect() { + const routerHistory = this.$router.history.router.options.routerHistory + const name = routerHistory[routerHistory.length - 1].name === "details-type-signalement" ? "details-type-signalement" : "ajouter-type-signalement" this.$router.push({ - name: "ajouter-type-signalement", + name, params: { geojson: this.geojson, type: "external-geojson", }, }); - //this.featureTypeImporting = false; }, launchImport() { @@ -400,13 +401,14 @@ export default { const paramsTest = `user=${user}&TYPENAME=${this.selectedResource.layerName}`; miscAPI.getExternalGeojson(paramsTest).then((data) => { this.geojson = data; - console.log(this.geojson); - this.toNewFeatureType(); + this.redirect(); }); }, }, created() { + console.log(this.$router) + console.log(this.$router.history.router.options.routerHistory[this.$router.history.router.options.routerHistory.length -1].name) this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug); }, }; @@ -428,6 +430,7 @@ h1 { } .table > .row { display: flex; + transition: background-color ease-out 0.2s; } .table > .row:not(:first-of-type).selected { background-color: #8bddd9; diff --git a/src/views/feature_type/Feature_type_detail.vue b/src/views/feature_type/Feature_type_detail.vue index 456cbcda719dfef109006fd3542d9f23a2c5453c..8e66330348e1387900ebd04a211b92a6d2d395bf 100644 --- a/src/views/feature_type/Feature_type_detail.vue +++ b/src/views/feature_type/Feature_type_detail.vue @@ -85,13 +85,29 @@ id="json_file" /> </div> + + <router-link + v-if=" + permissions && + permissions.can_create_feature + " + :to="{ + name: 'catalog-import', + params: { slug: project.slug }, + }" + class="ui icon button import-catalog" + >Créer un nouveau type de signalement à partir du catalogue Datasud + </router-link> + <div v-if="$route.params.geojson" class="ui button import-catalog"> + Ressource {{$route.params.geojson.name}} + </div> <ul v-if="importError" class="errorlist"> <li> {{ importError }} </li> </ul> <button - :disabled="fileToImport.size === 0" + :disabled="fileToImport.size === 0 && !$route.params.geojson" @click="importGeoJson" class="ui fluid teal icon button" > @@ -234,6 +250,8 @@ export default { ImportTask: ImportTask, }, + props: ["geojson", "typename", ], + data() { return { importError: "", @@ -322,6 +340,11 @@ export default { this.SET_CURRENT_FEATURE_TYPE_SLUG( this.$route.params.feature_type_slug ); + console.log(this.$route.params) + console.log(this.$route.params.type) + if (this.$route.params.type === "external-geojson") { + this.showImport = true; + } }, methods: { @@ -431,11 +454,16 @@ export default { }, importGeoJson() { - this.$store.dispatch('feature_type/SEND_FEATURES_FROM_GEOJSON', { - slug: this.$route.params.slug, - feature_type_slug: this.$route.params.feature_type_slug, - fileToImport: this.fileToImport, - }); + let payload = { + slug: this.$route.params.slug, + feature_type_slug: this.$route.params.feature_type_slug, + } + if (this.$route.params.geojson) { + payload["geojson"] = this.$route.params.geojson + } else { + payload["fileToImport"] = this.fileToImport; + } + this.$store.dispatch('feature_type/SEND_FEATURES_FROM_GEOJSON', payload); }, exportFeatures() { @@ -459,8 +487,6 @@ export default { limit: '5' }); - console.log("response", response) - if (response){ this.featuresLoading = false; } @@ -473,4 +499,8 @@ export default { .margin-25 { margin: 0 0.25em 0.25em 0 !important; } + +.import-catalog { + margin-bottom: 1em; +} </style> \ No newline at end of file