From 4ddbfd9855b9c80f7fadbacb63ec6ea7179fbb58 Mon Sep 17 00:00:00 2001 From: Alexis <35.alexis.pele@gmail.com> Date: Tue, 3 Dec 2024 15:29:06 +0100 Subject: [PATCH] Changed organization for 2 mixed components --- components/calendar/Calendar.vue | 4 +- components/calendar/dialog/DeleteEvent.vue | 45 +++ .../calendar/dialog/QuickCreateEvent.vue | 2 +- components/calendar/dialog/UpdateEvent.vue | 49 +++ components/calendar/form/DeleteEvent.vue | 90 ++--- components/calendar/form/UpdateEvent.vue | 323 ++++++++---------- 6 files changed, 265 insertions(+), 248 deletions(-) create mode 100644 components/calendar/dialog/DeleteEvent.vue create mode 100644 components/calendar/dialog/UpdateEvent.vue diff --git a/components/calendar/Calendar.vue b/components/calendar/Calendar.vue index 2dd6b7f..37c312b 100644 --- a/components/calendar/Calendar.vue +++ b/components/calendar/Calendar.vue @@ -53,8 +53,8 @@ onMounted(() => { - - + + diff --git a/components/calendar/dialog/DeleteEvent.vue b/components/calendar/dialog/DeleteEvent.vue new file mode 100644 index 0000000..1e02d55 --- /dev/null +++ b/components/calendar/dialog/DeleteEvent.vue @@ -0,0 +1,45 @@ + + + diff --git a/components/calendar/dialog/QuickCreateEvent.vue b/components/calendar/dialog/QuickCreateEvent.vue index ac202bd..3e487e7 100644 --- a/components/calendar/dialog/QuickCreateEvent.vue +++ b/components/calendar/dialog/QuickCreateEvent.vue @@ -19,7 +19,7 @@ function toggleDialog() { - + {{ $t("entity.calendar.event.addSingle") }} diff --git a/components/calendar/dialog/UpdateEvent.vue b/components/calendar/dialog/UpdateEvent.vue new file mode 100644 index 0000000..46003e6 --- /dev/null +++ b/components/calendar/dialog/UpdateEvent.vue @@ -0,0 +1,49 @@ + + + diff --git a/components/calendar/form/DeleteEvent.vue b/components/calendar/form/DeleteEvent.vue index 065a4f5..f9e68f0 100644 --- a/components/calendar/form/DeleteEvent.vue +++ b/components/calendar/form/DeleteEvent.vue @@ -3,7 +3,7 @@ import { PhCircleNotch } from "@phosphor-icons/vue"; import { useToast } from "~/components/ui/toast"; const { resetSkeleton, deleteEventFromSkeleton, cancelLatestRequest } = useCalendar() -const { isDeleteEventModalOpen, eventSkeleton, lastActiveEvent } = storeToRefs(useCalendar()) +const { isDeleteEventModalOpen, eventSkeleton } = storeToRefs(useCalendar()) const { toast } = useToast() const { t } = useI18n() @@ -14,13 +14,6 @@ const formErrors = reactive<{ message: string | null }>({ message: null }) -// Watch the popover state -watch(isDeleteEventModalOpen, (hasOpened, _o) => { - if (hasOpened && lastActiveEvent.value) { - eventSkeleton.value = { ...lastActiveEvent.value } - } -}) - async function handleAction(): Promise { if (isLoading.value) return @@ -48,17 +41,6 @@ async function handleAction(): Promise { } } -/** - * Prevents the modal from closing if's still loading - * - * @param e The closing event (can be keydown or click) - */ -function handleClosing(e: Event): void { - if (isLoading.value) { - e.preventDefault() - } -} - /** * Click on the cancel button * @@ -71,53 +53,35 @@ function handleCancel(): void { diff --git a/components/calendar/form/UpdateEvent.vue b/components/calendar/form/UpdateEvent.vue index 1f8615f..716cf4c 100644 --- a/components/calendar/form/UpdateEvent.vue +++ b/components/calendar/form/UpdateEvent.vue @@ -4,7 +4,7 @@ import { useToast } from "~/components/ui/toast"; import type { APIError } from "~/models/Errors"; const { resetSkeleton, updateEventFromSkeleton, cancelLatestRequest } = useCalendar() -const { eventSkeleton, lastActiveEvent, isEditEventModalOpen } = storeToRefs(useCalendar()) +const { eventSkeleton, lastActiveEvent } = storeToRefs(useCalendar()) const { toast } = useToast() const { t } = useI18n() @@ -15,13 +15,6 @@ const formErrors = reactive<{ message: string | null }>({ message: null }) -// Watch the popover state -watch(isEditEventModalOpen, (hasOpened, _o) => { - if (hasOpened && lastActiveEvent.value) { - eventSkeleton.value = { ...lastActiveEvent.value } - } -}) - async function handleAction() { if (isLoading.value) return @@ -44,18 +37,6 @@ async function handleAction() { } finally { resetSkeleton() isLoading.value = false - isEditEventModalOpen.value = false - } -} - -/** - * Prevents the modal from closing if's still loading - * - * @param e The closing event (can be keydown or click) - */ -function handleClosing(e: Event) { - if (isLoading.value) { - e.preventDefault() } } @@ -71,174 +52,152 @@ function handleCancel() {