@@ -11,13 +11,14 @@ import UserCommentReportDetail from '@/pages/userComments/UserCommentReportDetai
11
11
const Actions = {
12
12
COMMENT_DELETE : 'commentDelete' ,
13
13
REPORT_DELETE : 'reportDelete' ,
14
+ COMMENT_PUBLICATION_VIEW : 'commentPublicationView' ,
14
15
} ;
15
16
export const useUserCommentStore = defineComponentStore (
16
17
'userCommentStore' ,
17
18
( props ) => {
18
19
const { t} = useLocalize ( ) ;
19
20
20
- const selectedCommentStatus = ref ( 'approved' ) ;
21
+ const activeTab = ref ( 'approved' ) ;
21
22
const itemsPerPage = props . itemsPerPage ;
22
23
const currentCommentReportsPage = ref ( 1 ) ;
23
24
const currentCommentsPage = ref ( 1 ) ;
@@ -82,7 +83,7 @@ export const useUserCommentStore = defineComponentStore(
82
83
83
84
const commentsUrl = computed ( ( ) => {
84
85
let queryParams = '' ;
85
- switch ( selectedCommentStatus . value ) {
86
+ switch ( activeTab . value ) {
86
87
case 'approved' :
87
88
queryParams += `?isApproved=${ true } ` ;
88
89
break ;
@@ -224,6 +225,11 @@ export const useUserCommentStore = defineComponentStore(
224
225
*/
225
226
function getCommentItemActions ( comment ) {
226
227
const actions = [
228
+ {
229
+ label : 'View publication' ,
230
+ icon : 'View' ,
231
+ name : Actions . COMMENT_PUBLICATION_VIEW ,
232
+ } ,
227
233
{
228
234
label : t ( 'manager.userComment.deleteComment' ) ,
229
235
icon : 'Cancel' ,
@@ -294,17 +300,17 @@ export const useUserCommentStore = defineComponentStore(
294
300
}
295
301
296
302
/**
297
- * Handle the change of the dropdown selection for comment status.
298
- * @param {string } value - The selected comment status value .
303
+ * Handle the change of the tab selection for comment status.
304
+ * @param {string } tabId - The selected tab Id .
299
305
*/
300
- async function onDropDownChanged ( value ) {
306
+ function onTabUpdate ( tabId ) {
301
307
// Track the current page for each comment table.
302
308
// This is useful when the user is switching between tables for different comments(approved, reported, needs approval).
303
309
// Instead of always starting from page 1 of the paginated table, we start from the last visited page for that comment table, defaulting to page 1 if there is no previous history.
304
- const pageToStartFrom = trackedCommentPaginationPageHistory [ value ] ?? 1 ;
305
- trackedCommentPaginationPageHistory [ selectedCommentStatus . value ] =
310
+ const pageToStartFrom = trackedCommentPaginationPageHistory [ tabId ] ?? 1 ;
311
+ trackedCommentPaginationPageHistory [ activeTab . value ] =
306
312
currentCommentsPage . value ;
307
- selectedCommentStatus . value = value ;
313
+ activeTab . value = tabId ;
308
314
309
315
setCurrentCommentsPage ( pageToStartFrom ) ;
310
316
}
@@ -355,19 +361,19 @@ export const useUserCommentStore = defineComponentStore(
355
361
/**
356
362
* Get the options for comment types(approved, needs approval, reported), to select from to view comments
357
363
*/
358
- const commentTypeOptions = computed ( ( ) => {
364
+ const commentTabOptions = computed ( ( ) => {
359
365
return [
360
366
{
361
367
label : t ( 'manager.userComment.approved' ) ,
362
- value : 'approved' ,
368
+ id : 'approved' ,
363
369
} ,
364
370
{
365
371
label : t ( 'manager.userComment.needsApproval' ) ,
366
- value : 'needsApproval' ,
372
+ id : 'needsApproval' ,
367
373
} ,
368
374
{
369
375
label : t ( 'manager.userComment.reported' ) ,
370
- value : 'reported' ,
376
+ id : 'reported' ,
371
377
} ,
372
378
] ;
373
379
} ) ;
@@ -402,29 +408,38 @@ export const useUserCommentStore = defineComponentStore(
402
408
return status . join ( ', ' ) ;
403
409
}
404
410
411
+ /**
412
+ * Open the publication a given comment was made for.
413
+ * @param comment
414
+ */
415
+ function commentPublicationView ( comment ) {
416
+ window . open ( comment . publicationUrl , '_blank' ) ;
417
+ }
418
+
405
419
return {
406
420
reportDelete,
407
421
toggleCommentApproval,
408
422
getCommentItemActions,
409
423
openCommentDetail,
410
424
setCurrentCommentsPage,
411
- onDropDownChanged,
412
425
commentDelete,
413
426
getReportItemActions,
414
427
setCurrentReportsPage,
415
428
openReport,
416
429
getCommentStatusText,
430
+ commentPublicationView,
431
+ onTabUpdate,
417
432
commentApprovalOptions,
418
- selectedCommentStatus,
419
433
itemsPerPage,
420
434
commentsPageColumns,
421
435
comments,
422
436
commentsPagination,
423
437
currentCommentReports,
424
438
currentCommentReportsPagination,
425
439
reportsTableColumns,
426
- commentTypeOptions ,
440
+ commentTabOptions ,
427
441
isCommentsLoading,
442
+ activeTab,
428
443
} ;
429
444
} ,
430
445
) ;
0 commit comments