finished ##256

This commit is contained in:
Tim Gröger 2020-05-17 13:36:20 +02:00
parent 671b9335c9
commit 6dac646f97
4 changed files with 62 additions and 5 deletions

View File

@ -217,7 +217,7 @@ export default {
} }
}, },
addAmountMore() { addAmountMore() {
this.addAmount(this.value * 100) this.addAmount(Math.abs(this.value * 100))
setTimeout(() => { setTimeout(() => {
this.value = null this.value = null
}, 300) }, 300)

View File

@ -42,6 +42,20 @@
/> />
</v-col> </v-col>
</v-row> </v-row>
<v-row>
<v-col>
<v-autocomplete
chips
multiple
v-model="editedItem.workgroups"
label="AG's"
outlined
:items="workgroups"
item-value="id"
item-text="name"
return-object></v-autocomplete>
</v-col>
</v-row>
</v-container> </v-container>
</v-card-text> </v-card-text>
<v-card-actions> <v-card-actions>
@ -68,6 +82,13 @@
</v-text-field> </v-text-field>
</v-toolbar> </v-toolbar>
</template> </template>
<template v-slot:item.workgroups="{item}">
<div>
<v-chip v-for="group in item.workgroups" :key="group.id" x-small>
{{group.name}}
</v-chip>
</div>
</template>
<template v-slot:item.statusgroup="{ item }"> <template v-slot:item.statusgroup="{ item }">
{{ computeStatus(item.statusgroup) }} {{ computeStatus(item.statusgroup) }}
</template> </template>
@ -132,6 +153,7 @@ export default {
header: [ header: [
{ text: 'Nachname', value: 'lastname' }, { text: 'Nachname', value: 'lastname' },
{ text: 'Vorname(n)', value: 'firstname' }, { text: 'Vorname(n)', value: 'firstname' },
{ text: 'AG\'s', value: 'workgroups'},
{ text: 'Status', value: 'statusgroup' }, { text: 'Status', value: 'statusgroup' },
{ text: 'Stimmrecht', value: 'voting' }, { text: 'Stimmrecht', value: 'voting' },
{ {
@ -146,6 +168,7 @@ export default {
firstname: null, firstname: null,
lastname: null, lastname: null,
username: null, username: null,
workgroups: [],
statusgroup: { statusgroup: {
id: -1, id: -1,
name: null name: null
@ -158,6 +181,7 @@ export default {
defaultItem: { defaultItem: {
id: -1, id: -1,
username: null, username: null,
workgroups: [],
statusgroup: { statusgroup: {
id: -1, id: -1,
name: null name: null
@ -183,7 +207,9 @@ export default {
getUsers: 'usermanager/getUsers', getUsers: 'usermanager/getUsers',
getStatus: 'usermanager/getStatus', getStatus: 'usermanager/getStatus',
updateStatusUser: 'usermanager/updateStatusUser', updateStatusUser: 'usermanager/updateStatusUser',
updateVoting: 'usermanager/updateVoting' updateVoting: 'usermanager/updateVoting',
updateWorkgroups: 'usermanager/updateWorkgroups',
getAllWorkgroups: 'wm/getAllWorkgroups'
}), }),
getWindowWidth() { getWindowWidth() {
this.isFulllineText = document.documentElement.clientWidth <= 750; this.isFulllineText = document.documentElement.clientWidth <= 750;
@ -231,6 +257,7 @@ export default {
save() { save() {
this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup}) this.updateStatusUser({username: this.editedItem.username, status: this.editedItem.statusgroup})
this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value}) this.updateVoting({username: this.editedItem.username, voting: this.editedItem.voting.value})
this.updateWorkgroups(this.editedItem)
this.close() this.close()
} }
}, },
@ -239,7 +266,8 @@ export default {
users: 'usermanager/users', users: 'usermanager/users',
status: 'usermanager/status', status: 'usermanager/status',
usersLoading: 'usermanager/usersLoading', usersLoading: 'usermanager/usersLoading',
statusLoading: 'usermanager/statusLoading' statusLoading: 'usermanager/statusLoading',
workgroups: 'wm/workgroups'
}), }),
computeStatus() { computeStatus() {
return id => { return id => {
@ -263,6 +291,7 @@ export default {
created() { created() {
this.getUsers() this.getUsers()
this.getStatus() this.getStatus()
this.getAllWorkgroups()
} }
} }
</script> </script>

View File

@ -40,7 +40,8 @@ const url = {
updateStatus: main + 'um/updateStatus', updateStatus: main + 'um/updateStatus',
deleteStatus: main + 'um/deleteStatus', deleteStatus: main + 'um/deleteStatus',
updateStatusUser: main + 'um/updateStatusUser', updateStatusUser: main + 'um/updateStatusUser',
updateVoting: main + 'um/updateVoting' updateVoting: main + 'um/updateVoting',
updateWorkgroups: main + 'um/updateWorkgroups'
}, },
wm: { wm: {
workgroup: main + 'wgm/workgroup', workgroup: main + 'wgm/workgroup',

View File

@ -25,6 +25,7 @@ const mutations = {
exists.mail = user.mail exists.mail = user.mail
exists.statusgroup = user.statusgroup exists.statusgroup = user.statusgroup
exists.voting = user.voting exists.voting = user.voting
exists.workgroups = user.workgroup
} else { } else {
state.users.push({ state.users.push({
username: user.username, username: user.username,
@ -32,7 +33,8 @@ const mutations = {
lastname: user.lastname, lastname: user.lastname,
mail: user.mail, mail: user.mail,
statusgroup: user.statusgroup, statusgroup: user.statusgroup,
voting: user.voting voting: user.voting,
workgroups: user.workgroups
}) })
} }
}, },
@ -59,6 +61,14 @@ const mutations = {
}, },
setStatusLoading: (state, value) => { setStatusLoading: (state, value) => {
state.statusLoading = 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)
if (e.response.status === 401) dispatch('logout', null, { root: true }) 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 })
}
} }
} }