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() {
this.addAmount(this.value * 100)
this.addAmount(Math.abs(this.value * 100))
setTimeout(() => {
this.value = null
}, 300)

View File

@ -42,6 +42,20 @@
/>
</v-col>
</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-card-text>
<v-card-actions>
@ -68,6 +82,13 @@
</v-text-field>
</v-toolbar>
</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 }">
{{ computeStatus(item.statusgroup) }}
</template>
@ -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()
}
}
</script>

View File

@ -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',

View File

@ -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 })
}
}
}