From 6dac646f97480af813ea1afaa00f48c81f7ae978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 17 May 2020 13:36:20 +0200 Subject: [PATCH] finished ##256 --- src/components/user/AddAmount.vue | 2 +- src/components/vorstand/UserManager.vue | 33 +++++++++++++++++++++++-- src/plugins/routes.js | 3 ++- src/store/modules/userManager.js | 29 +++++++++++++++++++++- 4 files changed, 62 insertions(+), 5 deletions(-) diff --git a/src/components/user/AddAmount.vue b/src/components/user/AddAmount.vue index 84fc5ad..00b90d0 100644 --- a/src/components/user/AddAmount.vue +++ b/src/components/user/AddAmount.vue @@ -217,7 +217,7 @@ export default { } }, addAmountMore() { - this.addAmount(this.value * 100) + this.addAmount(Math.abs(this.value * 100)) setTimeout(() => { this.value = null }, 300) diff --git a/src/components/vorstand/UserManager.vue b/src/components/vorstand/UserManager.vue index aabfe07..976c371 100644 --- a/src/components/vorstand/UserManager.vue +++ b/src/components/vorstand/UserManager.vue @@ -42,6 +42,20 @@ /> + + + + + @@ -68,6 +82,13 @@ + @@ -132,6 +153,7 @@ export default { header: [ { text: 'Nachname', value: 'lastname' }, { text: 'Vorname(n)', value: 'firstname' }, + { text: 'AG\'s', value: 'workgroups'}, { text: 'Status', value: 'statusgroup' }, { text: 'Stimmrecht', value: 'voting' }, { @@ -146,6 +168,7 @@ export default { firstname: null, lastname: null, username: null, + workgroups: [], statusgroup: { id: -1, name: null @@ -158,6 +181,7 @@ export default { defaultItem: { id: -1, username: null, + workgroups: [], statusgroup: { id: -1, name: null @@ -183,7 +207,9 @@ export default { getUsers: 'usermanager/getUsers', getStatus: 'usermanager/getStatus', updateStatusUser: 'usermanager/updateStatusUser', - updateVoting: 'usermanager/updateVoting' + updateVoting: 'usermanager/updateVoting', + updateWorkgroups: 'usermanager/updateWorkgroups', + getAllWorkgroups: 'wm/getAllWorkgroups' }), getWindowWidth() { this.isFulllineText = document.documentElement.clientWidth <= 750; @@ -231,6 +257,7 @@ export default { save() { this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup}) this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value}) + this.updateWorkgroups(this.editedItem) this.close() } }, @@ -239,7 +266,8 @@ export default { users: 'usermanager/users', status: 'usermanager/status', usersLoading: 'usermanager/usersLoading', - statusLoading: 'usermanager/statusLoading' + statusLoading: 'usermanager/statusLoading', + workgroups: 'wm/workgroups' }), computeStatus() { return id => { @@ -263,6 +291,7 @@ export default { created() { this.getUsers() this.getStatus() + this.getAllWorkgroups() } } diff --git a/src/plugins/routes.js b/src/plugins/routes.js index 4c3994e..118a35e 100644 --- a/src/plugins/routes.js +++ b/src/plugins/routes.js @@ -40,7 +40,8 @@ const url = { updateStatus: main + 'um/updateStatus', deleteStatus: main + 'um/deleteStatus', updateStatusUser: main + 'um/updateStatusUser', - updateVoting: main + 'um/updateVoting' + updateVoting: main + 'um/updateVoting', + updateWorkgroups: main + 'um/updateWorkgroups' }, wm: { workgroup: main + 'wgm/workgroup', diff --git a/src/store/modules/userManager.js b/src/store/modules/userManager.js index d60a75f..c63ec42 100644 --- a/src/store/modules/userManager.js +++ b/src/store/modules/userManager.js @@ -25,6 +25,7 @@ const mutations = { exists.mail = user.mail exists.statusgroup = user.statusgroup exists.voting = user.voting + exists.workgroups = user.workgroup } else { state.users.push({ username: user.username, @@ -32,7 +33,8 @@ const mutations = { lastname: user.lastname, mail: user.mail, statusgroup: user.statusgroup, - voting: user.voting + voting: user.voting, + workgroups: user.workgroups }) } }, @@ -59,6 +61,14 @@ const mutations = { }, setStatusLoading: (state, value) => { state.statusLoading = value + }, + updateWorkgroups: (state, { id, workgroups }) => { + let exists = state.users.find(a => { + return a.id === id + }) + if (exists) { + exists.workgroups = workgroups + } } } @@ -126,6 +136,23 @@ const actions = { if (e.response) if (e.response.status === 401) dispatch('logout', null, { root: true }) } + }, + async updateWorkgroups({ commit, rootState, dispatch }, data) { + try { + commit('setUsersLoading', true) + const response = await axios.post( + url.vorstand.um.updateWorkgroups, + { ...data }, + { headers: { Token: rootState.login.user.accessToken } } + ) + commit('updateWorkgroups', { id: data.id, workgroups: response.data }) + commit('setUsersLoading', false) + dispatch('getLifeTime', null, { root: true }) + } catch (e) { + commit('setUsersLoading', false) + if (e.response) + if (e.response.status === 401) dispatch('logout', null, { root: true }) + } } }