Skip to content

Commit 92233db

Browse files
authored
Merge pull request #1926 from NicoPennec/main
Fix days off on the timesheet tab.
2 parents 4280847 + b931d36 commit 92233db

File tree

8 files changed

+84
-84
lines changed

8 files changed

+84
-84
lines changed

package-lock.json

Lines changed: 43 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@fullcalendar/multimonth": "6.1.19",
2727
"@fullcalendar/vue3": "6.1.19",
2828
"@google/model-viewer": "4.1.0",
29-
"@sentry/vue": "10.31.0",
29+
"@sentry/vue": "10.32.0",
3030
"@unhead/vue": "2.0.19",
3131
"@vuepic/vue-datepicker": "11.0.3",
3232
"async": "3.2.6",
@@ -40,7 +40,7 @@
4040
"exceljs": "4.4.0",
4141
"fabric": "cgwire/fabric.js",
4242
"file-saver": "2.0.5",
43-
"lucide-vue-next": "0.561.0",
43+
"lucide-vue-next": "0.562.0",
4444
"marked": "17.0.1",
4545
"marked-emoji": "2.0.2",
4646
"moment": "2.30.1",

src/components/lists/TimesheetList.vue

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
:can-delete="false"
77
:min-date="disabledDates.to"
88
:max-date="disabledDates.from"
9+
utc
910
:with-margin="false"
1011
v-model="selectedDate"
1112
/>
@@ -201,7 +202,7 @@
201202
"
202203
:is-error="isDayOffError"
203204
:error-text="dayOffTextError"
204-
@confirm="$emit('unset-day-off')"
205+
@confirm="$emit('unset-day-off', personDayOff)"
205206
@cancel="closeUnsetDayOffModal"
206207
/>
207208
</div>
@@ -259,6 +260,10 @@ export default {
259260
default: false,
260261
type: Boolean
261262
},
263+
daysOff: {
264+
default: () => [],
265+
type: Array
266+
},
262267
dayOffError: {
263268
default: false,
264269
type: [String, Boolean]
@@ -316,13 +321,24 @@ export default {
316321
...mapGetters([
317322
'isCurrentUserArtist',
318323
'organisation',
319-
'personDayOff',
320-
'personIsDayOff',
321324
'productionMap',
322325
'taskTypeMap',
323326
'user'
324327
]),
325328
329+
personDayOff() {
330+
const selectedDate = moment(this.selectedDate).format('YYYY-MM-DD')
331+
return this.daysOff.find(
332+
dayOff =>
333+
selectedDate >= dayOff.date &&
334+
selectedDate <= (dayOff.end_date || dayOff.date)
335+
)
336+
},
337+
338+
personIsDayOff() {
339+
return Boolean(this.personDayOff)
340+
},
341+
326342
displayedTasks() {
327343
return this.tasks.slice(0, this.page * (PAGE_SIZE / 2))
328344
},

src/components/pages/Person.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
:done-tasks="loggableDoneTasks"
110110
:is-loading="isTasksLoading"
111111
:is-error="isTasksLoadingError"
112+
:days-off="daysOff"
112113
:day-off-error="dayOffError"
113114
:time-spent-map="personTimeSpentMap"
114115
:time-spent-total="personTimeSpentTotal"
@@ -688,6 +689,11 @@ export default {
688689
this.isTasksLoadingError = true
689690
}
690691
692+
this.loadDaysOff()
693+
},
694+
695+
async loadDaysOff() {
696+
const personId = this.person.id
691697
try {
692698
this.daysOff = await this.loadAggregatedPersonDaysOff({ personId })
693699
} catch (error) {
@@ -784,16 +790,18 @@ export default {
784790
} catch (error) {
785791
this.dayOffError = error.body?.message || true
786792
}
793+
await this.loadDaysOff()
787794
},
788795
789-
async onUnsetDayOff() {
796+
async onUnsetDayOff(dayOff) {
790797
this.dayOffError = false
791798
try {
792-
await this.unsetDayOff()
799+
await this.unsetDayOff(dayOff)
793800
this.$refs['timesheet-list']?.closeUnsetDayOffModal()
794801
} catch (error) {
795802
this.dayOffError = error.body?.message || true
796803
}
804+
await this.loadDaysOff()
797805
},
798806
799807
saveTaskScheduleItem(item) {

src/components/pages/Todos.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
:done-tasks="loggableDoneTasks"
110110
:is-loading="loading.timesheets || isTodosLoading"
111111
:is-error="isTodosLoadingError"
112+
:days-off="daysOff"
112113
:day-off-error="dayOffError"
113114
:time-spent-map="timeSpentMap"
114115
:time-spent-total="timeSpentTotal"
@@ -514,7 +515,7 @@ export default {
514515
await this.loadData(true)
515516
},
516517
517-
async onUnsetDayOff(dayOff = null) {
518+
async onUnsetDayOff(dayOff) {
518519
this.dayOffError = false
519520
try {
520521
await this.unsetDayOff(dayOff)

src/store/modules/people.js

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import {
3434
CLEAR_SELECTED_TASKS,
3535
SET_TIME_SPENT,
3636
PEOPLE_TIMESHEET_LOADED,
37-
PERSON_SET_DAY_OFF,
3837
PERSON_LOAD_TIME_SPENTS_END,
3938
SET_ORGANISATION,
4039
SET_PERSON_TASKS_SCROLL_POSITION,
@@ -209,8 +208,6 @@ const getters = {
209208
timesheet: state => state.timesheet,
210209
personTimeSpentMap: state => state.personTimeSpentMap,
211210
personTimeSpentTotal: state => state.personTimeSpentTotal,
212-
personDayOff: state => state.personDayOff,
213-
personIsDayOff: state => Boolean(state.personDayOff?.id),
214211
dayOffMap: state => state.dayOffMap,
215212
daysOff: state => state.daysOff
216213
}
@@ -359,13 +356,11 @@ const actions = {
359356
})
360357
commit(LOAD_PERSON_DONE_TASKS_END, [])
361358

362-
const [tasks, timeSpents, dayOff] = await Promise.all([
359+
const [tasks, timeSpents] = await Promise.all([
363360
peopleApi.getPersonTasks(personId).catch(() => []),
364-
peopleApi.getTimeSpents(personId, date),
365-
peopleApi.getDayOff(personId, date)
361+
peopleApi.getTimeSpents(personId, date)
366362
])
367363
commit(PERSON_LOAD_TIME_SPENTS_END, timeSpents || [])
368-
commit(PERSON_SET_DAY_OFF, dayOff || {})
369364
commit(LOAD_PERSON_TASKS_END, {
370365
personId,
371366
tasks,
@@ -471,30 +466,14 @@ const actions = {
471466
commit(SET_TIME_SPENT, timeSpent)
472467
},
473468

474-
async setDayOff({ commit }, { id, personId, date, end_date, description }) {
475-
let dayOff
476-
if (id) {
477-
dayOff = await peopleApi.updateDayOff(
478-
id,
479-
personId,
480-
date,
481-
end_date,
482-
description
483-
)
484-
} else {
485-
dayOff = await peopleApi.createDayOff(
486-
personId,
487-
date,
488-
end_date,
489-
description
490-
)
491-
}
492-
commit(PERSON_SET_DAY_OFF, dayOff)
469+
setDayOff(_, { id, personId, date, end_date, description }) {
470+
return id
471+
? peopleApi.updateDayOff(id, personId, date, end_date, description)
472+
: peopleApi.createDayOff(personId, date, end_date, description)
493473
},
494474

495-
async unsetDayOff({ commit }, dayOff = null) {
496-
await peopleApi.deleteDayOff(dayOff || state.personDayOff)
497-
commit(PERSON_SET_DAY_OFF, {})
475+
async unsetDayOff(_, dayOff) {
476+
await peopleApi.deleteDayOff(dayOff)
498477
},
499478

500479
setPersonTasksScrollPosition({ commit }, scrollPosition) {
@@ -852,10 +831,6 @@ const mutations = {
852831
) / 60
853832
},
854833

855-
[PERSON_SET_DAY_OFF](state, dayOff) {
856-
state.personDayOff = dayOff
857-
},
858-
859834
[PEOPLE_SET_DAYS_OFF](state, daysOff) {
860835
state.daysOff = daysOff
861836
},

src/store/modules/user.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import {
3737
USER_LOAD_DONE_TASKS_END,
3838
USER_LOAD_TIME_SPENTS_END,
3939
REGISTER_USER_TASKS,
40-
PERSON_SET_DAY_OFF,
4140
SET_TODOS_SEARCH,
4241
LOAD_USER_FILTERS_END,
4342
LOAD_USER_FILTERS_ERROR,
@@ -281,11 +280,9 @@ const actions = {
281280
try {
282281
const tasks = await peopleApi.loadTodos()
283282
const timeSpents = await peopleApi.loadTimeSpents(date)
284-
const dayOff = await peopleApi.getDayOff(state.user.id, date)
285283
commit(USER_LOAD_TODOS_END, { tasks, userFilters, taskTypeMap })
286284
commit(REGISTER_USER_TASKS, { tasks })
287285
commit(USER_LOAD_TIME_SPENTS_END, timeSpents)
288-
commit(PERSON_SET_DAY_OFF, dayOff)
289286
return tasks
290287
} catch (err) {
291288
console.error(err)

0 commit comments

Comments
 (0)