-
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.
pkp/pkp-lib#9453 Initial Boilerplate
- Loading branch information
1 parent
c991ce1
commit aeaa864
Showing
8 changed files
with
150 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {ref, computed} from 'vue'; | ||
/** | ||
* Helper to construct url for API interactions | ||
* Query params are not included, as correct query param serialisation | ||
* is covered in useFetch | ||
*/ | ||
|
||
export function useApiUrl(_path) { | ||
if (typeof pkp === 'undefined' || !pkp?.context?.apiBaseUrl) { | ||
throw new Error('pkp.context.apiBaseUrl is not configured'); | ||
} | ||
|
||
// normalise to be ref even if its not passed as ref | ||
const path = ref(_path); | ||
|
||
const apiUrl = computed(() => `${pkp.context.apiBaseUrl}${path.value}`); | ||
|
||
return {apiUrl}; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<template> | ||
<div class="mb-4 space-x-2"> | ||
<PkpButton | ||
v-for="review in store.reviewRoundHistories" | ||
:key="review.reviewRoundId" | ||
@click="store.openRoundHistoryModal(review)" | ||
> | ||
{{ t('submission.round', {round: review.reviewRoundNumber}) }} | ||
</PkpButton> | ||
</div> | ||
<SideModal | ||
:open="store.isRoundHistoryModalOpened" | ||
@close="store.closeRoundHistoryModal" | ||
> | ||
<RoundHistoryModal | ||
v-bind="store.roundHistoryModalProps" | ||
></RoundHistoryModal> | ||
</SideModal> | ||
</template> | ||
|
||
<script setup> | ||
import {defineProps} from 'vue'; | ||
import SideModal from '@/components/Modal/SideModal.vue'; | ||
import RoundHistoryModal from './RoundHistoryModal.vue'; | ||
import {useTranslation} from '@/composables/useTranslation'; | ||
import {useReviewerSubmissionPageStore} from './reviewerSubmissionPageStore'; | ||
const {t} = useTranslation(); | ||
const props = defineProps({ | ||
reviewRoundHistories: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const store = useReviewerSubmissionPageStore(props); | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<template> | ||
<SideModalBody> | ||
<template #title>Title TODO</template> | ||
<div class="p-4"> | ||
<div class="bg-lightest p-5"> | ||
Here goes all metadata, submissionId: {{ store.submissionId }}, roundId: | ||
{{ store.reviewRoundId }} | ||
|
||
<div v-if="store.submission"> | ||
<div class="text-xl-bold"> | ||
{{ localize(store.submission.publications[0].title) }} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</SideModalBody> | ||
</template> | ||
|
||
<script setup> | ||
import {defineProps} from 'vue'; | ||
import SideModalBody from '@/components/Modal/SideModalBody.vue'; | ||
import {useTranslation} from '@/composables/useTranslation'; | ||
import {useRoundHistoryModalStore} from './roundHistoryModalStore'; | ||
const props = defineProps({ | ||
submissionId: {type: Number, required: true}, | ||
reviewRoundId: {type: Number, required: true}, | ||
}); | ||
const {localize} = useTranslation(); | ||
const store = useRoundHistoryModalStore(props); | ||
</script> |
26 changes: 26 additions & 0 deletions
26
src/pages/reviewerSubmission/reviewerSubmissionPageStore.js
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import {ref} from 'vue'; | ||
import {defineComponentStore} from '@/utils/defineComponentStore'; | ||
|
||
export const useReviewerSubmissionPageStore = defineComponentStore( | ||
'reviewerSubmissionPage', | ||
(pageInitConfig) => { | ||
const isRoundHistoryModalOpened = ref(false); | ||
const roundHistoryModalProps = ref(null); | ||
function openRoundHistoryModal({submissionId, reviewRoundId}) { | ||
roundHistoryModalProps.value = {submissionId, reviewRoundId}; | ||
isRoundHistoryModalOpened.value = true; | ||
} | ||
function closeRoundHistoryModal() { | ||
isRoundHistoryModalOpened.value = false; | ||
roundHistoryModalProps.value = null; | ||
} | ||
|
||
return { | ||
isRoundHistoryModalOpened, | ||
openRoundHistoryModal, | ||
closeRoundHistoryModal, | ||
roundHistoryModalProps, | ||
reviewRoundHistories: pageInitConfig.reviewRoundHistories, | ||
}; | ||
}, | ||
); |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import {defineComponentStore} from '@/utils/defineComponentStore'; | ||
|
||
import {useApiUrl} from '@/composables/useApiUrl'; | ||
import {useFetch} from '@/composables/useFetch'; | ||
|
||
export const useRoundHistoryModalStore = defineComponentStore( | ||
'roundHistoryModal', | ||
(props) => { | ||
const {apiUrl: submissionApiUrl} = useApiUrl( | ||
`submissions/${props.submissionId}`, | ||
); | ||
const {fetch: fetchSubmission, data: submission} = | ||
useFetch(submissionApiUrl); | ||
|
||
fetchSubmission(); | ||
|
||
return { | ||
submission, | ||
submissionId: props.submissionId, | ||
reviewRoundId: props.reviewRoundId, | ||
}; | ||
}, | ||
); |