changeset 10:361ae8211991 vue-cli

refactored to component local state
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 18 Jun 2018 12:11:35 +0200
parents ee6d3836014e
children e0b5dd98665e
files src/stores/application.js src/views/Login.vue
diffstat 2 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/stores/application.js	Fri Jun 15 13:04:07 2018 +0200
+++ b/src/stores/application.js	Mon Jun 18 12:11:35 2018 +0200
@@ -2,8 +2,7 @@
   namespaced: true,
   state: {
     appTitle: process.env.VUE_APP_TITLE,
-    secondaryLogo: process.env.VUE_APP_SECONDARY_LOGO_URL,
-    loginFailed: false
+    secondaryLogo: process.env.VUE_APP_SECONDARY_LOGO_URL
   },
   getters: {
     appTitle: state => {
@@ -11,19 +10,9 @@
     },
     secondaryLogo: state => {
       return state.secondaryLogo;
-    },
-    loginFailed: state => {
-      return state.loginFailed;
     }
   },
-  mutations: {
-    loginError(state) {
-      state.loginFailed = true;
-    },
-    loginSuccess(state) {
-      state.loginFailed = false;
-    }
-  },
+  mutations: {},
   actions: {}
 };
 
--- a/src/views/Login.vue	Fri Jun 15 13:04:07 2018 +0200
+++ b/src/views/Login.vue	Mon Jun 18 12:11:35 2018 +0200
@@ -57,11 +57,12 @@
     return {
       username: "",
       password: "",
-      submitted: false
+      submitted: false,
+      loginFailed: false
     };
   },
   computed: {
-    ...mapGetters("application", ["appTitle", "loginFailed", "secondaryLogo"]),
+    ...mapGetters("application", ["appTitle", "secondaryLogo"]),
     ...mapGetters("i18n", [
       "signinHeader",
       "emailLabel",
@@ -78,11 +79,11 @@
       this.$store
         .dispatch("user/login", { username, password })
         .then(() => {
-          this.$store.commit("application/loginSuccess");
+          this.loginFailed = false;
           this.$router.push("/");
         })
         .catch(() => {
-          this.$store.commit("application/loginError");
+          this.loginFailed = true;
           this.submitted = false;
         });
     }