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 { useUiStore } from 'src/stores/ui-store';
|
||||||
import { useTimesheetStore } from 'src/stores/timesheet-store';
|
import { useTimesheetStore } from 'src/stores/timesheet-store';
|
||||||
import { Shift } from 'src/modules/timesheets/models/shift.models';
|
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 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 { locale } = useI18n();
|
||||||
const uiStore = useUiStore();
|
const uiStore = useUiStore();
|
||||||
|
const shiftApi = useShiftApi();
|
||||||
const timesheetStore = useTimesheetStore();
|
const timesheetStore = useTimesheetStore();
|
||||||
|
|
||||||
const day = defineModel<TimesheetDay>({ required: true });
|
const day = defineModel<TimesheetDay>({ required: true });
|
||||||
|
|
@ -44,6 +46,22 @@
|
||||||
else if (locale.value === 'en-CA')
|
else if (locale.value === 'en-CA')
|
||||||
return holiday.nameEn;
|
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>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -93,13 +111,14 @@
|
||||||
class="q-pa-none transparent"
|
class="q-pa-none transparent"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="_shift, shiftIndex in day.shifts"
|
v-for="shift, shiftIndex in day.shifts"
|
||||||
:key="shiftIndex"
|
:key="shiftIndex"
|
||||||
>
|
>
|
||||||
<ShiftListDayRowMobile
|
<ShiftListDayRowMobile
|
||||||
v-model:shift="day.shifts[shiftIndex]!"
|
v-model:shift="day.shifts[shiftIndex]!"
|
||||||
:current-shifts="day.shifts"
|
:current-shifts="day.shifts"
|
||||||
:has-shift-after="shiftIndex < day.shifts.length - 1"
|
:has-shift-after="shiftIndex < day.shifts.length - 1"
|
||||||
|
@request-delete="deleteCurrentShift(shift.id, shiftIndex)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClickApplyDailyPreset = async () => {
|
const onClickApplyDailyPreset = async () => {
|
||||||
|
console.log(timesheetId, weekDayIndex, day.value.date, employeeEmail);
|
||||||
await timesheetApi.applyPreset(timesheetId, weekDayIndex, day.value.date, employeeEmail);
|
await timesheetApi.applyPreset(timesheetId, weekDayIndex, day.value.date, employeeEmail);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@
|
||||||
>
|
>
|
||||||
<ShiftListDay
|
<ShiftListDay
|
||||||
v-model="row[dayIndex]!.day"
|
v-model="row[dayIndex]!.day"
|
||||||
:week-day-index="dayIndex"
|
:week-day-index="rowIndex"
|
||||||
:timesheet-id="day.timesheetId"
|
:timesheet-id="day.timesheetId"
|
||||||
:timesheet-approved="day.isTimesheetApproved"
|
:timesheet-approved="day.isTimesheetApproved"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -178,7 +178,7 @@ export const useTimesheetStore = defineStore('timesheet', () => {
|
||||||
try {
|
try {
|
||||||
let response;
|
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);
|
response = await timesheetService.applyPresetToDay(timesheet_id, week_day_index, date, employeeEmail);
|
||||||
else
|
else
|
||||||
response = await timesheetService.applyPresetToWeek(timesheet_id, employeeEmail);
|
response = await timesheetService.applyPresetToWeek(timesheet_id, employeeEmail);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user