finished ##184

This commit is contained in:
Tim Gröger 2020-02-23 22:32:31 +01:00
parent dadb31f376
commit b6dfc45c46
5 changed files with 87 additions and 28 deletions

View File

@ -1,5 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="de">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">

View File

@ -23,6 +23,20 @@
</div> </div>
</v-expand-transition> </v-expand-transition>
</v-card-text> </v-card-text>
<v-card-actions>
<v-spacer />
<v-btn
v-if="!day.locked && !day.loading && day.worker.length < 2"
@click="
addJob({
year: day.date.getFullYear(),
month: day.date.getMonth() + 1,
day: day.date.getDate()
})
"
>Eintragen</v-btn
>
</v-card-actions>
</v-card> </v-card>
</div> </div>
</template> </template>
@ -55,7 +69,8 @@ export default {
...mapActions({ ...mapActions({
getUser: 'jobs/getUser', getUser: 'jobs/getUser',
setLoading: 'jobs/setDayLoading', setLoading: 'jobs/setDayLoading',
setNotLoading: 'jobs/setDayNotLoading' setNotLoading: 'jobs/setDayNotLoading',
addJob: 'jobs/addJob'
}), }),
test(event) { test(event) {
console.log('blur', event) console.log('blur', event)

View File

@ -29,7 +29,8 @@ const url = {
}, },
user: { user: {
config: main + 'user/saveConfig', config: main + 'user/saveConfig',
job: main + 'user/job' job: main + 'user/job',
addJob: main + 'user/addJob'
}, },
barU: { barU: {
storno: main + 'bar/storno' storno: main + 'bar/storno'

View File

@ -38,7 +38,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Montag', name: 'Montag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
case 2: case 2:
@ -47,7 +48,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Dienstag', name: 'Dienstag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
case 3: case 3:
@ -61,7 +63,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Mittwoch', name: 'Mittwoch',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
} }
break break
@ -71,7 +74,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Donnerstag', name: 'Donnerstag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
case 5: case 5:
@ -80,7 +84,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Freitag', name: 'Freitag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
case 6: case 6:
@ -89,7 +94,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Samstag', name: 'Samstag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
case 0: case 0:
@ -98,7 +104,8 @@ const mutations = {
date: currentDate, date: currentDate,
name: 'Sontag', name: 'Sontag',
worker: [], worker: [],
loading: false loading: false,
locked: false
} }
break break
} }
@ -114,13 +121,18 @@ const mutations = {
let worker = state.month[week].days[day].worker.find(a => { let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username return a.username === user.username
}) })
if (!worker && data.com === 'add') { if (user) {
state.month[week].days[day].worker.push({ if (!worker && data.com === 'add') {
firstname: user.firstname, state.month[week].days[day].worker.push({
lastname: user.lastname, firstname: user.firstname,
username: user.username, lastname: user.lastname,
fullName: user.firstname + ' ' + user.lastname username: user.username,
}) fullName: user.firstname + ' ' + user.lastname
})
}
}
if (data.day) {
state.month[week].days[day].locked = data.day.locked
} }
} }
} }
@ -192,14 +204,38 @@ const actions = {
{ ...data }, { ...data },
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
for (let item = 0; item < response.data.length; item++) { for (let item = 0; item < response.data.worker.length; item++) {
commit('updateMonth', { ...response.data[item], com: 'add' }) 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('setDayNotLoading', { date: data.startdatetime, getters }) commit('setDayNotLoading', { date: data.startdatetime, getters })
} catch (e) { } catch (e) {
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 addJob({ commit, rootState, dispatch }, data) {
try {
const response = await axios.post(
url.user.addJob,
{ ...data },
{
headers: { Token: rootState.login.user.accessToken }
}
)
commit('updateMonth', { ...response.data[0], com: 'add' })
} catch (e) {
if (e.response)
if (e.response.status === 401) dispatch('logout', null, { root: true })
}
} }
} }

View File

@ -156,13 +156,18 @@ const mutations = {
let worker = state.month[week].days[day].worker.find(a => { let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username return a.username === user.username
}) })
if (!worker && data.com === 'add') { if (user) {
state.month[week].days[day].worker.push({ if (!worker && data.com === 'add') {
firstname: user.firstname, state.month[week].days[day].worker.push({
lastname: user.lastname, firstname: user.firstname,
username: user.username, lastname: user.lastname,
fullName: user.firstname + ' ' + user.lastname username: user.username,
}) fullName: user.firstname + ' ' + user.lastname
})
}
}
if (data.day) {
state.month[week].days[day].locked = data.day.locked
} }
} }
} }
@ -224,9 +229,11 @@ const actions = {
{ headers: { Token: rootState.login.user.accessToken } } { headers: { Token: rootState.login.user.accessToken } }
) )
console.log(response.data) console.log(response.data)
for (let item = 0; item < response.data.length; item++) { for (let item = 0; item < response.data.worker.length; item++) {
commit('updateMonth', { ...response.data[item], com: 'add' }) 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('setDayNotLoading', { date: data.startdatetime, getters }) commit('setDayNotLoading', { date: data.startdatetime, getters })
} catch (e) { } catch (e) {
if (e.response) if (e.response)