From 003ac898617a030de32b71e9fe96b29a7416fec1 Mon Sep 17 00:00:00 2001 From: nicoMaz <139277771+nicomaz@users.noreply.github.com> Date: Mon, 20 May 2024 18:47:12 +0100 Subject: [PATCH 1/8] feat: add modal store --- frontend/stores/modals.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 frontend/stores/modals.ts diff --git a/frontend/stores/modals.ts b/frontend/stores/modals.ts new file mode 100644 index 000000000..d47fe7f22 --- /dev/null +++ b/frontend/stores/modals.ts @@ -0,0 +1,27 @@ +import { defineStore } from "pinia"; + +interface Modal { + isOpen: boolean; +} + +export const useModals = defineStore("modals", { + state: () => ({ + modals: {} as Record, + }), + + actions: { + openModal(modalName: string) { + const modals = this.modals; + for (const key in modals) { + modals[key].isOpen = false; + } + modals[modalName] = { isOpen: true }; + }, + + closeModal(modalName: string) { + if (this.modals[modalName]) { + this.modals[modalName].isOpen = false; + } + }, + }, +}); From 3f8bde9bc3d53c9386a089e0afaa484f182eb0b4 Mon Sep 17 00:00:00 2001 From: nicoMaz <139277771+nicomaz@users.noreply.github.com> Date: Mon, 20 May 2024 18:47:51 +0100 Subject: [PATCH 2/8] feat: refactor to use modal store --- frontend/pages/docs/get-active.vue | 8 ++++++-- frontend/pages/docs/get-organized.vue | 8 ++++++-- frontend/pages/docs/grow-organization.vue | 8 ++++++-- frontend/pages/events/[id]/about.vue | 8 ++++++-- frontend/pages/organizations/[id]/about.vue | 9 ++++++--- frontend/pages/organizations/[id]/groups/[id]/about.vue | 8 ++++++-- 6 files changed, 36 insertions(+), 13 deletions(-) diff --git a/frontend/pages/docs/get-active.vue b/frontend/pages/docs/get-active.vue index a59634582..590c30414 100644 --- a/frontend/pages/docs/get-active.vue +++ b/frontend/pages/docs/get-active.vue @@ -130,13 +130,17 @@ diff --git a/frontend/pages/docs/get-organized.vue b/frontend/pages/docs/get-organized.vue index 32b54ec0d..fefc382a3 100644 --- a/frontend/pages/docs/get-organized.vue +++ b/frontend/pages/docs/get-organized.vue @@ -103,13 +103,17 @@ diff --git a/frontend/pages/docs/grow-organization.vue b/frontend/pages/docs/grow-organization.vue index d982a875e..396349e1c 100644 --- a/frontend/pages/docs/grow-organization.vue +++ b/frontend/pages/docs/grow-organization.vue @@ -110,13 +110,17 @@ diff --git a/frontend/pages/events/[id]/about.vue b/frontend/pages/events/[id]/about.vue index cb8ecb67a..66f714a4f 100644 --- a/frontend/pages/events/[id]/about.vue +++ b/frontend/pages/events/[id]/about.vue @@ -139,13 +139,17 @@ onMounted(() => { handleResize(); // initial check }); +const modals = useModals(); +const modalName = "ModalSharePage"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/pages/organizations/[id]/about.vue b/frontend/pages/organizations/[id]/about.vue index 5a4426633..cdd62f3f2 100644 --- a/frontend/pages/organizations/[id]/about.vue +++ b/frontend/pages/organizations/[id]/about.vue @@ -202,14 +202,17 @@ const testDiscussionInput: DiscussionInput = { // upVotes: 6, // downVotes: 4, // }); - +const modals = useModals(); +const modalName = "ModalSharePage"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/pages/organizations/[id]/groups/[id]/about.vue b/frontend/pages/organizations/[id]/groups/[id]/about.vue index 52e1296b3..91bcb9daa 100644 --- a/frontend/pages/organizations/[id]/groups/[id]/about.vue +++ b/frontend/pages/organizations/[id]/groups/[id]/about.vue @@ -125,13 +125,17 @@ onMounted(() => { updateShareBtnLabel(); }); +const modals = useModals(); +const modalName = "ModalSharePage"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; From 30e2633a33f752e942ac8ea7ae0d855f63775ade Mon Sep 17 00:00:00 2001 From: nicoMaz <139277771+nicomaz@users.noreply.github.com> Date: Mon, 20 May 2024 18:47:56 +0100 Subject: [PATCH 3/8] feat: refactor to use modal store --- frontend/app.vue | 10 ++++++--- frontend/components/card/CardAbout.vue | 9 +++++--- frontend/components/card/CardDetails.vue | 8 +++++-- frontend/components/card/CardGetInvolved.vue | 8 +++++-- .../icon/IconOrganizationStatus.vue | 9 +++++--- .../image-carousel/MediaImageCarousel.vue | 9 +++++--- .../image-carousel/MediaImageCarouselFull.vue | 8 +++++-- frontend/components/modal/ModalBase.vue | 21 +++++++++--------- .../components/modal/ModalCommandPalette.vue | 22 +++++++++++-------- .../components/modal/ModalEditPageText.vue | 17 ++++++++------ .../modal/ModalMediaImageCarousel.vue | 17 ++++++++------ .../modal/ModalOrganizationStatus.vue | 17 ++++++++------ frontend/components/modal/ModalSharePage.vue | 18 +++++++-------- .../components/modal/image/ModalImage.vue | 17 ++++++++------ .../components/modal/qr-code/ModalQRCode.vue | 14 +++++------- .../modal/qr-code/ModalQRCodeBtn.vue | 8 +++++-- .../modal/upload-images/ModalUploadImages.vue | 13 +++++------ .../sidebar/left/SidebarLeftIndex.vue | 9 +++++--- .../TooltipMenuSearchResultEvent.vue | 8 +++++-- .../TooltipMenuSearchResultGroup.vue | 8 +++++-- .../TooltipMenuSearchResultOrganization.vue | 8 +++++-- .../TooltipMenuSearchResultResource.vue | 8 +++++-- .../TooltipMenuSearchResultUser.vue | 8 +++++-- 23 files changed, 168 insertions(+), 106 deletions(-) diff --git a/frontend/app.vue b/frontend/app.vue index 765340146..bd91bc4cd 100644 --- a/frontend/app.vue +++ b/frontend/app.vue @@ -14,6 +14,7 @@ @@ -28,15 +29,18 @@ useHead({ return titleChunk ? `${titleChunk} • activist` : "activist"; }, }); - +const modals = useModals(); +const modalName = "generalModal"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; const { isMacOS } = useDevice(); diff --git a/frontend/components/card/CardAbout.vue b/frontend/components/card/CardAbout.vue index f572d9041..f61fff4d6 100644 --- a/frontend/components/card/CardAbout.vue +++ b/frontend/components/card/CardAbout.vue @@ -242,14 +242,17 @@ const expandText = ref(false); function expand_reduce_text() { expandText.value = !expandText.value; } - +const modals = useModals(); +const modalName = "ModalEditPageText"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/components/card/CardDetails.vue b/frontend/components/card/CardDetails.vue index d0784750d..c442395cc 100644 --- a/frontend/components/card/CardDetails.vue +++ b/frontend/components/card/CardDetails.vue @@ -59,13 +59,17 @@ const { descriptionText } = useDescriptionText(props); const { getInvolvedText } = useGetInvolvedText(props); const { getInvolvedURL } = useGetInvolvedURL(props); +const modals = useModals(); +const modalName = "ModalEditPageText"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/components/card/CardGetInvolved.vue b/frontend/components/card/CardGetInvolved.vue index 831e3f32f..bc530da7a 100644 --- a/frontend/components/card/CardGetInvolved.vue +++ b/frontend/components/card/CardGetInvolved.vue @@ -157,13 +157,17 @@ const { getInvolvedURL } = useGetInvolvedURL(props); const { id } = useRoute().params; +const modals = useModals(); +const modalName = "ModalEditPageText"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/components/icon/IconOrganizationStatus.vue b/frontend/components/icon/IconOrganizationStatus.vue index f4545c52a..74123e418 100644 --- a/frontend/components/icon/IconOrganizationStatus.vue +++ b/frontend/components/icon/IconOrganizationStatus.vue @@ -74,14 +74,17 @@ defineProps<{ status: number; organization: Organization; }>(); - +const modals = useModals(); +const modalName = "ModalOrganizationStatus"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/components/media/image-carousel/MediaImageCarousel.vue b/frontend/components/media/image-carousel/MediaImageCarousel.vue index f96f997ff..7b529d320 100644 --- a/frontend/components/media/image-carousel/MediaImageCarousel.vue +++ b/frontend/components/media/image-carousel/MediaImageCarousel.vue @@ -50,15 +50,18 @@ const imageUrls = [ `/images/content_pages/art/get_organized_${imageColor}.png`, `/images/content_pages/art/grow_organization_${imageColor}.png`, ]; - +const modals = useModals(); +const modalName = "ModalUploadImages"; const modalIsOpen = ref(false); function openModal() { - modalIsOpen.value = true; + modals.openModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; } const handleCloseModal = () => { - modalIsOpen.value = false; + modals.closeModal(modalName); + modalIsOpen.value = modals.modals[modalName].isOpen; }; diff --git a/frontend/components/media/image-carousel/MediaImageCarouselFull.vue b/frontend/components/media/image-carousel/MediaImageCarouselFull.vue index 0eda91177..f26b890f5 100644 --- a/frontend/components/media/image-carousel/MediaImageCarouselFull.vue +++ b/frontend/components/media/image-carousel/MediaImageCarouselFull.vue @@ -16,13 +16,17 @@ diff --git a/frontend/components/modal/ModalBase.vue b/frontend/components/modal/ModalBase.vue index 56dcd2d9c..e625c6a2c 100644 --- a/frontend/components/modal/ModalBase.vue +++ b/frontend/components/modal/ModalBase.vue @@ -1,9 +1,5 @@