diff --git a/src/i18n/en-ca/index.ts b/src/i18n/en-ca/index.ts index 33ff984..3bba422 100644 --- a/src/i18n/en-ca/index.ts +++ b/src/i18n/en-ca/index.ts @@ -245,6 +245,8 @@ export default { day: "day", empty: "empty", name: "name", + lock: "", + unlock: "", }, misc: { or: "or", @@ -290,6 +292,8 @@ export default { apply_preset_day: "Apply schedule to day", apply_preset_week: "Apply schedule to week", save_successful: "timesheets saved", + unsaved_changes_title: "You have unsaved changes", + unsaved_changes_caption: "Save before leaving?", nav_button: { calendar_date_picker: "Calendar", current_week: "This week", @@ -349,9 +353,10 @@ export default { type: "Type", types: { PER_DIEM: "Per Diem", - EXPENSES: "expense", + EXPENSES: "reimbursement", MILEAGE: "mileage", ON_CALL: "on-call allowance", + COMMISSION: "Commission", }, }, errors: { diff --git a/src/i18n/fr-ca/index.ts b/src/i18n/fr-ca/index.ts index c2e0e28..7fe01c2 100644 --- a/src/i18n/fr-ca/index.ts +++ b/src/i18n/fr-ca/index.ts @@ -245,6 +245,8 @@ export default { day: "jour", empty: "vide", name: "nom", + lock: "verrouiller", + unlock: "déverrouiller", }, misc: { or: "ou", @@ -290,6 +292,8 @@ export default { apply_preset_day: "Appliquer horaire pour la journée", apply_preset_week: "Appliquer horaire pour la semaine", save_successful: "feuilles de temps enregistrées", + unsaved_changes_title: "Vous avez des changements non-enregistrés", + unsaved_changes_caption: "Sauvegardez avant de quitter?", nav_button: { calendar_date_picker: "Calendrier", current_week: "Semaine actuelle", @@ -349,9 +353,10 @@ export default { type: "Type", types: { PER_DIEM: "Per diem", - EXPENSES: "dépense", + EXPENSES: "remboursement", MILEAGE: "kilométrage", ON_CALL: "Prime de garde", + COMMISSION: "Commission", }, }, errors: { diff --git a/src/modules/timesheet-approval/components/details-dialog.vue b/src/modules/timesheet-approval/components/details-dialog.vue index 3baabb9..1cb8f9f 100644 --- a/src/modules/timesheet-approval/components/details-dialog.vue +++ b/src/modules/timesheet-approval/components/details-dialog.vue @@ -11,25 +11,33 @@ import TimesheetWrapper from 'src/modules/timesheets/components/timesheet-wrapper.vue'; import ExpenseDialogList from 'src/modules/timesheets/components/expense-dialog-list.vue'; import { useTimesheetApprovalApi } from '../composables/use-timesheet-approval-api'; + import { useShiftApi } from 'src/modules/timesheets/composables/use-shift-api'; + + // ========== state ======================================== const { t } = useI18n(); - const timesheet_store = useTimesheetStore(); + const timesheetStore = useTimesheetStore(); const timesheetApprovalApi = useTimesheetApprovalApi(); - const is_dialog_open = ref(false); + const shiftApi = useShiftApi(); + const isDialogOpen = ref(false); - const isApproved = computed(() => timesheet_store.timesheets.every(timesheet => timesheet.is_approved)); + // ========== computed ======================================== + + const isApproved = computed(() => timesheetStore.timesheets.every(timesheet => timesheet.is_approved)); const approveButtonLabel = computed(() => isApproved.value ? - t('timesheet_approvals.table.verified') : - t('timesheet_approvals.table.unverified') + t('shared.label.unlock') : + t('shared.label.lock') ); - const approveButtonIcon = computed(() => isApproved.value ? 'lock' : 'lock_open'); - const hasExpenses = computed(() => timesheet_store.timesheets.some(timesheet => + const approveButtonIcon = computed(() => isApproved.value ? 'las la-lock' : 'las la-unlock'); + const hasExpenses = computed(() => timesheetStore.timesheets.some(timesheet => Object.values(timesheet.weekly_expenses).some(hours => hours > 0)) ); + // ========== methods ======================================== + const onClickApproveAll = async () => { - const employeeEmail = timesheet_store.current_pay_period_overview?.email; - const isApproved = timesheet_store.timesheets.every(timesheet => timesheet.is_approved); + const employeeEmail = timesheetStore.current_pay_period_overview?.email; + const isApproved = timesheetStore.timesheets.every(timesheet => timesheet.is_approved); if (employeeEmail !== undefined && isApproved !== undefined) { await timesheetApprovalApi.toggleTimesheetsApprovalByEmployeeEmail( @@ -38,19 +46,23 @@ ); } } + + const onClickSaveTimesheets = async () => { + await shiftApi.saveShiftChanges(timesheetStore.current_pay_period_overview?.email); + }