Mercurial > gemma
changeset 2329:514193fd0120
refac: improve routing structure. We now have /bottlenecks, /stretches, /review routes
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 19 Feb 2019 14:57:48 +0100 |
parents | c98491f9c466 |
children | 7b79d4966a87 42849084f063 |
files | client/src/components/Contextbox.vue client/src/components/Sidebar.vue client/src/router.js |
diffstat | 3 files changed, 69 insertions(+), 51 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Contextbox.vue Tue Feb 19 13:55:02 2019 +0100 +++ b/client/src/components/Contextbox.vue Tue Feb 19 14:57:48 2019 +0100 @@ -58,6 +58,7 @@ "application/showSearchbar", this.showSearchbarLastState ); + this.$router.push("/"); } } };
--- a/client/src/components/Sidebar.vue Tue Feb 19 13:55:02 2019 +0100 +++ b/client/src/components/Sidebar.vue Tue Feb 19 14:57:48 2019 +0100 @@ -15,45 +15,33 @@ ></font-awesome-icon> <span class="fix-trans-space" v-translate>Map</span> </router-link> - <a - :class="['secondary', { active: isActive('bottlenecks') }]" - @click="toggleContextBox('bottlenecks')" - href="#" - > + <router-link to="/bottlenecks"> <font-awesome-icon - class="fa-fw mr-2" + class="fa-fw mr-2" fixed-width icon="ship" ></font-awesome-icon> <span class="fix-trans-space" v-translate>Bottlenecks</span> - </a> + </router-link> <div v-if="isWaterwayAdmin"> - <a - :class="['secondary', { active: isActive('staging') }]" - @click="toggleContextBox('staging')" - href="#" - > + <router-link to="/review"> <font-awesome-icon class="fa-fw mr-2" fixed-width icon="clipboard-check" ></font-awesome-icon> <span class="fix-trans-space" v-translate>Staging area</span> - </a> + </router-link> </div> <div v-if="isSysAdmin"> - <a - :class="['secondary', { active: isActive('stretches') }]" - @click="toggleContextBox('stretches')" - href="#" - > + <router-link to="/stretches"> <font-awesome-icon class="fa-fw mr-2" fixed-width icon="road" ></font-awesome-icon> <span class="fix-trans-space" v-translate>Define stretches</span> - </a> + </router-link> </div> <div v-if="isWaterwayAdmin"> <small class="text-muted pl-3"> <translate>Import</translate> </small> @@ -175,20 +163,6 @@ export default { name: "sidebar", props: ["routeName"], - watch: { - $route() { - const { review, importlog } = this.$route.query; - if (review) { - this.toggleContextBox("staging"); - this.$store.commit("imports/setImportToReview", review); - } else { - this.$store.commit("imports/setImportToReview", -99); - } - if (importlog) { - this.$router.push("/importqueue/" + importlog); - } - } - }, computed: { ...mapGetters("user", ["isSysAdmin", "isWaterwayAdmin"]), ...mapState("user", ["user"]),
--- a/client/src/router.js Tue Feb 19 13:55:02 2019 +0100 +++ b/client/src/router.js Tue Feb 19 14:57:48 2019 +0100 @@ -20,6 +20,7 @@ /* facilitate codesplitting */ const Login = () => import("./components/Login.vue"); +const Main = () => import("./components/Main.vue"); Vue.use(Router); @@ -80,23 +81,7 @@ } }, { - path: "/importqueue", - name: "importqueues", - component: () => import("./components/importqueue/Importqueue.vue"), - meta: { - requiresAuth: true - }, - beforeEnter: (to, from, next) => { - const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; - if (!isWaterwayAdmin) { - next("/"); - } else { - next(); - } - } - }, - { - path: "/importqueue/:id", + path: "/importqueue/:id?", name: "importqueue", component: () => import("./components/importqueue/Importqueue.vue"), meta: { @@ -178,9 +163,67 @@ { path: "/", name: "mainview", - component: () => import("./components/Main.vue"), + component: Main, + meta: { + requiresAuth: true + }, + beforeEnter: (to, from, next) => { + store.commit("application/showContextBox", false); + store.commit("application/contextBoxContent", ""); + store.commit("application/showSearchbar", false); + next(); + } + }, + { + path: "/bottlenecks", + name: "mainview", + component: Main, + meta: { + requiresAuth: true + }, + beforeEnter: (to, from, next) => { + store.commit("application/showContextBox", true); + store.commit("application/contextBoxContent", "bottlenecks"); + store.commit("application/showSearchbar", true); + next(); + } + }, + { + path: "/review/:id?", + name: "mainview", + component: Main, meta: { requiresAuth: true + }, + beforeEnter: (to, from, next) => { + const isWaterwayAdmin = store.getters["user/isWaterwayAdmin"]; + if (!isWaterwayAdmin) { + next("/"); + } else { + store.commit("application/showContextBox", true); + store.commit("application/contextBoxContent", "staging"); + store.commit("application/showSearchbar", true); + next(); + } + } + }, + { + path: "/stretches", + name: "mainview", + component: Main, + meta: { + requiresAuth: true + }, + beforeEnter: (to, from, next) => { + const isSysadmin = store.getters["user/isSysAdmin"]; + if (!isSysadmin) { + next("/"); + } else { + store.commit("application/showContextBox", true); + store.commit("application/contextBoxContent", "stretches"); + store.commit("application/showSearchbar", true); + next(); + } } }, {