Skip to content

Commit 2b591e8

Browse files
MrRob100ewhanson
authored andcommitted
Download reviews form built in vue calling controller route
1 parent a0ab8c6 commit 2b591e8

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

src/components/Container/Container.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ListPanel from '@/components/ListPanel/ListPanel.vue';
33
import PkpForm from '@/components/Form/Form.vue';
44
import SelectReviewerListPanel from '@/components/ListPanel/users/SelectReviewerListPanel.vue';
55
import SubmissionsListPanel from '@/components/ListPanel/submissions/SubmissionsListPanel.vue';
6+
import ReviewerManagerReadReviewModal from '@/managers/ReviewerManager/ReviewerManagerReadReviewModal.vue';
67
78
export default {
89
name: 'Container',
@@ -11,6 +12,7 @@ export default {
1112
PkpForm,
1213
SelectReviewerListPanel,
1314
SubmissionsListPanel,
15+
ReviewerManagerReadReviewModal,
1416
},
1517
data() {
1618
return {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<template>
2+
<div class="flex">
3+
<div class="flex-grow">
4+
<h2>{{ title }}</h2>
5+
</div>
6+
<div class="flex-shrink-0">
7+
<DropdownActions
8+
:actions="exportOptions"
9+
:label="t('editor.review.download')"
10+
@action="handleExport"
11+
/>
12+
</div>
13+
</div>
14+
</template>
15+
<script setup>
16+
import DropdownActions from '@/components/DropdownActions/DropdownActions.vue';
17+
import {useLocalize} from '@/composables/useLocalize';
18+
import {useApiUrl} from '@/composables/useApiUrl';
19+
import {useFetch} from '@/composables/useFetch';
20+
const props = defineProps({
21+
title: {type: String, required: true},
22+
submissionId: {type: String, required: true},
23+
reviewRoundId: {type: String, required: true},
24+
reviewAssignmentId: {type: String, required: true},
25+
submissionStageId: {type: String, required: true},
26+
});
27+
28+
const {t} = useLocalize();
29+
const exportOptions = [
30+
{
31+
label: `${t('editor.review.authorOnly')} (PDF)`,
32+
name: 'authorPdf',
33+
},
34+
{
35+
label: `${t('editor.review.authorOnly')} (XML)`,
36+
name: 'authorXml',
37+
},
38+
{
39+
label: `${t('editor.review.allSections')} (PDF)`,
40+
name: 'editorPdf',
41+
},
42+
{
43+
label: `${t('editor.review.allSections')} (XML)`,
44+
name: 'editorXml',
45+
},
46+
];
47+
48+
async function handleExport(name) {
49+
let op;
50+
let authorFriendly;
51+
switch (name) {
52+
case 'authorPdf':
53+
op = 'export-pdf';
54+
authorFriendly = 1;
55+
break;
56+
case 'authorXml':
57+
op = 'export-xml';
58+
authorFriendly = 1;
59+
break;
60+
case 'editorPdf':
61+
op = 'export-pdf';
62+
authorFriendly = 0;
63+
break;
64+
case 'editorXml':
65+
op = 'export-xml';
66+
authorFriendly = 0;
67+
break;
68+
}
69+
70+
const {apiUrl} = useApiUrl(
71+
`reviews/${props.submissionId}/${props.reviewAssignmentId}/${op}?authorFriendly=${authorFriendly}`,
72+
);
73+
74+
const {data, fetch, isSuccess, validationError} = useFetch(apiUrl, {
75+
method: 'GET',
76+
expectValidationError: true,
77+
});
78+
await fetch();
79+
if (validationError.value) {
80+
pkp.eventBus.$emit('notify', validationError.value.error, 'warning');
81+
} else if (isSuccess.value) {
82+
const anchor = document.createElement('a');
83+
anchor.href = useApiUrl(
84+
`reviews/${props.submissionId}/exports/${data.value.temporaryFileId}`,
85+
).apiUrl.value;
86+
document.body.appendChild(anchor);
87+
anchor.click();
88+
document.body.removeChild(anchor);
89+
}
90+
}
91+
</script>

0 commit comments

Comments
 (0)