Skip to content

Commit aeaa864

Browse files
pkp/pkp-lib#9453 Initial Boilerplate
1 parent c991ce1 commit aeaa864

File tree

8 files changed

+150
-10
lines changed

8 files changed

+150
-10
lines changed

Diff for: package-lock.json

+5-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
"msw-storybook-addon": "^2.0.0--canary.122.b3ed3b1.0",
6666
"postcss": "^8.4.27",
6767
"prettier": "^3.0.2",
68-
"prettier-plugin-tailwindcss": "^0.5.6",
68+
"prettier-plugin-tailwindcss": "^0.5.11",
6969
"react": "^18.2.0",
7070
"react-dom": "^18.2.0",
7171
"storybook": "^7.6.5",

Diff for: src/components/Container/Page.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@ import PkpDialog from '@/components/Modal/Dialog.vue';
44
import ModalManager from '@/components/Modal/ModalManager.vue';
55
66
import PkpAnnouncer from '@/components/Announcer/Announcer.vue';
7-
// store
7+
import ReviewerSubmissionPage from '@/pages/reviewerSubmission/ReviewerSubmissionPage.vue';
88
99
export default {
1010
name: 'Page',
1111
components: {
1212
PkpDialog,
1313
PkpAnnouncer,
1414
ModalManager,
15+
ReviewerSubmissionPage,
1516
},
1617
extends: Container,
1718
data() {

Diff for: src/composables/useApiUrl.js

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import {ref, computed} from 'vue';
2+
/**
3+
* Helper to construct url for API interactions
4+
* Query params are not included, as correct query param serialisation
5+
* is covered in useFetch
6+
*/
7+
8+
export function useApiUrl(_path) {
9+
if (typeof pkp === 'undefined' || !pkp?.context?.apiBaseUrl) {
10+
throw new Error('pkp.context.apiBaseUrl is not configured');
11+
}
12+
13+
// normalise to be ref even if its not passed as ref
14+
const path = ref(_path);
15+
16+
const apiUrl = computed(() => `${pkp.context.apiBaseUrl}${path.value}`);
17+
18+
return {apiUrl};
19+
}
+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<template>
2+
<div class="mb-4 space-x-2">
3+
<PkpButton
4+
v-for="review in store.reviewRoundHistories"
5+
:key="review.reviewRoundId"
6+
@click="store.openRoundHistoryModal(review)"
7+
>
8+
{{ t('submission.round', {round: review.reviewRoundNumber}) }}
9+
</PkpButton>
10+
</div>
11+
<SideModal
12+
:open="store.isRoundHistoryModalOpened"
13+
@close="store.closeRoundHistoryModal"
14+
>
15+
<RoundHistoryModal
16+
v-bind="store.roundHistoryModalProps"
17+
></RoundHistoryModal>
18+
</SideModal>
19+
</template>
20+
21+
<script setup>
22+
import {defineProps} from 'vue';
23+
24+
import SideModal from '@/components/Modal/SideModal.vue';
25+
import RoundHistoryModal from './RoundHistoryModal.vue';
26+
27+
import {useTranslation} from '@/composables/useTranslation';
28+
29+
import {useReviewerSubmissionPageStore} from './reviewerSubmissionPageStore';
30+
31+
const {t} = useTranslation();
32+
33+
const props = defineProps({
34+
reviewRoundHistories: {
35+
type: Object,
36+
required: true,
37+
},
38+
});
39+
40+
const store = useReviewerSubmissionPageStore(props);
41+
</script>

Diff for: src/pages/reviewerSubmission/RoundHistoryModal.vue

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<template>
2+
<SideModalBody>
3+
<template #title>Title TODO</template>
4+
<div class="p-4">
5+
<div class="bg-lightest p-5">
6+
Here goes all metadata, submissionId: {{ store.submissionId }}, roundId:
7+
{{ store.reviewRoundId }}
8+
9+
<div v-if="store.submission">
10+
<div class="text-xl-bold">
11+
{{ localize(store.submission.publications[0].title) }}
12+
</div>
13+
</div>
14+
</div>
15+
</div>
16+
</SideModalBody>
17+
</template>
18+
19+
<script setup>
20+
import {defineProps} from 'vue';
21+
import SideModalBody from '@/components/Modal/SideModalBody.vue';
22+
import {useTranslation} from '@/composables/useTranslation';
23+
import {useRoundHistoryModalStore} from './roundHistoryModalStore';
24+
25+
const props = defineProps({
26+
submissionId: {type: Number, required: true},
27+
reviewRoundId: {type: Number, required: true},
28+
});
29+
30+
const {localize} = useTranslation();
31+
32+
const store = useRoundHistoryModalStore(props);
33+
</script>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import {ref} from 'vue';
2+
import {defineComponentStore} from '@/utils/defineComponentStore';
3+
4+
export const useReviewerSubmissionPageStore = defineComponentStore(
5+
'reviewerSubmissionPage',
6+
(pageInitConfig) => {
7+
const isRoundHistoryModalOpened = ref(false);
8+
const roundHistoryModalProps = ref(null);
9+
function openRoundHistoryModal({submissionId, reviewRoundId}) {
10+
roundHistoryModalProps.value = {submissionId, reviewRoundId};
11+
isRoundHistoryModalOpened.value = true;
12+
}
13+
function closeRoundHistoryModal() {
14+
isRoundHistoryModalOpened.value = false;
15+
roundHistoryModalProps.value = null;
16+
}
17+
18+
return {
19+
isRoundHistoryModalOpened,
20+
openRoundHistoryModal,
21+
closeRoundHistoryModal,
22+
roundHistoryModalProps,
23+
reviewRoundHistories: pageInitConfig.reviewRoundHistories,
24+
};
25+
},
26+
);
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import {defineComponentStore} from '@/utils/defineComponentStore';
2+
3+
import {useApiUrl} from '@/composables/useApiUrl';
4+
import {useFetch} from '@/composables/useFetch';
5+
6+
export const useRoundHistoryModalStore = defineComponentStore(
7+
'roundHistoryModal',
8+
(props) => {
9+
const {apiUrl: submissionApiUrl} = useApiUrl(
10+
`submissions/${props.submissionId}`,
11+
);
12+
const {fetch: fetchSubmission, data: submission} =
13+
useFetch(submissionApiUrl);
14+
15+
fetchSubmission();
16+
17+
return {
18+
submission,
19+
submissionId: props.submissionId,
20+
reviewRoundId: props.reviewRoundId,
21+
};
22+
},
23+
);

0 commit comments

Comments
 (0)