From ed8ce9dfec909d247faa6100ee114f8e32cf9a18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jarda=20Kot=C4=9B=C5=A1ovec?= Date: Mon, 8 Jan 2024 11:31:38 +0100 Subject: [PATCH] pkp/pkp-lib# Refine SideModal API, POC for legacy modals --- package-lock.json | 8 +- package.json | 2 +- src/components/Container/Page.vue | 3 + src/components/Modal/AjaxModalWrapper.vue | 37 +++++-- src/components/Modal/Dialog.vue | 96 +++++++++---------- src/components/Modal/LegacyModalManager.vue | 43 +++++++++ src/components/Modal/SideModalBody.vue | 43 ++++++--- src/components/Modal/SideModalBodyAjax.vue | 19 ++++ src/pages/submissions/ColumnActivity.vue | 58 +++++------ .../submissions/SubmissionSummaryModal.vue | 86 ++++++++--------- src/stores/dialogStore.js | 2 + 11 files changed, 243 insertions(+), 154 deletions(-) create mode 100644 src/components/Modal/LegacyModalManager.vue create mode 100644 src/components/Modal/SideModalBodyAjax.vue diff --git a/package-lock.json b/package-lock.json index 4df24fc21..59ebd81ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "storybook": "^7.6.5", - "tailwindcss": "^3.3.3", + "tailwindcss": "3.4", "vite": "^4.4.9", "vitest": "^1.0.4" } @@ -15321,9 +15321,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.3.5", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.3.5.tgz", - "integrity": "sha512-5SEZU4J7pxZgSkv7FP1zY8i2TIAOooNZ1e/OGtxIEv6GltpoiXUqWvLy89+a10qYTB1N5Ifkuw9lqQkN9sscvA==", + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz", + "integrity": "sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==", "dev": true, "dependencies": { "@alloc/quick-lru": "^5.2.0", diff --git a/package.json b/package.json index 44d02504e..610705d4e 100644 --- a/package.json +++ b/package.json @@ -69,7 +69,7 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "storybook": "^7.6.5", - "tailwindcss": "^3.3.3", + "tailwindcss": "3.4", "vite": "^4.4.9", "vitest": "^1.0.4" }, diff --git a/src/components/Container/Page.vue b/src/components/Container/Page.vue index e61c625fa..fa7b41a76 100644 --- a/src/components/Container/Page.vue +++ b/src/components/Container/Page.vue @@ -2,6 +2,8 @@ import {mapStores} from 'pinia'; import Container from '@/components/Container/Container.vue'; import PkpDialog from '@/components/Modal/Dialog.vue'; +import LegacyModalManager from '@/components/Modal/LegacyModalManager.vue'; + import PkpAnnouncer from '@/components/Announcer/Announcer.vue'; // store import {useDialogStore} from '@/stores/dialogStore.js'; @@ -11,6 +13,7 @@ export default { components: { PkpDialog, PkpAnnouncer, + LegacyModalManager, }, extends: Container, data() { diff --git a/src/components/Modal/AjaxModalWrapper.vue b/src/components/Modal/AjaxModalWrapper.vue index 30ca8e2b8..a9ce50e94 100644 --- a/src/components/Modal/AjaxModalWrapper.vue +++ b/src/components/Modal/AjaxModalWrapper.vue @@ -5,9 +5,10 @@ import {ref, onMounted, inject, defineProps} from 'vue'; import {useFetch} from '@/composables/useFetch'; -const props = defineProps({ - contentUrl: { - type: String, +const {options} = defineProps({ + options: { + type: Object, + default: () => {}, }, }); @@ -15,8 +16,9 @@ const contentDiv = ref(null); // eslint-disable-next-line no-unused-vars const pkp = window.pkp; -const {data: assignParticipantPageData, fetch: fetchAssignParticipantPage} = - useFetch(props.contentUrl); +const {data: modalData, fetch: fetchAssignParticipantPage} = useFetch( + options.url, +); const closeModal = inject('closeModal'); const registerCloseCallback = inject('registerCloseCallback'); @@ -48,14 +50,35 @@ function catchInsideClick(e) { } } +function passToBridge(jQueryEvent) { + // If we have an event bridge configured then re-trigger + // the event on the target object. + if (options.eventBridge) { + $('[id^="' + options.eventBridge + '"]').trigger( + jQueryEvent.type, + jQueryEvent.data, + ); + } +} + onMounted(async () => { await fetchAssignParticipantPage(); - if (assignParticipantPageData.value) { - $(contentDiv.value).html(assignParticipantPageData.value.content); + if (modalData.value) { + // TODO CONSIDER REMOVE BINDS ON UNMOUNT + $(contentDiv.value).html(modalData.value.content); $(contentDiv.value).bind('formSubmitted', closeModal); $(contentDiv.value).bind('formCanceled', closeModal); $(contentDiv.value).bind('ajaxHtmlError', closeModal); $(contentDiv.value).bind('modalFinished', closeModal); + + // Publish some otherwise private events triggered + // by nested widgets so that they can be handled by + // the element that opened the modal. + + $(contentDiv.value).bind('redirectRequested', passToBridge); + $(contentDiv.value).bind('dataChanged', passToBridge); + $(contentDiv.value).bind('updateHeader', passToBridge); + $(contentDiv.value).bind('gridRefreshRequested', passToBridge); } }); diff --git a/src/components/Modal/Dialog.vue b/src/components/Modal/Dialog.vue index e97239571..3a92c9960 100644 --- a/src/components/Modal/Dialog.vue +++ b/src/components/Modal/Dialog.vue @@ -1,6 +1,6 @@ - diff --git a/src/components/Modal/LegacyModalManager.vue b/src/components/Modal/LegacyModalManager.vue new file mode 100644 index 000000000..5f4974a95 --- /dev/null +++ b/src/components/Modal/LegacyModalManager.vue @@ -0,0 +1,43 @@ + + + diff --git a/src/components/Modal/SideModalBody.vue b/src/components/Modal/SideModalBody.vue index 0b0aaabf1..aed3cfd48 100644 --- a/src/components/Modal/SideModalBody.vue +++ b/src/components/Modal/SideModalBody.vue @@ -26,12 +26,23 @@
- - +
+
+
+ + + + + + +
+ +
+
+
+ +
+
@@ -39,17 +50,19 @@ + - diff --git a/src/components/Modal/SideModalBodyAjax.vue b/src/components/Modal/SideModalBodyAjax.vue new file mode 100644 index 000000000..52a85f6fc --- /dev/null +++ b/src/components/Modal/SideModalBodyAjax.vue @@ -0,0 +1,19 @@ + + + diff --git a/src/pages/submissions/ColumnActivity.vue b/src/pages/submissions/ColumnActivity.vue index 3ac2d3b9c..bd5349d4d 100644 --- a/src/pages/submissions/ColumnActivity.vue +++ b/src/pages/submissions/ColumnActivity.vue @@ -1,7 +1,7 @@ - diff --git a/src/pages/submissions/SubmissionSummaryModal.vue b/src/pages/submissions/SubmissionSummaryModal.vue index 65b220999..4ea2146de 100644 --- a/src/pages/submissions/SubmissionSummaryModal.vue +++ b/src/pages/submissions/SubmissionSummaryModal.vue @@ -1,50 +1,46 @@