diff --git a/public/index.html b/public/index.html
index 7e96d1c..ec4c4c7 100644
--- a/public/index.html
+++ b/public/index.html
@@ -1,5 +1,5 @@
-
+
diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue
index cd3edaa..d2db7df 100644
--- a/src/components/user/Jobs/Day.vue
+++ b/src/components/user/Jobs/Day.vue
@@ -23,6 +23,20 @@
+
+
+ Eintragen
+
@@ -55,7 +69,8 @@ export default {
...mapActions({
getUser: 'jobs/getUser',
setLoading: 'jobs/setDayLoading',
- setNotLoading: 'jobs/setDayNotLoading'
+ setNotLoading: 'jobs/setDayNotLoading',
+ addJob: 'jobs/addJob'
}),
test(event) {
console.log('blur', event)
diff --git a/src/plugins/routes.js b/src/plugins/routes.js
index caabd83..128224f 100644
--- a/src/plugins/routes.js
+++ b/src/plugins/routes.js
@@ -29,7 +29,8 @@ const url = {
},
user: {
config: main + 'user/saveConfig',
- job: main + 'user/job'
+ job: main + 'user/job',
+ addJob: main + 'user/addJob'
},
barU: {
storno: main + 'bar/storno'
diff --git a/src/store/modules/jobs.js b/src/store/modules/jobs.js
index 0f35f6b..82ca622 100644
--- a/src/store/modules/jobs.js
+++ b/src/store/modules/jobs.js
@@ -38,7 +38,8 @@ const mutations = {
date: currentDate,
name: 'Montag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
case 2:
@@ -47,7 +48,8 @@ const mutations = {
date: currentDate,
name: 'Dienstag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
case 3:
@@ -61,7 +63,8 @@ const mutations = {
date: currentDate,
name: 'Mittwoch',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
}
break
@@ -71,7 +74,8 @@ const mutations = {
date: currentDate,
name: 'Donnerstag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
case 5:
@@ -80,7 +84,8 @@ const mutations = {
date: currentDate,
name: 'Freitag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
case 6:
@@ -89,7 +94,8 @@ const mutations = {
date: currentDate,
name: 'Samstag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
case 0:
@@ -98,7 +104,8 @@ const mutations = {
date: currentDate,
name: 'Sontag',
worker: [],
- loading: false
+ loading: false,
+ locked: false
}
break
}
@@ -114,13 +121,18 @@ const mutations = {
let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username
})
- if (!worker && data.com === 'add') {
- state.month[week].days[day].worker.push({
- firstname: user.firstname,
- lastname: user.lastname,
- username: user.username,
- fullName: user.firstname + ' ' + user.lastname
- })
+ if (user) {
+ if (!worker && data.com === 'add') {
+ state.month[week].days[day].worker.push({
+ firstname: user.firstname,
+ lastname: 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 },
{ headers: { Token: rootState.login.user.accessToken } }
)
- for (let item = 0; item < response.data.length; item++) {
- commit('updateMonth', { ...response.data[item], com: 'add' })
+ for (let item = 0; item < response.data.worker.length; item++) {
+ 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 })
} catch (e) {
if (e.response)
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 })
+ }
}
}
diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js
index dde6eae..1193de3 100644
--- a/src/store/modules/serviceManagement.js
+++ b/src/store/modules/serviceManagement.js
@@ -156,13 +156,18 @@ const mutations = {
let worker = state.month[week].days[day].worker.find(a => {
return a.username === user.username
})
- if (!worker && data.com === 'add') {
- state.month[week].days[day].worker.push({
- firstname: user.firstname,
- lastname: user.lastname,
- username: user.username,
- fullName: user.firstname + ' ' + user.lastname
- })
+ if (user) {
+ if (!worker && data.com === 'add') {
+ state.month[week].days[day].worker.push({
+ firstname: user.firstname,
+ lastname: 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 } }
)
console.log(response.data)
- for (let item = 0; item < response.data.length; item++) {
- commit('updateMonth', { ...response.data[item], com: 'add' })
+ for (let item = 0; item < response.data.worker.length; item++) {
+ 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 })
} catch (e) {
if (e.response)