fix(approvals): add preset to possible changes that can be applied to employee timesheet from approval page
This commit is contained in:
parent
e8d9e9c4dc
commit
80e07bfff2
|
|
@ -15,7 +15,7 @@
|
||||||
|
|
||||||
// ================== State ==================
|
// ================== State ==================
|
||||||
|
|
||||||
const { day, dense = false, approved = false, holiday = false } = defineProps<{
|
const { timesheetId, weekDayIndex, day, dense = false, approved = false, holiday = false } = defineProps<{
|
||||||
timesheetId: number;
|
timesheetId: number;
|
||||||
weekDayIndex: number;
|
weekDayIndex: number;
|
||||||
day: TimesheetDay;
|
day: TimesheetDay;
|
||||||
|
|
@ -59,6 +59,10 @@
|
||||||
else
|
else
|
||||||
shift_error_message.value = undefined;
|
shift_error_message.value = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onClickApplyDailyPreset = async () => {
|
||||||
|
await timesheet_api.applyPreset(timesheetId, weekDayIndex, day.date, employeeEmail);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
@ -83,7 +87,7 @@
|
||||||
:label="$t('timesheet.apply_preset_day')"
|
:label="$t('timesheet.apply_preset_day')"
|
||||||
class="text-uppercase text-weight-bold text-accent q-mx-lg q-py-none rounded-5"
|
class="text-uppercase text-weight-bold text-accent q-mx-lg q-py-none rounded-5"
|
||||||
style="opacity: 0.6;"
|
style="opacity: 0.6;"
|
||||||
@click.stop="timesheet_api.applyPreset(timesheetId, weekDayIndex, day.date)"
|
@click.stop="onClickApplyDailyPreset"
|
||||||
>
|
>
|
||||||
<q-icon
|
<q-icon
|
||||||
name="las la-calendar-day"
|
name="las la-calendar-day"
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
import ShiftListDateWidget from 'src/modules/timesheets/components/shift-list-date-widget.vue';
|
import ShiftListDateWidget from 'src/modules/timesheets/components/shift-list-date-widget.vue';
|
||||||
|
|
||||||
import { date, useQuasar } from 'quasar';
|
import { date, useQuasar } from 'quasar';
|
||||||
import { ref, computed, watch, onMounted } from 'vue';
|
import { ref, computed, watch, onMounted, inject } from 'vue';
|
||||||
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';
|
||||||
|
|
@ -31,6 +31,7 @@
|
||||||
const mobile_animation_direction = ref('fadeInLeft');
|
const mobile_animation_direction = ref('fadeInLeft');
|
||||||
const currentDayComponent = ref<HTMLElement[] | null>(null);
|
const currentDayComponent = ref<HTMLElement[] | null>(null);
|
||||||
const currentDayComponentWatcher = ref(currentDayComponent);
|
const currentDayComponentWatcher = ref(currentDayComponent);
|
||||||
|
const employeeEmail = inject<string>('employeeEmail');
|
||||||
|
|
||||||
const animation_style = computed(() => ui_store.is_mobile_mode ? mobile_animation_direction.value : 'fadeInDown');
|
const animation_style = computed(() => ui_store.is_mobile_mode ? mobile_animation_direction.value : 'fadeInDown');
|
||||||
|
|
||||||
|
|
@ -70,6 +71,10 @@
|
||||||
return holiday.nameEn;
|
return holiday.nameEn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onClickApplyWeeklyPreset = async (timesheet_id: number) => {
|
||||||
|
await timesheet_api.applyPreset(timesheet_id, undefined, undefined, employeeEmail);
|
||||||
|
}
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await timesheet_store.getCurrentFederalHolidays();
|
await timesheet_store.getCurrentFederalHolidays();
|
||||||
});
|
});
|
||||||
|
|
@ -103,7 +108,7 @@
|
||||||
dense
|
dense
|
||||||
:label="$t('timesheet.apply_preset_week')"
|
:label="$t('timesheet.apply_preset_week')"
|
||||||
class="col-auto text-uppercase text-weight-bold text-accent q-mx-lg q-py-none rounded-5"
|
class="col-auto text-uppercase text-weight-bold text-accent q-mx-lg q-py-none rounded-5"
|
||||||
@click="timesheet_api.applyPreset(timesheet.timesheet_id)"
|
@click="onClickApplyWeeklyPreset(timesheet.timesheet_id)"
|
||||||
>
|
>
|
||||||
<q-icon
|
<q-icon
|
||||||
name="las la-calendar-week"
|
name="las la-calendar-week"
|
||||||
|
|
|
||||||
|
|
@ -31,19 +31,19 @@ export const useTimesheetApi = () => {
|
||||||
timesheet_store.is_loading = false;
|
timesheet_store.is_loading = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const applyPreset = async (timesheet_id: number, week_day_index?: number, date?: string) => {
|
const applyPreset = async (timesheet_id: number, week_day_index?: number, date?: string, employeeEmail?: string) => {
|
||||||
if (timesheet_store.timesheets.map(timesheet => timesheet.timesheet_id).includes(timesheet_id)) {
|
if (timesheet_store.timesheets.map(timesheet => timesheet.timesheet_id).includes(timesheet_id)) {
|
||||||
timesheet_store.is_loading = true;
|
timesheet_store.is_loading = true;
|
||||||
try {
|
try {
|
||||||
let response;
|
let response;
|
||||||
|
|
||||||
if (week_day_index && date)
|
if (week_day_index && date)
|
||||||
response = await timesheetService.applyPresetToDay(timesheet_id, week_day_index, date);
|
response = await timesheetService.applyPresetToDay(timesheet_id, week_day_index, date, employeeEmail);
|
||||||
else
|
else
|
||||||
response = await timesheetService.applyPresetToWeek(timesheet_id);
|
response = await timesheetService.applyPresetToWeek(timesheet_id, employeeEmail);
|
||||||
|
|
||||||
if (response.success)
|
if (response.success)
|
||||||
await timesheet_store.getTimesheetsByOptionalEmployeeEmail();
|
await timesheet_store.getTimesheetsByOptionalEmployeeEmail(employeeEmail);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error applying weekly timesheet: ', error);
|
console.error('Error applying weekly timesheet: ', error);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,22 @@ export const timesheetService = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
applyPresetToWeek: async (timesheet_id: number): Promise<BackendResponse<boolean>> => {
|
applyPresetToWeek: async (timesheet_id: number, employeeEmail?: string): Promise<BackendResponse<boolean>> => {
|
||||||
const response = await api.post<BackendResponse<boolean>>(`schedule-presets/apply-preset`, { timesheet_id });
|
if (employeeEmail) {
|
||||||
|
const response = await api.post<BackendResponse<boolean>>(`schedule-presets/apply-preset/${employeeEmail}`, { timesheet_id });
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await api.post<BackendResponse<boolean>>('schedule-presets/apply-preset', { timesheet_id });
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
|
|
||||||
applyPresetToDay: async (timesheet_id: number, week_day_index: number, date: string): Promise<BackendResponse<boolean>> => {
|
applyPresetToDay: async (timesheet_id: number, week_day_index: number, date: string, employeeEmail?: string): Promise<BackendResponse<boolean>> => {
|
||||||
|
if (employeeEmail) {
|
||||||
|
const response = await api.post<BackendResponse<boolean>>(`schedule-presets/apply-day-preset/${employeeEmail}`, { timesheet_id, week_day_index, date });
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
|
|
||||||
const response = await api.post<BackendResponse<boolean>>('schedule-presets/apply-day-preset', { timesheet_id, week_day_index, date });
|
const response = await api.post<BackendResponse<boolean>>('schedule-presets/apply-day-preset', { timesheet_id, week_day_index, date });
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user