Skip to content

Commit ee0ed7c

Browse files
pkp/pkp-lib#11327 Improvments from the CR feedback
1 parent 908fc44 commit ee0ed7c

15 files changed

+41
-168
lines changed

src/frontend/components/PkpButton/PkpButton.vue

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,4 @@
44
</BaseButton>
55
</template>
66

7-
<script setup>
8-
import BaseButton from './BaseButton.vue';
9-
</script>
10-
117
<style></style>

src/frontend/components/PkpComments/PkpCommentReportDialog.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,3 @@
55
<BaseCommentReportDialogReasonInput></BaseCommentReportDialogReasonInput>
66
</BaseCommentReportDialog>
77
</template>
8-
<script setup>
9-
import BaseCommentReportDialog from './base/BaseCommentReportDialog.vue';
10-
import BaseCommentReportDialogAuthor from './base/BaseCommentReportDialogAuthor.vue';
11-
import BaseCommentReportDialogCommentText from './base/BaseCommentReportDialogCommentText.vue';
12-
import BaseCommentReportDialogReasonInput from './base/BaseCommentReportDialogReasonInput.vue';
13-
</script>

src/frontend/components/PkpComments/PkpComments.vue

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<BaseCommentsMessages>
1919
<template #default="messageProps">
2020
<BaseCommentsMessage v-bind="messageProps">
21-
<BaseCommentsNotificationMessageApproved />
21+
<BaseCommentsNotificationMessageNeedsApproval />
2222
<div class="BaseCommentsMessageHeader">
2323
<BaseCommentsMessageDate></BaseCommentsMessageDate>
2424
<BaseCommentsMessageActions></BaseCommentsMessageActions>
@@ -38,32 +38,3 @@
3838
</BaseCommentsVersions>
3939
</BaseComments>
4040
</template>
41-
42-
<script setup>
43-
import BaseComments from './base/BaseComments.vue';
44-
import BaseCommentsVersions from './base/BaseCommentsVersions.vue';
45-
import BaseCommentsVersion from './base/BaseCommentsVersion.vue';
46-
import BaseCommentsNew from './base/BaseCommentsNew.vue';
47-
import BaseCommentsNewInput from './base/BaseCommentsNewInput.vue';
48-
import BaseCommentsNewSubmit from './base/BaseCommentsNewSubmit.vue';
49-
import BaseCommentsVersionHeader from './base/BaseCommentsVersionHeader.vue';
50-
import BaseCommentsVersionHeaderTrigger from './base/BaseCommentsVersionHeaderTrigger.vue';
51-
import BaseCommentsVersionHeaderLabel from './base/BaseCommentsVersionHeaderLabel.vue';
52-
import BaseCommentsVersionHeaderChevron from './base/BaseCommentsVersionHeaderChevron.vue';
53-
54-
import BaseCommentsVersionContent from './base/BaseCommentsVersionContent.vue';
55-
56-
import BaseCommentsLogInto from './base/BaseCommentsLogInto.vue';
57-
import BaseCommentsMessages from './base/BaseCommentsMessages.vue';
58-
import BaseCommentsNotificationNotLatest from './base/BaseCommentsNotificationNotLatest.vue';
59-
import BaseCommentsMessage from './base/BaseCommentsMessage.vue';
60-
import BaseCommentsNotificationMessageApproved from './base/BaseCommentsNotificationMessageApproved.vue';
61-
import BaseCommentsMessageDate from './base/BaseCommentsMessageDate.vue';
62-
import BaseCommentsMessageActions from './base/BaseCommentsMessageActions.vue';
63-
import BaseCommentsMessageBody from './base/BaseCommentsMessageBody.vue';
64-
import BaseCommentsMessageAuthor from './base/BaseCommentsMessageAuthor.vue';
65-
import BaseCommentsMessageAuthorName from './base/BaseCommentsMessageAuthorName.vue';
66-
import BaseCommentsMessageAuthorOrcid from './base/BaseCommentsMessageAuthorOrcid.vue';
67-
import BaseCommentsMessageAuthorAffiliation from './base/BaseCommentsMessageAuthorAffiliation.vue';
68-
</script>
69-
<style></style>

src/frontend/components/PkpComments/PkpScrollToComments.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,3 @@
44
<BaseScrollToCommentsLogInto />
55
</BaseScrollToComments>
66
</template>
7-
8-
<script setup>
9-
import BaseScrollToComments from './base/BaseScrollToComments.vue';
10-
import BaseScrollToCommentsAllComments from './base/BaseScrollToCommentsAllComments.vue';
11-
import BaseScrollToCommentsLogInto from './base/BaseScrollToCommentsLogInto.vue';
12-
</script>

src/frontend/components/PkpComments/base/BaseCommentsMessageAuthorOrcid.vue

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
<template>
2-
<span class="BaseCommentsMessageAuthorOrcid">
2+
<a
3+
v-if="messageProps.message.userOrcidDisplayValue"
4+
class="BaseCommentsMessageAuthorOrcid"
5+
:href="messageProps.message.userOrcidDisplayValue"
6+
>
7+
<PkpIcon
8+
:icon="
9+
messageProps.message.isUserOrcidAuthenticated
10+
? 'Orcid'
11+
: 'OrcidUnauthenticated'
12+
"
13+
/>
314
{{ messageProps.message.userOrcidDisplayValue }}
4-
</span>
15+
</a>
516
</template>
617
<script setup>
718
import {inject} from 'vue';

src/frontend/components/PkpComments/base/BaseCommentsNewInput.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@
44
:placeholder="t('userComment.addYourComment')"
55
:label="t('userComment.addYourComment')"
66
:is-label-sr-only="true"
7-
:model-value="commentsStore.getCommentText(publicationId)"
8-
@update:model-value="commentsStore.updateCommentText(publicationId, $event)"
7+
:model-value="commentsStore.commentText"
8+
@update:model-value="commentsStore.updateCommentText($event)"
99
/>
1010
</template>
1111
<script setup>
1212
import {usePkpLocalize} from '@/frontend/composables/usePkpLocalize';
13-
import {inject} from 'vue';
1413
import {usePkpCommentsStore} from '../usePkpCommentsStore';
1514
1615
const {t} = usePkpLocalize();
17-
const publicationId = inject('publicationId');
1816
const commentsStore = usePkpCommentsStore();
1917
</script>

src/frontend/components/PkpComments/base/BaseCommentsNewSubmit.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
class="BaseCommentsNewSubmit"
44
@click="commentsStore.addComment(publicationId)"
55
>
6-
Submit
6+
{{ t('form.submit') }}
77
</pkp-button>
88
</template>
99

1010
<script setup>
1111
import {inject} from 'vue';
1212
import {usePkpCommentsStore} from '../usePkpCommentsStore';
13+
import {usePkpLocalize} from '@/frontend/composables/usePkpLocalize';
1314
15+
const {t} = usePkpLocalize();
1416
const publicationId = inject('publicationId');
1517
const commentsStore = usePkpCommentsStore();
1618
</script>

src/frontend/components/PkpComments/base/BaseCommentsNotificationMessageApproved.vue renamed to src/frontend/components/PkpComments/base/BaseCommentsNotificationMessageNeedsApproval.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
messageProps.message.userId === commentsStore.getCurrentUser().id &&
66
!messageProps.message.isApproved
77
"
8-
class="BaseCommentsNotificationMessageApproved"
8+
class="BaseCommentsNotificationMessageNeedsApproval"
99
>
1010
<PkpIcon icon="Help" class="pkpUserCommentsList__item--helpIcon"></PkpIcon>
1111
{{ t('userComment.awaitingApprovalNotice') }}

src/frontend/components/PkpComments/usePkpCommentsStore.js

Lines changed: 17 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
1414
const loginUrl = ref('');
1515
const commentsCountPerPublication = ref({});
1616
const allCommentsCount = ref(0);
17+
const commentText = ref('');
18+
const reportText = ref('');
1719

1820
// Version-specific state stored in a Map
1921
const versionStates = ref({});
@@ -64,8 +66,6 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
6466
showMoreCommentsCount: 0,
6567
currentPage: 0,
6668
pageCount: 0,
67-
commentText: '',
68-
reportText: '',
6969
});
7070
}
7171
return versionStates.value[publicationId];
@@ -77,14 +77,9 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
7777
return getVersionState(publicationId).comments;
7878
}
7979

80-
// Get comment text for a specific publication
81-
function getCommentText(publicationId) {
82-
return getVersionState(publicationId).commentText;
83-
}
84-
85-
// Update comment text for a specific publication
86-
function updateCommentText(publicationId, value) {
87-
getVersionState(publicationId).commentText = value;
80+
// Update comment text
81+
function updateCommentText(value) {
82+
commentText.value = value;
8883
}
8984

9085
// Get version label for a specific publication
@@ -149,34 +144,29 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
149144

150145
// Add a comment for a specific publication
151146
async function addComment(publicationId) {
152-
const versionState = getVersionState(publicationId);
153-
154147
if (
155148
!isLatestPublication(publicationId) ||
156149
!getCurrentUser() ||
157-
!versionState.commentText.trim()
150+
!commentText.value.trim()
158151
) {
159152
return;
160153
}
161154

162-
const {openDialogNetworkError} = usePkpModal();
163155
const {apiUrl} = useUrl('comments');
164156

165157
const {fetch: submitComment, isSuccess} = usePkpFetch(apiUrl, {
166158
method: 'POST',
167159
body: {
168160
publicationId: publicationId,
169-
commentText: versionState.commentText,
161+
commentText: commentText.value,
170162
},
171163
});
172164

173165
await submitComment();
174166

175167
if (isSuccess.value) {
176-
versionState.commentText = '';
168+
commentText.value = '';
177169
await loadComments(publicationId, true);
178-
} else {
179-
openDialogNetworkError();
180170
}
181171
}
182172

@@ -255,32 +245,31 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
255245
function commentReport(publicationId, comment) {
256246
const {t} = usePkpLocalize();
257247
const {openDialog} = usePkpModal();
258-
const versionState = getVersionState(publicationId);
259-
versionState.reportText = '';
248+
reportText.value = '';
260249

261250
openDialog({
262251
title: t('userComment.reportComment'),
263252
comment,
264-
bodyComponent: pkp.registry.getComponent('PkpCommentReportDialog'),
253+
bodyComponent: 'PkpCommentReportDialog',
265254
bodyProps: {
266255
comment,
267-
reportText: versionState.reportText,
256+
reportText: reportText,
268257
'onUpdate:reportText': (value) => {
269-
versionState.reportText = value;
258+
reportText.value = value;
270259
},
271260
},
272261
actions: [
273262
{
274263
label: t('form.submit'),
275264
isPrimary: true,
276265
callback: async (close) => {
277-
if (versionState.reportText.trim() === '') {
266+
if (reportText.value.trim() === '') {
278267
return;
279268
}
280269
await performCommentReport(
281270
publicationId,
282271
comment,
283-
versionState.reportText,
272+
reportText.value,
284273
);
285274
close();
286275
},
@@ -334,6 +323,9 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
334323
loginUrl,
335324
commentsCountPerPublication,
336325
allCommentsCount,
326+
commentText,
327+
reportText,
328+
updateCommentText,
337329

338330
// Global actions
339331
initialize,
@@ -342,14 +334,12 @@ export const usePkpCommentsStore = defineStore('pkpComments', () => {
342334

343335
// Version-specific getters
344336
getComments,
345-
getCommentText,
346337
getVersionLabel,
347338
getPublication,
348339
isLatestPublication,
349340
hasMoreComments,
350341

351342
// Version-specific actions
352-
updateCommentText,
353343
loadComments,
354344
addComment,
355345
getCommentActions,

src/frontend/components/PkpDialog/PkpDialog.vue

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,3 @@
88
</BaseDialogContent>
99
</BaseDialog>
1010
</template>
11-
12-
<script setup>
13-
import BaseDialog from './base/BaseDialog.vue';
14-
import BaseDialogContent from './base/BaseDialogContent.vue';
15-
import BaseDialogOverlay from './base/BaseDialogOverlay.vue';
16-
import BaseDialogTitle from './base/BaseDialogTitle.vue';
17-
import BaseDialogBody from './base/BaseDialogBody.vue';
18-
import BaseDialogActionButtons from './base/BaseDialogActionButtons.vue';
19-
</script>

0 commit comments

Comments
 (0)