comparison client/src/views/Users.vue @ 406:40e7ab3df32c

feat: Basic CRUD for usermanagement etd Basic features for adding, changing, deleting users established
author Thomas Junk <thomas.junk@intevation.de>
date Wed, 15 Aug 2018 15:14:23 +0200
parents cb233a5a2ecd
children a9440a4826aa
comparison
equal deleted inserted replaced
403:46a80016293c 406:40e7ab3df32c
118 }; 118 };
119 } 119 }
120 }, 120 },
121 methods: { 121 methods: {
122 deleteUser(name) { 122 deleteUser(name) {
123 console.log("delete: " + name); 123 this.$store
124 .dispatch("usermanagement/deleteUser", { name: name })
125 .then(() => {
126 this.submitted = false;
127 this.$store.dispatch("usermanagement/loadUsers").catch(error => {
128 const { status, data } = error.response;
129 app.$toast.error({
130 title: "Backend Error",
131 message: `${status}: ${data.message}`
132 });
133 });
134 })
135 .catch(error => {
136 const { status, data } = error.response;
137 app.$toast.error({
138 title: "Backend Error",
139 message: `${status}: ${data.message}`
140 });
141 });
124 }, 142 },
125 addUser() { 143 addUser() {
126 this.$store.commit("usermanagement/clearCurrentUser"); 144 this.$store.commit("usermanagement/clearCurrentUser");
127 this.$store.commit("usermanagement/setUserDetailsVisible"); 145 this.$store.commit("usermanagement/setUserDetailsVisible");
128 }, 146 },
137 .then(next) 155 .then(next)
138 .catch(error => { 156 .catch(error => {
139 const { status, data } = error.response; 157 const { status, data } = error.response;
140 app.$toast.error({ 158 app.$toast.error({
141 title: "Backend Error", 159 title: "Backend Error",
142 message: `${status}: ${data}` 160 message: `${status}: ${data.message}`
143 }); 161 });
144 }); 162 });
145 }, 163 },
146 beforeRouteLeave(to, from, next) { 164 beforeRouteLeave(to, from, next) {
147 store.commit("usermanagement/clearCurrentUser"); 165 store.commit("usermanagement/clearCurrentUser");