From b057fb2784e91623da54a3e63a11dd4906eebfd3 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 6 Feb 2024 18:46:15 +0100 Subject: [PATCH] fix(reminders): set reminder date on datepicker when editing a reminder Setting an actual reminder date (not a relative one) flowed only from the component to the outside when setting it. When editing it, the reminder date would not be populated, causing the datepicker date to stay at the current date. --- .../tasks/partials/reminder-detail.vue | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/components/tasks/partials/reminder-detail.vue b/src/components/tasks/partials/reminder-detail.vue index 89703a905..3ffd5296d 100644 --- a/src/components/tasks/partials/reminder-detail.vue +++ b/src/components/tasks/partials/reminder-detail.vue @@ -46,7 +46,7 @@ (() => [ {reminder: null, relativePeriod: -1 * SECONDS_A_DAY * 7, relativeTo: defaultRelativeTo}, {reminder: null, relativePeriod: -1 * SECONDS_A_DAY * 30, relativeTo: defaultRelativeTo}, ]) -const reminderDate = ref(null) +const reminderDate = ref(null) type availableForms = null | 'relative' | 'absolute' @@ -135,7 +135,17 @@ const reminderText = computed(() => { watch( () => modelValue, (newReminder) => { - reminder.value = newReminder || new TaskReminderModel() + if(newReminder) { + reminder.value = newReminder + + if(newReminder.relativeTo === null) { + reminderDate.value = new Date(newReminder.reminder) + } + + return + } + + reminder.value = new TaskReminderModel() }, {immediate: true}, ) @@ -148,7 +158,7 @@ function updateData() { } } -function setReminderDate(close) { +function setReminderDateAndClose(close) { reminder.value.reminder = reminderDate.value === null ? null : new Date(reminderDate.value)