Merge pull request 'release/nicolas/v1.3' (#96) from release/nicolas/v1.3 into main
Reviewed-on: Targo/targo_frontend#96
This commit is contained in:
commit
15e60c9ed2
|
|
@ -10,11 +10,13 @@
|
|||
import { useUiStore } from 'src/stores/ui-store';
|
||||
import { useTimesheetStore } from 'src/stores/timesheet-store';
|
||||
import { Shift } from 'src/modules/timesheets/models/shift.models';
|
||||
import { useShiftApi } from 'src/modules/timesheets/composables/use-shift-api';
|
||||
import type { TimesheetDay } from 'src/modules/timesheets/models/timesheet.models';
|
||||
// import { useTimesheetApi } from 'src/modules/timesheets/composables/use-timesheet-api';
|
||||
import { isShiftOverlap } from 'src/modules/timesheets/utils/shift.util';
|
||||
|
||||
const { locale } = useI18n();
|
||||
const uiStore = useUiStore();
|
||||
const shiftApi = useShiftApi();
|
||||
const timesheetStore = useTimesheetStore();
|
||||
|
||||
const day = defineModel<TimesheetDay>({ required: true });
|
||||
|
|
@ -44,6 +46,22 @@
|
|||
else if (locale.value === 'en-CA')
|
||||
return holiday.nameEn;
|
||||
};
|
||||
|
||||
const onTimeFieldBlur = () => {
|
||||
const is_error = isShiftOverlap(day.value.shifts);
|
||||
day.value.shifts.map(shift => shift.has_error = is_error);
|
||||
}
|
||||
|
||||
const deleteCurrentShift = async (shiftId: number, index: number) => {
|
||||
if (shiftId <= 0)
|
||||
day.value.shifts.splice(index, 1);
|
||||
else
|
||||
await shiftApi.deleteShiftById(shiftId);
|
||||
|
||||
if (day.value.shifts.length < 2) {
|
||||
onTimeFieldBlur();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
@ -93,13 +111,14 @@
|
|||
class="q-pa-none transparent"
|
||||
>
|
||||
<div
|
||||
v-for="_shift, shiftIndex in day.shifts"
|
||||
v-for="shift, shiftIndex in day.shifts"
|
||||
:key="shiftIndex"
|
||||
>
|
||||
<ShiftListDayRowMobile
|
||||
v-model:shift="day.shifts[shiftIndex]!"
|
||||
:current-shifts="day.shifts"
|
||||
:has-shift-after="shiftIndex < day.shifts.length - 1"
|
||||
@request-delete="deleteCurrentShift(shift.id, shiftIndex)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@
|
|||
}
|
||||
|
||||
const onClickApplyDailyPreset = async () => {
|
||||
console.log(timesheetId, weekDayIndex, day.value.date, employeeEmail);
|
||||
await timesheetApi.applyPreset(timesheetId, weekDayIndex, day.value.date, employeeEmail);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@
|
|||
>
|
||||
<ShiftListDay
|
||||
v-model="row[dayIndex]!.day"
|
||||
:week-day-index="dayIndex"
|
||||
:week-day-index="rowIndex"
|
||||
:timesheet-id="day.timesheetId"
|
||||
:timesheet-approved="day.isTimesheetApproved"
|
||||
/>
|
||||
|
|
|
|||
|
|
@ -178,7 +178,7 @@ export const useTimesheetStore = defineStore('timesheet', () => {
|
|||
try {
|
||||
let response;
|
||||
|
||||
if (week_day_index && date)
|
||||
if (week_day_index !== undefined && date !== undefined)
|
||||
response = await timesheetService.applyPresetToDay(timesheet_id, week_day_index, date, employeeEmail);
|
||||
else
|
||||
response = await timesheetService.applyPresetToWeek(timesheet_id, employeeEmail);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user