-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I9870 - Consolidate modal rendering stack (#344)
* pkp/pkp-lib#9870 Render legacy modals via Vue.js * pkp/pkp-lib#9870 Update storybook using openSideModal function
- Loading branch information
1 parent
8cf5bec
commit b2ac693
Showing
21 changed files
with
613 additions
and
477 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,56 @@ | ||
<template> | ||
<SideModal close-label="Close" :open="isOpened" @close="close"> | ||
<SideModalBodyAjax :options="options" /> | ||
<SideModal close-label="Close" :open="isOpened2" @close="close2"> | ||
<SideModalBodyAjax :options="options2" /> | ||
<SideModal | ||
close-label="Close" | ||
:open="sideModal1?.opened || false" | ||
:modal-level="1" | ||
@close="() => close(sideModal1?.modalId)" | ||
> | ||
<component :is="component1" v-bind="sideModal1?.props" /> | ||
<SideModal | ||
close-label="Close" | ||
:modal-level="2" | ||
:open="sideModal2?.opened || false" | ||
@close="() => close(sideModal2?.modalId)" | ||
> | ||
<component :is="component2" v-bind="sideModal2?.props" /> | ||
</SideModal> | ||
</SideModal> | ||
<PkpDialog></PkpDialog> | ||
</template> | ||
|
||
<script setup> | ||
import {ref} from 'vue'; | ||
import {computed} from 'vue'; | ||
import {useModalStore} from '@/stores/modalStore'; | ||
import {storeToRefs} from 'pinia'; | ||
import SideModal from '@/components/Modal/SideModal.vue'; | ||
import SideModalBodyAjax from '@/components/Modal/SideModalBodyAjax.vue'; | ||
import LegacyAjax from '@/components/Modal/SideModalBodyLegacyAjax.vue'; | ||
import PkpDialog from '@/components/Modal/Dialog.vue'; | ||
const isOpened = ref(false); | ||
const isOpened2 = ref(false); | ||
const LegacyModals = {LegacyAjax}; | ||
const options = ref(null); | ||
const options2 = ref(null); | ||
const modalStore = useModalStore(); | ||
const {sideModal1, sideModal2} = storeToRefs(useModalStore()); | ||
function close() { | ||
isOpened.value = false; | ||
options.value = null; | ||
} | ||
function close2() { | ||
isOpened2.value = false; | ||
options2.value = null; | ||
} | ||
// pkp.eventBus.$emit('open-tab', tab); | ||
// Component can be either string or actual vue component | ||
const component1 = computed(() => { | ||
if (!sideModal1.value?.component) { | ||
return null; | ||
} | ||
return typeof sideModal1.value.component === 'string' | ||
? LegacyModals[sideModal1.value.component] | ||
: sideModal1.value.component; | ||
}); | ||
/** POC, its disabled for now, it will handle legacy modals in future to improve their accessibility */ | ||
pkp.eventBus.$on('open-modal-vue', (_options) => { | ||
if (options.value) { | ||
options2.value = _options; | ||
isOpened2.value = true; | ||
return; | ||
const component2 = computed(() => { | ||
if (!sideModal2.value?.component) { | ||
return null; | ||
} | ||
options.value = _options; | ||
isOpened.value = true; | ||
return typeof sideModal2.value.component === 'string' | ||
? LegacyModals[sideModal2.value.component] | ||
: sideModal2.value.component; | ||
}); | ||
function close(modalId) { | ||
modalStore.closeSideModal(true, modalId); | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.