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>
<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>
<v-toolbar flat color="white">
<v-toolbar-title>Preisliste</v-toolbar-title>
@ -363,7 +368,7 @@ export default {
this.closeType()
},
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 })
},
addType() {
@ -459,7 +464,7 @@ export default {
computeType() {
return id => {
const type = this.types.find(a => {
return a.id === id
return a.id === id
})
return type ? type.name : null
}

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

@ -132,10 +132,39 @@
</v-combobox>
</v-col>
<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-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-row>
</v-card-text>
@ -186,9 +215,8 @@ export default {
},
mounted() {
this.$nextTick(function() {
window.addEventListener('resize', this.getWindowWidth);
window.addEventListener('resize', this.getWindowWidth)
this.getWindowWidth()
})
},
methods: {
@ -196,9 +224,9 @@ export default {
saveConfig: 'user/saveConfig',
getStatus: 'user/getStatus'
}),
getWindowWidth() {
this.isFulllineText = document.documentElement.clientWidth <= 600;
},
getWindowWidth() {
this.isFulllineText = document.documentElement.clientWidth <= 600
},
save() {
let user = {}
if (this.firstname) user.firstname = this.firstname
@ -249,6 +277,7 @@ export default {
</script>
<style scoped>
.fulllineText{
.fulllineText {
flex-basis: unset;
}</style>
}
</style>

View File

@ -16,17 +16,26 @@
Benutzerliste
</v-list-item-title>
</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>
</template>
<script>
import { mdiBriefcase, mdiAccountMultiple } from '@mdi/js'
import { mdiBriefcase, mdiAccountMultiple, mdiAccountGroup } from '@mdi/js'
export default {
name: 'ManagementNavigation',
data() {
return {
work: mdiBriefcase,
list: mdiAccountMultiple
list: mdiAccountMultiple,
group: mdiAccountGroup
}
}
}

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

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

View File

@ -23,6 +23,7 @@ import ManagementNavigation from '@/components/vorstand/ManagementNavigation'
import GastroNavigation from '@/components/gastro/GastroNavigation'
import PriceListView from '@/views/contents/PriceListView'
import UserManager from '@/components/vorstand/UserManager'
import WorkgroupManagement from "@/components/vorstand/WorkgroupManagement";
Vue.use(VueRouter)
@ -58,6 +59,10 @@ const routes = [
{
path: '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 priceList from '@/store/modules/pricelist'
import usermanager from '@/store/modules/userManager'
import wm from '@/store/modules/workgroupManagement'
Vue.use(Vuex)
@ -22,6 +23,7 @@ export default new Vuex.Store({
jobs,
requestJobs,
priceList,
usermanager
usermanager,
wm
}
})

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

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
}