finished ##186
This commit is contained in:
parent
b6dfc45c46
commit
9082b00567
|
@ -21,7 +21,7 @@
|
|||
</v-toolbar-items>
|
||||
<v-spacer />
|
||||
</v-toolbar>
|
||||
<v-card v-for="week in month" :key="month.indexOf(week)">
|
||||
<v-card v-for="week in month" :key="month.indexOf(week)" flat tile>
|
||||
<v-card-title class="subtitle-1 font-weight-bold">
|
||||
Woche vom {{ week.startDate.getDate() }}.{{
|
||||
week.startDate.getMonth() + 1
|
||||
|
|
|
@ -23,7 +23,14 @@
|
|||
</div>
|
||||
</v-expand-transition>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-card-actions class="text--secondary">
|
||||
<div v-if="day.locked">
|
||||
Du kannst dich nicht zum Bardienst eintragen, da der Tag gesperrt ist.
|
||||
</div>
|
||||
<div v-else-if="day.worker.length >= 2">
|
||||
Du kannst dich nicht Bardienst eintragen, da mehr als 2 Personen schon eingetragen sind.
|
||||
</div>
|
||||
<div v-else>Hier kannst du dich zum Bardienst eintragen.</div>
|
||||
<v-spacer />
|
||||
<v-btn
|
||||
v-if="!day.locked && !day.loading && day.worker.length < 2"
|
||||
|
|
|
@ -21,8 +21,12 @@
|
|||
</v-btn>
|
||||
</v-toolbar-items>
|
||||
<v-spacer />
|
||||
<v-toolbar-items>
|
||||
<v-btn text @click="lockDays(true)">Monat sperren</v-btn>
|
||||
<v-btn text @click="lockDays(false)">Monat freigeben</v-btn>
|
||||
</v-toolbar-items>
|
||||
</v-toolbar>
|
||||
<v-card v-for="week in month" :key="month.indexOf(week)">
|
||||
<v-card v-for="week in month" :key="month.indexOf(week)" tile flat>
|
||||
<v-card-title class="subtitle-1 font-weight-bold">
|
||||
Woche vom {{ week.startDate.getDate() }}.{{
|
||||
week.startDate.getMonth() + 1
|
||||
|
@ -81,7 +85,8 @@ export default {
|
|||
methods: {
|
||||
...mapActions({
|
||||
createMonth: 'sm/createMonth',
|
||||
getAllUsers: 'sm/getAllUsers'
|
||||
getAllUsers: 'sm/getAllUsers',
|
||||
lockDay: 'sm/lockDay'
|
||||
}),
|
||||
changeMonth(value) {
|
||||
if (value === -1) {
|
||||
|
@ -90,6 +95,14 @@ export default {
|
|||
this.date = new Date(this.date.getFullYear(), this.date.getMonth() + 1)
|
||||
}
|
||||
this.createMonth(this.date)
|
||||
},
|
||||
lockDays(value) {
|
||||
for (var week in this.month) {
|
||||
for (var dayint in this.month[week].days) {
|
||||
var day = this.month[week].days[dayint]
|
||||
this.lockDay({year: day.date.getFullYear(), month: day.date.getMonth() + 1, day: day.date.getDate(), locked: value})
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
|
|
|
@ -24,14 +24,13 @@
|
|||
label="Dienste"
|
||||
filled
|
||||
color="green"
|
||||
@input="searchInput=null"
|
||||
@input="searchInput = null"
|
||||
:search-input.sync="searchInput"
|
||||
@blur="focused=false"
|
||||
@focus="focused=true"
|
||||
|
||||
@blur="focused = false"
|
||||
@focus="focused = true"
|
||||
>
|
||||
<template v-slot:prepend-inner>
|
||||
<v-icon>{{account_add}}</v-icon>
|
||||
<v-icon>{{ account_add }}</v-icon>
|
||||
</template>
|
||||
<template v-slot:selection="data">
|
||||
<v-chip
|
||||
|
@ -55,13 +54,18 @@
|
|||
</div>
|
||||
</v-expand-transition>
|
||||
</v-card-text>
|
||||
<v-card-actions v-if="!day.loading">
|
||||
<v-chip class="text-uppercase" :color="lockedColor">{{ lockedText }}</v-chip>
|
||||
<v-spacer />
|
||||
<v-btn @click="lock">{{lockedTextBtn}}</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapGetters, mapActions } from 'vuex'
|
||||
import {mdiAccountPlus} from '@mdi/js'
|
||||
import { mdiAccountPlus } from '@mdi/js'
|
||||
export default {
|
||||
name: 'Day',
|
||||
props: {
|
||||
|
@ -90,7 +94,8 @@ export default {
|
|||
getUser: 'sm/getUser',
|
||||
deleteUser: 'sm/deleteUser',
|
||||
setLoading: 'sm/setDayLoading',
|
||||
setNotLoading: 'sm/setDayNotLoading'
|
||||
setNotLoading: 'sm/setDayNotLoading',
|
||||
lockDay: 'sm/lockDay'
|
||||
}),
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
remove(deletedUser) {
|
||||
|
@ -126,6 +131,9 @@ export default {
|
|||
return 'grey lighten-4'
|
||||
}
|
||||
},
|
||||
lock() {
|
||||
this.lockDay({year: this.day.date.getFullYear(), month: this.day.date.getMonth() + 1, day: this.day.date.getDate(), locked: !this.day.locked})
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters({
|
||||
|
@ -134,6 +142,15 @@ export default {
|
|||
}),
|
||||
worker() {
|
||||
return this.day.worker
|
||||
},
|
||||
lockedColor() {
|
||||
return this.day.locked ? 'red' : 'green'
|
||||
},
|
||||
lockedText() {
|
||||
return this.day.locked ? 'gesperrt' : 'frei'
|
||||
},
|
||||
lockedTextBtn() {
|
||||
return this.day.locked ? 'freigeben' : 'sperren'
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -156,7 +173,7 @@ export default {
|
|||
for (let user in oldValue) {
|
||||
if (!newValue.includes(oldValue[user])) {
|
||||
deletedUser = oldValue[user]
|
||||
console.log("deleteUser", deletedUser, this.day.date)
|
||||
console.log('deleteUser', deletedUser, this.day.date)
|
||||
this.deleteUser({
|
||||
startdatetime: this.day.date,
|
||||
date: this.day.date.getTime() / 1000,
|
||||
|
|
|
@ -24,7 +24,8 @@ const url = {
|
|||
sm: {
|
||||
addUser: main + 'sm/addUser',
|
||||
deleteUser: main + 'sm/deleteUser',
|
||||
getUser: main + 'sm/getUser'
|
||||
getUser: main + 'sm/getUser',
|
||||
lockDay: main + 'sm/lockDay'
|
||||
}
|
||||
},
|
||||
user: {
|
||||
|
|
|
@ -118,10 +118,10 @@ const mutations = {
|
|||
for (let week = 0; week < state.month.length; week++) {
|
||||
for (let day in state.month[week].days) {
|
||||
if (state.month[week].days[day].date - date === 0) {
|
||||
if (user) {
|
||||
let worker = state.month[week].days[day].worker.find(a => {
|
||||
return a.username === user.username
|
||||
})
|
||||
if (user) {
|
||||
if (!worker && data.com === 'add') {
|
||||
state.month[week].days[day].worker.push({
|
||||
firstname: user.firstname,
|
||||
|
@ -211,7 +211,6 @@ const actions = {
|
|||
day: response.data.day
|
||||
})
|
||||
}
|
||||
if (response.data.worker.length === 0)
|
||||
commit('updateMonth', {
|
||||
start: response.data.day.date,
|
||||
day: response.data.day
|
||||
|
|
|
@ -47,7 +47,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Montag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 2:
|
||||
|
@ -56,7 +57,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Dienstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 3:
|
||||
|
@ -70,7 +72,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Mittwoch',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
}
|
||||
break
|
||||
|
@ -80,7 +83,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Donnerstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 5:
|
||||
|
@ -89,7 +93,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Freitag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 6:
|
||||
|
@ -98,7 +103,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Samstag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
case 0:
|
||||
|
@ -107,7 +113,8 @@ const mutations = {
|
|||
date: currentDate,
|
||||
name: 'Sontag',
|
||||
worker: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
locked: false
|
||||
}
|
||||
break
|
||||
}
|
||||
|
@ -153,10 +160,10 @@ const mutations = {
|
|||
for (let week = 0; week < state.month.length; week++) {
|
||||
for (let day in state.month[week].days) {
|
||||
if (state.month[week].days[day].date - date === 0) {
|
||||
if (user) {
|
||||
let worker = state.month[week].days[day].worker.find(a => {
|
||||
return a.username === user.username
|
||||
})
|
||||
if (user) {
|
||||
if (!worker && data.com === 'add') {
|
||||
state.month[week].days[day].worker.push({
|
||||
firstname: user.firstname,
|
||||
|
@ -228,12 +235,17 @@ const actions = {
|
|||
{ ...data },
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
console.log(response.data)
|
||||
for (let item = 0; item < response.data.worker.length; item++) {
|
||||
commit('updateMonth', { ...response.data.worker[item], com: 'add', day: response.data.day })
|
||||
commit('updateMonth', {
|
||||
...response.data.worker[item],
|
||||
com: 'add',
|
||||
day: response.data.day
|
||||
})
|
||||
}
|
||||
if (response.data.worker.length === 0)
|
||||
commit('updateMonth', { start: response.data.day.date, day:response.data.day})
|
||||
commit('updateMonth', {
|
||||
start: response.data.day.date,
|
||||
day: response.data.day
|
||||
})
|
||||
commit('setDayNotLoading', { date: data.startdatetime, getters })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
|
@ -255,6 +267,19 @@ const actions = {
|
|||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
async lockDay({ commit, rootState, dispatch }, data) {
|
||||
try {
|
||||
const response = await axios.post(
|
||||
url.vorstand.sm.lockDay,
|
||||
{ ...data },
|
||||
{ headers: { Token: rootState.login.user.accessToken } }
|
||||
)
|
||||
commit('updateMonth', { start: response.data.date, day: response.data })
|
||||
} catch (e) {
|
||||
if (e.response)
|
||||
if (e.response.status === 401) dispatch('logout', null, { root: true })
|
||||
}
|
||||
},
|
||||
setDayLoading({ commit, getters }, date) {
|
||||
commit('setDayLoading', { date, getters })
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue