11<template >
22 <div class =" h3 mb-4" >{{ $t("Comments") }}</div >
3- <CommentsFilterForm class =" mb-4" v-model =" filters" />
3+ <div class =" d-flex align-items-center mb-4" >
4+ <CommentsFilterForm class =" flex-grow-1" v-model =" filters" />
5+ <div class =" d-flex gap-2" >
6+ <button class =" btn btn-success" :disabled =" selectedRows.length == 0" @click =" handleStatusChangeAll('CONFIRMED')" >
7+ {{ $t("ConfirmAll") }}
8+ </button >
9+ <button class =" btn btn-danger" :disabled =" selectedRows.length == 0" @click =" handleStatusChangeAll('REJECTED')" >
10+ {{ $t("RejectAll") }}
11+ </button >
12+ </div >
13+ </div >
414 <VTableServer :items =" comments" :itemsLength =" comments.length" :is-loading =" commentsIsLoading" >
15+ <VColumn :header =" 'Select'" field =" id" >
16+ <template #body =" { item } " >
17+ <input
18+ type =" checkbox"
19+ class =" form-check-input"
20+ :checked =" selectedRows.includes(item.id)"
21+ v-model =" selectedRows"
22+ :value =" item.id"
23+ :id =" item.id"
24+ />
25+ </template >
26+ </VColumn >
527 <VColumn :header =" $t('Id')" field =" id" >
628 <template #body =" { item } " >
729 <span v-html =" highlightText(item.id)" />
1537 <VColumn :header =" $t('Email')" field =" email" />
1638 <VColumn :header =" $t('Post')" field =" postId" >
1739 <template #body =" { item } " >
18- <button class =" btn btn-sm btn-outline-info" title =" View Related Post"
19- @click =" handleFetchPost(item.postId)" >
40+ <button class =" btn btn-sm btn-outline-info" title =" View Related Post" @click =" handleFetchPost(item.postId)" >
2041 <i class =" bi-eye" />
2142 </button >
2243 </template >
4566 <button class =" btn btn-danger btn-sm" @click =" handleRejectComment(item)" >
4667 <i class =" bi-ban" />
4768 </button >
48- <button class =" btn btn-success btn-sm z-3" data-bs-toggle =" tooltip" data-bs-placement =" top" @click =" handleConfirmComment(item.id)"
49- data-bs-title =" Tooltip on top" >
69+ <button
70+ class =" btn btn-success btn-sm z-3"
71+ data-bs-toggle =" tooltip"
72+ data-bs-placement =" top"
73+ @click =" handleConfirmComment(item.id)"
74+ data-bs-title =" Tooltip on top"
75+ >
5076 <i class =" bi-check-circle" />
5177 </button >
5278 </div >
6591 </template >
6692 <div >
6793 <h3 class =" text-danger" >Attention</h3 >
68- <p >
69- Changed Data can not be restored
70- </p >
71- <div >
72- Post with id ({{ rejectComment?.comment?.id }}) will be rejected!!
73- </div >
94+ <p >Changed Data can not be restored</p >
95+ <div >Post with id ({{ rejectComment?.comment?.id }}) will be rejected!!</div >
7496 </div >
7597 <template v-slot :footer >
76- <button class =" btn btn-danger" @click =" handleConfirmRejection($refs.modal.hide)" >
77- Yes
78- </button >
79- <button class =" btn btn-secondary" @click =" $refs.modal.hide()" >
80- Cancel
81- </button >
98+ <button class =" btn btn-danger" @click =" handleConfirmRejection($refs.modal.hide)" >Yes</button >
99+ <button class =" btn btn-secondary" @click =" $refs.modal.hide()" >Cancel</button >
82100 </template >
83101 </VModal >
84102</template >
@@ -99,9 +117,9 @@ import { computed, reactive, ref, watch } from "vue";
99117export default {
100118 name: " CommentsView" ,
101119 setup () {
102- const { showToast } = useToast ()
120+ const { showToast } = useToast ();
103121
104- const { comments , commentsIsLoading , fetchComments , changeStatus: changeCommentStatus } = useFetchComments ();
122+ const { comments , commentsIsLoading , fetchComments , changeStatus: changeCommentStatus } = useFetchComments ();
105123 fetchComments ({});
106124
107125 const { post , postIsLoading , fetchPost } = useFetchPost ();
@@ -116,14 +134,16 @@ export default {
116134 rejectComment .comment = rejectedComment;
117135 rejectComment .modalIsOpen = true ;
118136 };
119- const handleConfirmComment = (id )=> {
120- changeCommentStatus (id,' CONFIRMED' )
121- }
137+ const handleConfirmComment = (id ) => {
138+ changeCommentStatus (id, " CONFIRMED" );
139+ };
122140
123141 const handleFetchPost = async (id ) => {
124142 try {
125143 postModalIsOpen .value = true ;
126- fetchPost (id).then (res => console .log (" res" , res)).catch (err => console .log (" err" , err));
144+ fetchPost (id)
145+ .then ((res ) => console .log (" res" , res))
146+ .catch ((err ) => console .log (" err" , err));
127147 } catch {
128148 postModalIsOpen .value = false ;
129149 }
@@ -174,13 +194,21 @@ export default {
174194 const regex = new RegExp (` (${ query} )` , " gi" );
175195 return String (text).replace (regex, " <mark>$1</mark>" );
176196 };
177-
178197 const handleConfirmRejection = () => {
179- changeCommentStatus (rejectComment .comment .id , " REJECTED" )
180- showToast ({ body: " undo" , theme: ThemeColor .WARNING , title: " Deleting" , duration: 3000 })
181- rejectComment .comment = null
182- rejectComment .modalIsOpen = false
183- }
198+ changeCommentStatus (rejectComment .comment .id , " REJECTED" );
199+ showToast ({ body: " Undo" , theme: ThemeColor .WARNING , duration: 3000 });
200+ rejectComment .comment = null ;
201+ rejectComment .modalIsOpen = false ;
202+ };
203+
204+ const selectedRows = ref ([]);
205+
206+ const handleStatusChangeAll = (status ) => {
207+ selectedRows .value .forEach ((commentId ) => {
208+ changeCommentStatus (commentId, status);
209+ selectedRows .value = [];
210+ });
211+ };
184212
185213 return {
186214 comments: filteredComments,
@@ -194,7 +222,9 @@ export default {
194222 handleRejectComment,
195223 handleConfirmRejection,
196224 rejectComment,
197- handleConfirmComment
225+ handleConfirmComment,
226+ selectedRows,
227+ handleStatusChangeAll,
198228 };
199229 },
200230 components: {
0 commit comments