40
40
</template >
41
41
</VColumn >
42
42
<VColumn :header =" $t('Actions')" field =" id" >
43
- <template #body >
43
+ <template #body = " { item } " >
44
44
<div class =" d-flex gap-2" >
45
- <button class =" btn btn-danger btn-sm" >
45
+ <button class =" btn btn-danger btn-sm" @click = " handleRejectComment(item) " >
46
46
<i class =" bi-ban" />
47
47
</button >
48
48
<button class =" btn btn-success btn-sm z-3" data-bs-toggle =" tooltip" data-bs-placement =" top"
59
59
{{ post.title }}
60
60
</h1 >
61
61
</VModal >
62
+ <VModal v-model =" rejectComment.modalIsOpen" ref =" modal" >
63
+ <template v-slot :header >
64
+ <h1 class =" h6" >Are you sure?</h1 >
65
+ </template >
66
+ <div >
67
+ <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 >
74
+ </div >
75
+ <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 >
82
+ </template >
83
+ </VModal >
62
84
</template >
63
85
64
86
<script >
@@ -70,7 +92,7 @@ import { useFetchComments } from "@/composables/comments.composable";
70
92
import { useApplyFilters } from " @/composables/filter.composable" ;
71
93
import useFetchPost from " @/composables/posts.composable" ;
72
94
import StorageService from " @/services/storage.service" ;
73
- import { computed , ref , watch } from " vue" ;
95
+ import { computed , reactive , ref , watch } from " vue" ;
74
96
75
97
export default {
76
98
name: " CommentsView" ,
@@ -80,6 +102,17 @@ export default {
80
102
81
103
const { post , postIsLoading , fetchPost } = useFetchPost ();
82
104
const postModalIsOpen = ref (false );
105
+
106
+ const rejectComment = reactive ({
107
+ comment: null ,
108
+ modalIsOpen: false ,
109
+ });
110
+
111
+ const handleRejectComment = (rejectedComment ) => {
112
+ rejectComment .comment = rejectedComment;
113
+ rejectComment .modalIsOpen = true ;
114
+ };
115
+
83
116
const handleFetchPost = async (id ) => {
84
117
try {
85
118
postModalIsOpen .value = true ;
@@ -97,14 +130,18 @@ export default {
97
130
email: syncedFilters? .email || undefined ,
98
131
});
99
132
100
- watch (filters, (newFilters ) => {
101
- StorageService .set (' synced-filters' ,{... filters,... newFilters})
102
- }, { immediate: true })
133
+ watch (
134
+ filters,
135
+ (newFilters ) => {
136
+ StorageService .set (" synced-filters" , { ... filters, ... newFilters });
137
+ },
138
+ { immediate: true }
139
+ );
103
140
104
141
StorageService .observe (" synced-filters" , (newValue ) => {
105
142
filters .searchQuery = newValue? .searchQuery || undefined ;
106
143
filters .email = newValue? .email || undefined ;
107
- filters .status = newValue? .status || undefined
144
+ filters .status = newValue? .status || undefined ;
108
145
});
109
146
110
147
const filteredComments = computed (() => {
@@ -131,6 +168,12 @@ export default {
131
168
return String (text).replace (regex, " <mark>$1</mark>" );
132
169
};
133
170
171
+ const handleConfirmRejection = () => {
172
+ // doing rejection here
173
+ rejectComment .comment = null
174
+ rejectComment .modalIsOpen = false
175
+ }
176
+
134
177
return {
135
178
comments: filteredComments,
136
179
commentsIsLoading,
@@ -140,6 +183,9 @@ export default {
140
183
postIsLoading,
141
184
handleFetchPost,
142
185
postModalIsOpen,
186
+ handleRejectComment,
187
+ handleConfirmRejection,
188
+ rejectComment,
143
189
};
144
190
},
145
191
components: {
0 commit comments