Skip to content
Snippets Groups Projects
Commit 37041c06 authored by Timothee P's avatar Timothee P :sunflower:
Browse files

wip:changing routes params

parent 6b1cb363
No related branches found
No related tags found
4 merge requests!295Version 3.0.0,!247REDMINE_ISSUE-12787,!245REDMINE_ISSUE-12786,!233REDMINE_ISSUE-12378
...@@ -334,6 +334,7 @@ export default { ...@@ -334,6 +334,7 @@ export default {
computed: { computed: {
...mapGetters(["project", "permissions"]), ...mapGetters(["project", "permissions"]),
...mapGetters("feature_type", ["feature_type"]),
paginatedRessources() { paginatedRessources() {
return this.ressources.slice(this.pagination.start, this.pagination.end); return this.ressources.slice(this.pagination.start, this.pagination.end);
...@@ -383,16 +384,16 @@ export default { ...@@ -383,16 +384,16 @@ export default {
} }
}, },
toNewFeatureType() { redirect() {
//this.featureTypeImporting = true; 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({ this.$router.push({
name: "ajouter-type-signalement", name,
params: { params: {
geojson: this.geojson, geojson: this.geojson,
type: "external-geojson", type: "external-geojson",
}, },
}); });
//this.featureTypeImporting = false;
}, },
launchImport() { launchImport() {
...@@ -400,13 +401,14 @@ export default { ...@@ -400,13 +401,14 @@ export default {
const paramsTest = `user=${user}&TYPENAME=${this.selectedResource.layerName}`; const paramsTest = `user=${user}&TYPENAME=${this.selectedResource.layerName}`;
miscAPI.getExternalGeojson(paramsTest).then((data) => { miscAPI.getExternalGeojson(paramsTest).then((data) => {
this.geojson = data; this.geojson = data;
console.log(this.geojson); this.redirect();
this.toNewFeatureType();
}); });
}, },
}, },
created() { 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); this.$store.dispatch("GET_PROJECT_INFO", this.$route.params.slug);
}, },
}; };
...@@ -428,6 +430,7 @@ h1 { ...@@ -428,6 +430,7 @@ h1 {
} }
.table > .row { .table > .row {
display: flex; display: flex;
transition: background-color ease-out 0.2s;
} }
.table > .row:not(:first-of-type).selected { .table > .row:not(:first-of-type).selected {
background-color: #8bddd9; background-color: #8bddd9;
......
...@@ -85,13 +85,29 @@ ...@@ -85,13 +85,29 @@
id="json_file" id="json_file"
/> />
</div> </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"> <ul v-if="importError" class="errorlist">
<li> <li>
{{ importError }} {{ importError }}
</li> </li>
</ul> </ul>
<button <button
:disabled="fileToImport.size === 0" :disabled="fileToImport.size === 0 && !$route.params.geojson"
@click="importGeoJson" @click="importGeoJson"
class="ui fluid teal icon button" class="ui fluid teal icon button"
> >
...@@ -234,6 +250,8 @@ export default { ...@@ -234,6 +250,8 @@ export default {
ImportTask: ImportTask, ImportTask: ImportTask,
}, },
props: ["geojson", "typename", ],
data() { data() {
return { return {
importError: "", importError: "",
...@@ -322,6 +340,11 @@ export default { ...@@ -322,6 +340,11 @@ export default {
this.SET_CURRENT_FEATURE_TYPE_SLUG( this.SET_CURRENT_FEATURE_TYPE_SLUG(
this.$route.params.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: { methods: {
...@@ -431,11 +454,16 @@ export default { ...@@ -431,11 +454,16 @@ export default {
}, },
importGeoJson() { importGeoJson() {
this.$store.dispatch('feature_type/SEND_FEATURES_FROM_GEOJSON', { let payload = {
slug: this.$route.params.slug, slug: this.$route.params.slug,
feature_type_slug: this.$route.params.feature_type_slug, feature_type_slug: this.$route.params.feature_type_slug,
fileToImport: this.fileToImport, }
}); 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() { exportFeatures() {
...@@ -459,8 +487,6 @@ export default { ...@@ -459,8 +487,6 @@ export default {
limit: '5' limit: '5'
}); });
console.log("response", response)
if (response){ if (response){
this.featuresLoading = false; this.featuresLoading = false;
} }
...@@ -473,4 +499,8 @@ export default { ...@@ -473,4 +499,8 @@ export default {
.margin-25 { .margin-25 {
margin: 0 0.25em 0.25em 0 !important; margin: 0 0.25em 0.25em 0 !important;
} }
.import-catalog {
margin-bottom: 1em;
}
</style> </style>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment