Merge branch 'feature/workgroup' into develop

This commit is contained in:
Tim Gröger 2020-05-17 13:47:41 +02:00
commit e0eeb5c467
11 changed files with 446 additions and 23 deletions

View File

@ -1,6 +1,11 @@
<template> <template>
<div> <div>
<v-data-table :headers="headers" :items="priceList" :search="search" :loading="priceListLoading || typesLoading"> <v-data-table
:headers="headers"
:items="priceList"
:search="search"
:loading="priceListLoading || typesLoading"
>
<template v-slot:top> <template v-slot:top>
<v-toolbar flat color="white"> <v-toolbar flat color="white">
<v-toolbar-title>Preisliste</v-toolbar-title> <v-toolbar-title>Preisliste</v-toolbar-title>
@ -363,7 +368,7 @@ export default {
this.closeType() this.closeType()
}, },
deleteType(item) { deleteType(item) {
confirm('Bist du sicher, dass die diese Kategorie entfernen wills?') && confirm('Bist du sicher, dass du diese Kategorie entfernen willst?') &&
this.deleteDrinkType({ id: item.id }) this.deleteDrinkType({ id: item.id })
}, },
addType() { addType() {

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

@ -132,10 +132,39 @@
</v-combobox> </v-combobox>
</v-col> </v-col>
<v-col v-bind:class="{ fulllineText: isFulllineText }"> <v-col v-bind:class="{ fulllineText: isFulllineText }">
<v-text-field outlined :value="computeStatus" readonly label="Mitgliedsstatus"/> <v-text-field
outlined
:value="computeStatus"
readonly
label="Mitgliedsstatus"
/>
</v-col> </v-col>
<v-col v-bind:class="{ fulllineText: isFulllineText }"> <v-col v-bind:class="{ fulllineText: isFulllineText }">
<v-text-field outlined :value="user.voting ? 'ja' : 'nein'" readonly label="Stimmrecht" /> <v-text-field
outlined
:value="user.voting ? 'ja' : 'nein'"
readonly
label="Stimmrecht"
/>
</v-col>
</v-row>
<v-row>
<v-col v-bind:class="{ fulllineText: isFulllineText }">
<v-combobox
chips
outlined
multiple
label="Arbeitsgruppen"
readonly
v-model="user.workgroups"
item-value="id"
item-text="name"
append-icon
>
<template v-slot:selection="data">
<v-chip>{{data.item.name}}</v-chip>
</template>
</v-combobox>
</v-col> </v-col>
</v-row> </v-row>
</v-card-text> </v-card-text>
@ -186,9 +215,8 @@ export default {
}, },
mounted() { mounted() {
this.$nextTick(function() { this.$nextTick(function() {
window.addEventListener('resize', this.getWindowWidth); window.addEventListener('resize', this.getWindowWidth)
this.getWindowWidth() this.getWindowWidth()
}) })
}, },
methods: { methods: {
@ -197,7 +225,7 @@ export default {
getStatus: 'user/getStatus' getStatus: 'user/getStatus'
}), }),
getWindowWidth() { getWindowWidth() {
this.isFulllineText = document.documentElement.clientWidth <= 600; this.isFulllineText = document.documentElement.clientWidth <= 600
}, },
save() { save() {
let user = {} let user = {}
@ -249,6 +277,7 @@ export default {
</script> </script>
<style scoped> <style scoped>
.fulllineText{ .fulllineText {
flex-basis: unset; flex-basis: unset;
}</style> }
</style>

View File

@ -16,17 +16,26 @@
Benutzerliste Benutzerliste
</v-list-item-title> </v-list-item-title>
</v-list-item> </v-list-item>
<v-list-item link to="/main/management/workgroupmanagement">
<v-list-item-icon>
<v-icon>{{group}}</v-icon>
</v-list-item-icon>
<v-list-item-title>
Arbeitsgruppen
</v-list-item-title>
</v-list-item>
</v-list> </v-list>
</template> </template>
<script> <script>
import { mdiBriefcase, mdiAccountMultiple } from '@mdi/js' import { mdiBriefcase, mdiAccountMultiple, mdiAccountGroup } from '@mdi/js'
export default { export default {
name: 'ManagementNavigation', name: 'ManagementNavigation',
data() { data() {
return { return {
work: mdiBriefcase, work: mdiBriefcase,
list: mdiAccountMultiple list: mdiAccountMultiple,
group: mdiAccountGroup
} }
} }
} }

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

@ -0,0 +1,190 @@
<template>
<div>
<v-data-table
:headers="header"
:items="workgroups"
:loading="workgroupLoading"
:search="search"
>
<template v-slot:top>
<v-toolbar flat color="white">
<v-toolbar-title>Arbeitsgruppen</v-toolbar-title>
<v-spacer> </v-spacer>
<v-text-field
v-model="search"
label="Suche Arbeitsgrupp"
single-line
hide-details
>
<template v-slot:append>
<v-icon>{{ searchIcon }}</v-icon>
</template>
</v-text-field>
<v-dialog v-model="dialog">
<template v-slot:activator="{ on }">
<v-btn
fab
x-small
color="primary"
class="mb-2"
v-on="on"
style="margin: 5px"
>
<v-icon>
{{ plusIcon }}
</v-icon>
</v-btn>
</template>
<v-card>
<v-card-title>
<span class="headline">{{ formTitle }}</span>
</v-card-title>
<v-card-text>
<v-container>
<v-text-field
v-model="editedItem.name"
label="Name"
outlined
></v-text-field>
<v-autocomplete
v-model="editedItem.boss"
label="AG-Leiter"
:items="users"
:item-text="item => item.firstname + ' ' + item.lastname"
item-value="username"
:loading="usersLoading"
outlined
return-object
>
</v-autocomplete>
</v-container>
</v-card-text>
<v-card-actions>
<v-spacer></v-spacer>
<v-btn color="blue darken-1" text @click="close"
>Abbreche</v-btn
>
<v-btn color="blue darken-1" text @click="save"
>Speichern</v-btn
>
</v-card-actions>
</v-card>
</v-dialog>
</v-toolbar>
</template>
<template v-slot:item.boss="{ item }">
<div v-if="item.boss != null">
{{ item.boss.firstname }} {{ item.boss.lastname }}
</div>
</template>
<template v-slot:item.actions="{ item }">
<v-icon small class="mr-2" @click="editItem(item)">
{{ editIcon }}
</v-icon>
<v-icon small class="mr-2" @click="deleteItem(item)">
{{ deleteIcon }}
</v-icon>
</template>
</v-data-table>
</div>
</template>
<script>
import { mdiPencil, mdiMagnify, mdiDelete, mdiPlus } from '@mdi/js'
import { mapActions, mapGetters } from 'vuex'
export default {
name: 'WorkgroupManagement',
data() {
return {
editIcon: mdiPencil,
searchIcon: mdiMagnify,
deleteIcon: mdiDelete,
plusIcon: mdiPlus,
search: null,
dialog: false,
header: [
{ text: 'AG-Name', value: 'name' },
{ text: 'AG-Leiter', value: 'boss' },
{
text: 'Aktionen',
value: 'actions',
sortable: false,
filterable: false
}
],
editedItem: {
id: -1,
username: null,
boss: {
username: null,
firstname: null,
lastname: null
}
},
defaultItem: {
id: -1,
username: null,
boss: {
name: null,
firstname: null,
lastname: null
}
},
editedIndex: -1
}
},
methods: {
...mapActions({
getAllWorkgroups: 'wm/getAllWorkgroups',
setWorkgroup: 'wm/setWorkgroup',
updateWorkgroup: 'wm/updateWorkgroup',
getAllUsers: 'usermanager/getUsers',
deleteWorkgroup: 'wm/deleteWorkgroup'
}),
editItem(item) {
this.editedIndex = item.id
this.editedItem = Object.assign({}, item)
this.dialog = true
},
save() {
this.editedItem.id === -1
? this.setWorkgroup(this.editedItem)
: this.updateWorkgroup(this.editedItem)
this.editedItem = Object.assign({}, this.defaultItem)
this.close()
},
close() {
this.dialog = false
setTimeout(() => {
this.editedItem = Object.assign({}, this.defaultItem)
this.editedIndex = -1
}, 300)
},
deleteItem(item) {
confirm(
'Bist du sicher, dass du diese Arbeitsgruppe entfernen willst?'
) && this.deleteWorkgroup(item)
}
},
computed: {
...mapGetters({
workgroupLoading: 'wm/workgroupLoading',
workgroups: 'wm/workgroups',
users: 'usermanager/users',
usersLoading: 'usermanager/usersLoading'
}),
formTitle() {
return this.editedIndex === -1
? 'Neue Arbeitsgruppe'
: 'Bearbeite Arbeitsgruppe'
}
},
created() {
this.getAllWorkgroups()
this.getAllUsers()
console.log(this.users)
}
}
</script>
<style scoped></style>

View File

@ -1,7 +1,7 @@
//const main = 'https://192.168.5.128:5000/' //const main = 'https://192.168.5.128:5000/'
//const main = 'http://localhost:5000/' const main = 'http://localhost:5000/'
//const main = 'http://192.168.5.118:5000/' //const main = 'http://192.168.5.118:5000/'
const main = 'https://groeger-clan.duckdns.org:5000/' //const main = 'https://groeger-clan.duckdns.org:5000/'
const url = { const url = {
login: main + 'login', login: main + 'login',
@ -10,7 +10,7 @@ const url = {
pricelist: main + 'pricelist', pricelist: main + 'pricelist',
getTypes: main + 'drinkTypes', getTypes: main + 'drinkTypes',
getFinanzerMain: main + 'getFinanzerMain', getFinanzerMain: main + 'getFinanzerMain',
bar: main + 'bar' bar: main + 'bar',
barGetUser: main + 'barGetUser', barGetUser: main + 'barGetUser',
barAddAmount: main + 'baradd', barAddAmount: main + 'baradd',
finanzerAddAmount: main + 'finanzerAddAmount', finanzerAddAmount: main + 'finanzerAddAmount',
@ -40,7 +40,14 @@ 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: {
workgroup: main + 'wgm/workgroup',
getWorkgroup: main + 'wgm/getWorkgroup',
getAllWorkgroups: main + 'wgm/getAllWorkgroups',
deleteWorkgroup: main + 'wgm/deleteWorkgroup'
} }
}, },
user: { user: {

View File

@ -23,6 +23,7 @@ import ManagementNavigation from '@/components/vorstand/ManagementNavigation'
import GastroNavigation from '@/components/gastro/GastroNavigation' import GastroNavigation from '@/components/gastro/GastroNavigation'
import PriceListView from '@/views/contents/PriceListView' import PriceListView from '@/views/contents/PriceListView'
import UserManager from '@/components/vorstand/UserManager' import UserManager from '@/components/vorstand/UserManager'
import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement";
Vue.use(VueRouter) Vue.use(VueRouter)
@ -58,6 +59,10 @@ const routes = [
{ {
path: 'usermanager', path: 'usermanager',
component: UserManager component: UserManager
},
{
path: 'workgroupmanagement',
component: WorkgroupManagement
} }
] ]
}, },

View File

@ -9,6 +9,7 @@ import jobs from '@/store/modules/jobs'
import requestJobs from '@/store/modules/jobRequests' import requestJobs from '@/store/modules/jobRequests'
import priceList from '@/store/modules/pricelist' import priceList from '@/store/modules/pricelist'
import usermanager from '@/store/modules/userManager' import usermanager from '@/store/modules/userManager'
import wm from '@/store/modules/workgroupManagement'
Vue.use(Vuex) Vue.use(Vuex)
@ -22,6 +23,7 @@ export default new Vuex.Store({
jobs, jobs,
requestJobs, requestJobs,
priceList, priceList,
usermanager usermanager,
wm
} }
}) })

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

View File

@ -0,0 +1,120 @@
import url from '@/plugins/routes'
import axios from 'axios'
const state = {
workgroupsLoading: false,
workgroups: []
}
const mutations = {
setWorkgroups: (state, workgroups) => {
state.workgroups = workgroups
},
updateWorkgroup: (state, workgroup) => {
console.log('workgroup is', workgroup)
let exists = state.workgroups.find(a => {
return a.id === workgroup.id
})
console.log('exists is', exists)
if (exists) {
exists.name = workgroup.name
exists.boss = workgroup.boss
} else {
state.workgroups.push(workgroup)
}
},
deleteWorkgroup: (state, workergroup) => {
let index = state.workgroups.indexOf(
state.workgroups.find(a => {
return a.id === workergroup.id
})
)
state.workgroups.splice(index, 1)
},
setWorkgroupLoading: (state, value) => {
state.workgroupsLoading = value
}
}
const actions = {
async getAllWorkgroups({ commit, rootState, dispatch }) {
try {
commit('setWorkgroupLoading', true)
const response = await axios.get(url.vorstand.wm.getAllWorkgroups, {
headers: { Token: rootState.login.user.accessToken }
})
commit('setWorkgroups', response.data)
commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
commit('setWorkgroupLoading', false)
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async setWorkgroup({ commit, rootState, dispatch }, data) {
try {
commit('setWorkgroupLoading', true)
const response = await axios.put(
url.vorstand.wm.workgroup,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateWorkgroup', response.data)
commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async updateWorkgroup({ commit, rootState, dispatch }, data) {
try {
commit('setWorkgroupLoading', true)
const repsonse = await axios.post(
url.vorstand.wm.workgroup,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('updateWorkgroup', repsonse.data)
commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
},
async deleteWorkgroup({ commit, rootState, dispatch }, data) {
try {
commit('setWorkgroupLoading', true)
await axios.post(
url.vorstand.wm.deleteWorkgroup,
{ ...data },
{ headers: { Token: rootState.login.user.accessToken } }
)
commit('deleteWorkgroup', data)
commit('setWorkgroupLoading', false)
dispatch('getLifeTime', null, { root: true })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
}
}
const getters = {
workgroups: state => {
return state.workgroups
},
workgroupLoading: state => {
return state.workgroupsLoading
}
}
export default {
namespaced: true,
state,
mutations,
actions,
getters
}