From f236ec3a2de10b1806d1224258d119b9afffcac9 Mon Sep 17 00:00:00 2001 From: Massedil Date: Mon, 4 Nov 2024 20:24:58 +0100 Subject: [PATCH] Issue #1571 Refactor to a new date component --- src/components/Event/EventDatePicker.vue | 46 +++++++++++++++++++++++ src/views/Event/EditView.vue | 47 ++++-------------------- 2 files changed, 54 insertions(+), 39 deletions(-) create mode 100644 src/components/Event/EventDatePicker.vue diff --git a/src/components/Event/EventDatePicker.vue b/src/components/Event/EventDatePicker.vue new file mode 100644 index 000000000..741a62c8d --- /dev/null +++ b/src/components/Event/EventDatePicker.vue @@ -0,0 +1,46 @@ + + diff --git a/src/views/Event/EditView.vue b/src/views/Event/EditView.vue index a4b634e68..1dc5f2125 100644 --- a/src/views/Event/EditView.vue +++ b/src/views/Event/EditView.vue @@ -66,12 +66,10 @@ class="items-center" label-for="begins-on-field" > - + > {{ t("Show the time when the event begins") @@ -84,13 +82,11 @@ label-for="ends-on-field" class="items-center" > - + :min="beginsOn" + > {{ t("Show the time when the event ends") }} @@ -654,6 +650,7 @@ import { useHead } from "@/utils/head"; import { useOruga } from "@oruga-ui/oruga-next"; import sortBy from "lodash/sortBy"; import { escapeHtml } from "@/utils/html"; +import EventDatePicker from "@/components/Event/EventDatePicker.vue"; const DEFAULT_LIMIT_NUMBER_OF_PLACES = 10; @@ -1205,34 +1202,6 @@ const isEventModified = computed((): boolean => { const beginsOn = ref(new Date()); const endsOn = ref(new Date()); -const beginsOnComponentDateTime = computed({ - get() { - // UTC to local - const localDate = new Date( - beginsOn.value.getTime() - beginsOn.value.getTimezoneOffset() * 60000 - ); - return localDate.toISOString().slice(0, 16); // Format to 'YYYY-MM-DDTHH:MM' - }, - set(value) { - // Local timezone - beginsOn.value = new Date(value); - }, -}); - -const endsOnComponentDateTime = computed({ - get() { - // UTC to local - const localDate = new Date( - endsOn.value.getTime() - endsOn.value.getTimezoneOffset() * 60000 - ); - return localDate.toISOString().slice(0, 16); // Format to 'YYYY-MM-DDTHH:MM' - }, - set(value) { - // Local timezone - endsOn.value = new Date(value); - }, -}); - const updateEventDateRelatedToTimezone = () => { // update event.value.beginsOn taking care of timezone const dateBeginsOn = new Date(beginsOn.value.getTime());