From dadb31f3769d743caaf1fc0d7e804960bd1b8fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 23 Feb 2020 11:19:53 +0100 Subject: [PATCH 1/5] finished ##188 for sm only send year, month, day. But you have to decrement month to send, because month starts with 0. Also you have to increment month to get. --- src/components/user/Jobs/Day.vue | 48 ++++++------------- .../ServiceManagementComponents/Day.vue | 25 ++++++++-- src/store/modules/jobs.js | 4 +- src/store/modules/serviceManagement.js | 5 +- 4 files changed, 39 insertions(+), 43 deletions(-) diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index a7c8138..cd3edaa 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -14,38 +14,12 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {{ worker.firstname }} {{ worker.lastname }} + {{ worker.firstname }} {{ worker.lastname }}
@@ -71,7 +45,10 @@ export default { this.setLoading(this.day.date) this.getUser({ date: this.day.date.getTime() / 1000, - startdatetime: this.day.date + startdatetime: this.day.date, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) }, methods: { @@ -108,7 +85,10 @@ export default { day() { this.getUser({ date: this.day.date.getTime() / 1000, - startdatetime: this.day.date + startdatetime: this.day.date, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) }, worker() { diff --git a/src/components/vorstand/ServiceManagementComponents/Day.vue b/src/components/vorstand/ServiceManagementComponents/Day.vue index 2142525..264cfaa 100644 --- a/src/components/vorstand/ServiceManagementComponents/Day.vue +++ b/src/components/vorstand/ServiceManagementComponents/Day.vue @@ -78,7 +78,10 @@ export default { this.setLoading(this.day.date) this.getUser({ date: this.day.date.getTime() / 1000, - startdatetime: this.day.date + startdatetime: this.day.date, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) }, methods: { @@ -99,7 +102,10 @@ export default { this.deleteUser({ startdatetime: this.day.date, date: this.day.date.getTime() / 1000, - user: deletedUser + user: deletedUser, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) }, test(event) { @@ -139,7 +145,10 @@ export default { addedUser = newValue[user] this.addUser({ date: this.day.date.getTime() / 1000, - user: addedUser + user: addedUser, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) } } @@ -151,7 +160,10 @@ export default { this.deleteUser({ startdatetime: this.day.date, date: this.day.date.getTime() / 1000, - user: deletedUser + user: deletedUser, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) } } @@ -160,7 +172,10 @@ export default { day() { this.getUser({ date: this.day.date.getTime() / 1000, - startdatetime: this.day.date + startdatetime: this.day.date, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() }) }, focused(newVal, oldValue) { diff --git a/src/store/modules/jobs.js b/src/store/modules/jobs.js index 319a77b..0f35f6b 100644 --- a/src/store/modules/jobs.js +++ b/src/store/modules/jobs.js @@ -25,7 +25,7 @@ const mutations = { let week = { id: id, days: {} } for (let intDay = startDate; intDay <= days + 7; intDay++) { if (end) break - let currentDate = new Date(year, mon, intDay, 12) + let currentDate = new Date(year, mon, intDay) switch (currentDate.getDay()) { case 1: @@ -106,7 +106,7 @@ const mutations = { state.month = month }, updateMonth: (state, data) => { - const date = new Date(data.startdatetime) + const date = new Date(data.start.year, data.start.month - 1, data.start.day) const user = data.user for (let week = 0; week < state.month.length; week++) { for (let day in state.month[week].days) { diff --git a/src/store/modules/serviceManagement.js b/src/store/modules/serviceManagement.js index 2b1b82e..dde6eae 100644 --- a/src/store/modules/serviceManagement.js +++ b/src/store/modules/serviceManagement.js @@ -34,7 +34,7 @@ const mutations = { let week = { id: id, days: {} } for (let intDay = startDate; intDay <= days + 7; intDay++) { if (end) break - let currentDate = new Date(year, mon, intDay, 12) + let currentDate = new Date(year, mon, intDay) switch (currentDate.getDay()) { case 1: @@ -148,7 +148,7 @@ const mutations = { } }, updateMonth: (state, data) => { - const date = new Date(data.startdatetime) + const date = new Date(data.start.year, data.start.month - 1, data.start.day) const user = data.user for (let week = 0; week < state.month.length; week++) { for (let day in state.month[week].days) { @@ -223,6 +223,7 @@ const actions = { { ...data }, { 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' }) } From b6dfc45c466a0417b95efee04a0d2af092bb89ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Sun, 23 Feb 2020 22:32:31 +0100 Subject: [PATCH 2/5] finished ##184 --- public/index.html | 2 +- src/components/user/Jobs/Day.vue | 17 ++++++- src/plugins/routes.js | 3 +- src/store/modules/jobs.js | 68 ++++++++++++++++++++------ src/store/modules/serviceManagement.js | 25 ++++++---- 5 files changed, 87 insertions(+), 28 deletions(-) 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) From 9082b005679f49ef0e64fcaf1cb8cd35d7c9b4db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Mon, 24 Feb 2020 12:19:13 +0100 Subject: [PATCH 3/5] finished ##186 --- src/components/user/Jobs.vue | 2 +- src/components/user/Jobs/Day.vue | 9 +++- src/components/vorstand/ServiceManagement.vue | 17 +++++- .../ServiceManagementComponents/Day.vue | 33 +++++++++--- src/plugins/routes.js | 3 +- src/store/modules/jobs.js | 15 +++--- src/store/modules/serviceManagement.js | 53 ++++++++++++++----- 7 files changed, 97 insertions(+), 35 deletions(-) diff --git a/src/components/user/Jobs.vue b/src/components/user/Jobs.vue index 642b1d4..a50bef1 100644 --- a/src/components/user/Jobs.vue +++ b/src/components/user/Jobs.vue @@ -21,7 +21,7 @@ - + Woche vom {{ week.startDate.getDate() }}.{{ week.startDate.getMonth() + 1 diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index d2db7df..29b96f2 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -23,7 +23,14 @@ - + +
+ Du kannst dich nicht zum Bardienst eintragen, da der Tag gesperrt ist. +
+
+ Du kannst dich nicht Bardienst eintragen, da mehr als 2 Personen schon eingetragen sind. +
+
Hier kannst du dich zum Bardienst eintragen.
+ + Monat sperren + Monat freigeben + - + 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: { diff --git a/src/components/vorstand/ServiceManagementComponents/Day.vue b/src/components/vorstand/ServiceManagementComponents/Day.vue index 264cfaa..5d9440c 100644 --- a/src/components/vorstand/ServiceManagementComponents/Day.vue +++ b/src/components/vorstand/ServiceManagementComponents/Day.vue @@ -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" > + + diff --git a/src/components/user/Jobs.vue b/src/components/user/Jobs.vue index a50bef1..77e322d 100644 --- a/src/components/user/Jobs.vue +++ b/src/components/user/Jobs.vue @@ -73,10 +73,12 @@ export default { }, created() { this.createMonth(this.date) + this.getAllUsers() }, methods: { ...mapActions({ - createMonth: 'jobs/createMonth' + createMonth: 'jobs/createMonth', + getAllUsers: 'jobs/getAllUsers' }), changeMonth(value) { if (value === -1) { diff --git a/src/components/user/Jobs/Day.vue b/src/components/user/Jobs/Day.vue index f14941a..7c14f9c 100644 --- a/src/components/user/Jobs/Day.vue +++ b/src/components/user/Jobs/Day.vue @@ -17,7 +17,7 @@
+ + + + + + + + senden + +
@@ -45,7 +74,10 @@
Eintragen + >Eintragen +
@@ -71,7 +103,8 @@ export default { data() { return { account_add: mdiAccountPlus, - searchInput: null + searchInput: null, + requestUser: null } }, created() { @@ -83,18 +116,36 @@ export default { month: this.day.date.getMonth() + 1, day: this.day.date.getDate() }) + this.getTransactJobs({}) + this.getTransactJobs({ + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() + }) }, methods: { ...mapActions({ + getTransactJobs: 'requestJobs/getTransactJobs', getUser: 'jobs/getUser', setLoading: 'jobs/setDayLoading', setNotLoading: 'jobs/setDayNotLoading', addJob: 'jobs/addJob', - deleteJob: 'jobs/deleteJob' + deleteJob: 'jobs/deleteJob', + transactJob: 'jobs/transactJob' }), test(event) { console.log('blur', event) }, + send() { + this.transactJob({ + user: this.requestUser.username, + year: this.day.date.getFullYear(), + month: this.day.date.getMonth() + 1, + day: this.day.date.getDate() + }) + this.requestUser = null + this.searchInput = null + }, color: day => { if (day) { if (day.date.getDay() === 0 || day.date.getDay() === 1) { @@ -117,12 +168,38 @@ export default { computed: { ...mapGetters({ disabled: 'jobs/disabled', - activeUser: 'user' + activeUser: 'user', + allUsers: 'jobs/allUsers', + transactJobs: 'requestJobs/transactJobs' }), userInWorker() { return this.day.worker.find(a => { return a.username === this.activeUser.username }) + }, + specifiedUsers() { + var users = [...this.allUsers] + for (var i in this.day.worker) { + var worker = users.find(a => { + return a.username === this.day.worker[i].username + }) + var index = users.indexOf(worker) + if (worker) users.splice(index, 1) + } + return users + }, + canDelete() { + console.log(this.day.date) + console.log(this.transactJobs) + var transactJob = this.transactJobs.filter(a => { + return a.date - this.day.date === 0 + }) + console.log('filter', transactJob) + var test = transactJob.find(a => { + return a.accepted && a.answerd + }) + console.log('find', test) + return test } }, watch: { diff --git a/src/components/user/UserNavigation.vue b/src/components/user/UserNavigation.vue index ade5ca4..a9aa1b0 100644 --- a/src/components/user/UserNavigation.vue +++ b/src/components/user/UserNavigation.vue @@ -2,7 +2,7 @@ - {{account}} + {{ account }} Home @@ -10,21 +10,29 @@ - {{bank}} + {{ bank }} Finanzübersicht - {{briefcase}} + {{ briefcase }} Dienstübersicht + + + + {{ switchAccount }} + + + Dienstanfragen + - {{account_card_details}} + {{ account_card_details }} Einstellung @@ -32,15 +40,22 @@