From 4281736a6d5f876cc1f27128fe6808a8367f4bd0 Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Sun, 8 Dec 2024 01:25:51 +0100 Subject: [PATCH] automatically set the project billable default in time entry create modal --- .../ui/src/TimeEntry/TimeEntryCreateModal.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/js/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue b/resources/js/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue index 8420495e..d70949ff 100644 --- a/resources/js/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue +++ b/resources/js/packages/ui/src/TimeEntry/TimeEntryCreateModal.vue @@ -70,6 +70,19 @@ const timeEntryDefaultValues = { const timeEntry = ref({ ...timeEntryDefaultValues }); +watch( + () => timeEntry.value.project_id, + (value) => { + if (value) { + // check if project is billable by default and set billable accordingly + const project = props.projects.find((p) => p.id === value); + if (project) { + timeEntry.value.billable = project.is_billable; + } + } + } +); + const localStart = ref( getLocalizedDayJs(timeEntryDefaultValues.start).format() );