diff client/src/router.js @ 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 c69432c1c4ac
line wrap: on
line diff
--- 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();
+        }
       }
     },
     {