changeset 3693:10cbf467fd63

client: configuration: load settings beforeEach route but only if not present yet On entering the system configuration page the settings are updated.
author Markus Kottlaender <markus@intevation.de>
date Tue, 18 Jun 2019 18:03:23 +0200
parents 3138836bf840
children 6f5297dc6039
files client/src/router.js
diffstat 1 files changed, 15 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/client/src/router.js	Tue Jun 18 17:44:28 2019 +0200
+++ b/client/src/router.js	Tue Jun 18 18:03:23 2019 +0200
@@ -92,7 +92,7 @@
         store.commit("application/showContextBox", false);
         store.commit("application/contextBoxContent", "");
         store.commit("application/showSearchbar", false);
-        store.dispatch("application/loadConfig").then(() => next());
+        next();
       }
     },
     {
@@ -213,17 +213,23 @@
     store.commit("user/setExpires", expiresFromPastSession);
     store.commit("user/setRoles", localStorage.getItem("roles"));
     store.commit("user/setIsAuthenticate", true);
+    // load settings only if not present yet
+    if (Object.keys(store.state.application.config).length) {
+      next();
+    } else {
+      store.dispatch("application/loadConfig").then(() => next());
+    }
   } else {
     store.commit("reset");
     store.commit("user/clearAuth");
-  }
-  const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
-  const redirectToLogin = requiresAuth && !store.state.user.isAuthenticated;
-  if (redirectToLogin) {
-    localStorage.setItem("tempRoute", to.path);
-    next("/login");
-  } else {
-    next();
+    const requiresAuth = to.matched.some(record => record.meta.requiresAuth);
+    const redirectToLogin = requiresAuth && !store.state.user.isAuthenticated;
+    if (redirectToLogin) {
+      localStorage.setItem("tempRoute", to.path);
+      next("/login");
+    } else {
+      next();
+    }
   }
 });