1
1
<template >
2
2
<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 >
4
14
<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 >
5
27
<VColumn :header =" $t('Id')" field =" id" >
6
28
<template #body =" { item } " >
7
29
<span v-html =" highlightText(item.id)" />
15
37
<VColumn :header =" $t('Email')" field =" email" />
16
38
<VColumn :header =" $t('Post')" field =" postId" >
17
39
<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)" >
20
41
<i class =" bi-eye" />
21
42
</button >
22
43
</template >
45
66
<button class =" btn btn-danger btn-sm" @click =" handleRejectComment(item)" >
46
67
<i class =" bi-ban" />
47
68
</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
+ >
50
76
<i class =" bi-check-circle" />
51
77
</button >
52
78
</div >
65
91
</template >
66
92
<div >
67
93
<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 >
74
96
</div >
75
97
<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 >
82
100
</template >
83
101
</VModal >
84
102
</template >
@@ -99,9 +117,9 @@ import { computed, reactive, ref, watch } from "vue";
99
117
export default {
100
118
name: " CommentsView" ,
101
119
setup () {
102
- const { showToast } = useToast ()
120
+ const { showToast } = useToast ();
103
121
104
- const { comments , commentsIsLoading , fetchComments , changeStatus: changeCommentStatus } = useFetchComments ();
122
+ const { comments , commentsIsLoading , fetchComments , changeStatus: changeCommentStatus } = useFetchComments ();
105
123
fetchComments ({});
106
124
107
125
const { post , postIsLoading , fetchPost } = useFetchPost ();
@@ -116,14 +134,16 @@ export default {
116
134
rejectComment .comment = rejectedComment;
117
135
rejectComment .modalIsOpen = true ;
118
136
};
119
- const handleConfirmComment = (id )=> {
120
- changeCommentStatus (id,' CONFIRMED' )
121
- }
137
+ const handleConfirmComment = (id ) => {
138
+ changeCommentStatus (id, " CONFIRMED" );
139
+ };
122
140
123
141
const handleFetchPost = async (id ) => {
124
142
try {
125
143
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));
127
147
} catch {
128
148
postModalIsOpen .value = false ;
129
149
}
@@ -174,13 +194,21 @@ export default {
174
194
const regex = new RegExp (` (${ query} )` , " gi" );
175
195
return String (text).replace (regex, " <mark>$1</mark>" );
176
196
};
177
-
178
197
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
+ };
184
212
185
213
return {
186
214
comments: filteredComments,
@@ -194,7 +222,9 @@ export default {
194
222
handleRejectComment,
195
223
handleConfirmRejection,
196
224
rejectComment,
197
- handleConfirmComment
225
+ handleConfirmComment,
226
+ selectedRows,
227
+ handleStatusChangeAll,
198
228
};
199
229
},
200
230
components: {
0 commit comments