1111 <span class =" font-medium text-gray-800" >
1212 {{ commenter }}
1313 </span >
14- <span > added a</span >
14+ <span > {{ __(" added a") }} </span >
1515 <span class =" max-w-xs truncate font-medium text-gray-800" >
16- comment
16+ {{ __(" comment") }}
1717 </span >
1818 </p >
1919 </div >
2626 <div v-if =" authStore.userId === commentedBy && !editable" >
2727 <Dropdown
2828 :placement =" 'right'"
29- :options =" [
30- {
31- label: 'Edit',
32- onClick: () => handleEditMode(),
33- icon: 'edit-2',
34- condition: () => !isTicketMergedComment,
35- },
36- {
37- label: 'Delete',
38- onClick: () => (showDialog = true),
39- icon: 'trash-2',
40- },
41- ]"
29+ :options =" dropdownOptions"
30+ @click =" isConfirmingDelete = false"
4231 >
4332 <Button
4433 icon =" more-horizontal"
147136 ? 'bg-blue-100 text-blue-700 hover:bg-blue-200'
148137 : 'bg-surface-gray-3 text-ink-gray-6 hover:bg-surface-gray-4'
149138 "
139+ v-if =" reaction.count !== 0"
150140 @click =" handleReaction(reaction.emoji)"
151141 >
152142 <span >{{ reaction.emoji }}</span >
157147 </div >
158148 </div >
159149 </div >
160- <Dialog
161- v-model =" showDialog"
162- :options =" {
163- title: 'Delete Comment',
164- message: 'Are you sure you want to confirm this action?',
165- actions: [
166- { label: 'Cancel', onClick: () => (showDialog = false) },
167- {
168- label: 'Delete',
169- onClick: () => deleteComment.submit(),
170- variant: 'solid',
171- },
172- ],
173- }"
174- />
175150</template >
176151
177152<script setup lang="ts">
@@ -183,6 +158,7 @@ import { useConfigStore } from "@/stores/config";
183158import { updateRes as updateComment } from " @/stores/knowledgeBase" ;
184159import { useUserStore } from " @/stores/user" ;
185160import { CommentActivity } from " @/types" ;
161+ import { ConfirmDelete } from " @/utils" ;
186162import { useDevice } from " @/composables" ;
187163import { useScreenSize } from " @/composables/screen" ;
188164import {
@@ -195,7 +171,6 @@ import {
195171} from " @/utils" ;
196172import {
197173 Avatar ,
198- Dialog ,
199174 Dropdown ,
200175 Popover ,
201176 TextEditor ,
@@ -204,6 +179,7 @@ import {
204179 toast ,
205180} from " frappe-ui" ;
206181import { PropType , computed , onMounted , ref } from " vue" ;
182+ import { __ } from " @/translation" ;
207183
208184const authStore = useAuthStore ();
209185const props = defineProps ({
@@ -228,12 +204,26 @@ const agentStore = useAgentStore();
228204const userMentions = computed (() => agentStore .dropdown ?? []);
229205
230206const emit = defineEmits ([" update" ]);
231- const showDialog = ref (false );
207+ const isConfirmingDelete = ref (false );
232208const editable = ref (false );
233209const _content = ref (content );
234210
235211const emojiList = [" 👍" , " 👎" , " ❤️" , " 🎉" , " 👀" , " ✅" ];
236212
213+ const dropdownOptions = computed (() => [
214+ {
215+ label: " Edit" ,
216+ onClick : () => handleEditMode (),
217+ icon: " edit-2" ,
218+ condition : () => ! isTicketMergedComment .value ,
219+ },
220+ ... ConfirmDelete ({
221+ onConfirmDelete : () => deleteComment .submit (),
222+ isConfirmingDelete ,
223+ }),
224+ ]);
225+ // editor.commands.focus('end')
226+
237227const reactions = ref <
238228 Array <{
239229 emoji: string ;
@@ -263,6 +253,37 @@ const toggleReaction = createResource({
263253});
264254
265255function handleReaction(emoji : string ) {
256+ const previousReaction = reactions .value .find (
257+ (r ) => r .current_user_reacted && r .emoji !== emoji
258+ );
259+ if (previousReaction ) {
260+ previousReaction .count = Math .max (0 , previousReaction .count - 1 );
261+ previousReaction .current_user_reacted = false ;
262+ }
263+
264+ const existingReaction = reactions .value .find ((r ) => r .emoji === emoji );
265+ if (existingReaction ) {
266+ if (existingReaction .current_user_reacted ) {
267+ existingReaction .count = Math .max (0 , existingReaction .count - 1 );
268+ existingReaction .current_user_reacted = false ;
269+ } else {
270+ existingReaction .count += 1 ;
271+ existingReaction .current_user_reacted = true ;
272+ }
273+ } else {
274+ reactions .value .push ({
275+ emoji ,
276+ count: 1 ,
277+ current_user_reacted: true ,
278+ users: [
279+ {
280+ user: authStore .userId ,
281+ full_name: getUser (authStore .userId ).full_name ,
282+ },
283+ ],
284+ });
285+ }
286+
266287 toggleReaction .submit (emoji );
267288}
268289
@@ -274,7 +295,7 @@ const commentBoxState = ref(content);
274295function handleEditMode() {
275296 editable .value = true ;
276297 commentBoxState .value = _content .value ;
277- editorRef .value .editor .chain ().focus (" start " );
298+ editorRef .value ? .editor .chain ().focus (" end " ). run ( );
278299}
279300
280301function handleDiscard() {
@@ -290,8 +311,7 @@ const deleteComment = createResource({
290311 }),
291312 onSuccess() {
292313 emit (" update" );
293- showDialog .value = false ;
294- toast .success (" Comment deleted" );
314+ toast .success (__ (" Comment deleted sucessfully." ));
295315 },
296316});
297317
@@ -301,7 +321,7 @@ function handleSaveComment() {
301321 return ;
302322 }
303323 if (isContentEmpty (_content .value )) {
304- toast .error (" Comment cannot be empty" );
324+ toast .error (__ ( " Comment cannot be empty. " ) );
305325 return ;
306326 }
307327
@@ -317,7 +337,7 @@ function handleSaveComment() {
317337 editable .value = false ;
318338 lastSavedContent .value = _content .value ;
319339 emit (" update" );
320- toast .success (" Comment updated" );
340+ toast .success (__ ( " Comment updated successfully. " ) );
321341 },
322342 }
323343 );
0 commit comments