diff --git a/src/router/index.js b/src/router/index.js index 40a6e9461b7c2e6dffde702373c6f97aa9baccc0..c94cd2581ff1f13580cf686f5828c6e37b2f2829 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -69,13 +69,20 @@ const routes = [ component: () => import('../views/project/Project_members.vue') }, // * FEATURE TYPE - { + { path: '/projet/:slug/type-signalement/ajouter/', name: 'ajouter-type-signalement', props: true, hasProject: true, component: () => import('../views/feature_type/Feature_type_edit.vue') }, + { + path: '/projet/:slug/type-signalement/ajouter/?create_from=:slug_type_signal', + name: 'dupliquer-type-signalement', + props: true, + hasProject: true, + component: () => import('../views/feature_type/Feature_type_edit.vue') + }, { path: '/projet/:slug/type-signalement/:feature_type_slug/', name: 'details-type-signalement', @@ -83,7 +90,7 @@ const routes = [ hasProject: true, component: () => import('../views/feature_type/Feature_type_detail.vue') }, - { // todo : adapter le template + { path: '/projet/:slug/type-signalement/:slug_type_signal/editer/', name: 'editer-type-signalement', props: true, @@ -119,7 +126,7 @@ const routes = [ hasProject: true, component: () => import('../views/feature/Feature_edit.vue') }, - + { path: '/:pathMatch(.*)*', name: 'NotFound', component: () => import('../views/NotFound.vue') }, ] //let routerHistory = []; diff --git a/src/store/index.js b/src/store/index.js index 3c4b485652a22ed08c944b58be776dced40dee8e..da6ffd7fb68cef697995b7f34038d7abdf3f705c 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -110,7 +110,9 @@ export default new Vuex.Store({ password: payload.password, }) .then((response) => { - const routerHistory = router.options.routerHistory // * use store previous route to go back after login + console.log(router.options.routerHistory) + // * use stored previous route to go back after login if page not open on login at first + const routerHistory = router.options.routerHistory[0].name !== "login" ? router.options.routerHistory : "/" commit("SET_USER", response.data.user); router.push(routerHistory[routerHistory.length - 1] || "/") dispatch("GET_USER_LEVEL_PROJECTS"); diff --git a/src/views/feature_type/Feature_type_edit.vue b/src/views/feature_type/Feature_type_edit.vue index 3602fa40932b1472bc25bca022a4ef4e311162eb..58f9c100b878c093529975d2a7b9dd5619a6af07 100644 --- a/src/views/feature_type/Feature_type_edit.vue +++ b/src/views/feature_type/Feature_type_edit.vue @@ -185,10 +185,7 @@ export default { data() { return { - action: - this.$router.history.current.name === "ajouter-type-signalement" - ? "create" - : "edit", + action: "create", dataKey: 0, form: { colors_style: { @@ -277,6 +274,17 @@ export default { "feature_type/SET_CURRENT_FEATURE_TYPE_SLUG", this.slug_type_signal ); + if (this.$router.history.current.name === "ajouter-type-signalement") { + this.action = "create"; + } else if ( + this.$router.history.current.name === "editer-type-signalement" + ) { + this.action = "edit"; + } else if ( + this.$router.history.current.name === "dupliquer-type-signalement" + ) { + this.action = "duplicate"; + } }, mounted() { if (this.action === "edit") { diff --git a/src/views/project/Project_detail.vue b/src/views/project/Project_detail.vue index c9cb3d140c1731054a622003993d3b9f8bb0f414..b86ab611562976430fceafb4c6bb1606278f750d 100644 --- a/src/views/project/Project_detail.vue +++ b/src/views/project/Project_detail.vue @@ -127,7 +127,11 @@ ><!-- // todo : adapt --> <i class="ui plus icon"></i> </router-link> - <a + <router-link + :to="{ + name: 'dupliquer-type-signalement', + params: { slug_type_signal: type.title }, + }" v-if="project && permissions.can_create_feature" class=" ui @@ -141,10 +145,9 @@ data-tooltip="Dupliquer un type de signalement" data-position="left center" data-variation="mini" - href="{% url 'geocontrib:feature_type_create' slug=project.slug %}?create_from=type.slug" ><!-- // todo : adapt --> <i class="inverted grey copy alternate icon"></i> - </a> + </router-link> <router-link :to="{ name: 'editer-type-signalement', @@ -163,7 +166,6 @@ data-tooltip="Éditer le type de signalement" data-position="left center" data-variation="mini" - href="{% url 'geocontrib:feature_type_update' slug=project.slug feature_type_slug=type.slug %}" > <i class="inverted grey pencil alternate icon"></i> </router-link>