Skip to content

Commit

Permalink
fix(ux): customer portal: disallow empty messages (#1143)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssiyad committed May 1, 2023
1 parent 7e34d6c commit bc03132
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions desk/src/pages/portal/ticketing/Ticket.vue
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ import CustomIcons from "@/components/desk/global/CustomIcons.vue"
import CustomerSatisfactionFeedback from "@/components/portal/ticket/CustomerSatisfactionFeedback.vue"
import TicketField from "@/components/global/TicketField.vue"
import { useAuthStore } from "@/stores/auth"
import { isEmpty } from "@/utils/editor"
export default {
name: "Tickets",
Expand Down Expand Up @@ -512,6 +513,17 @@ export default {
this.content = this.tempTextEditorData.content
this.attachments = this.tempTextEditorData.attachments
},
validate(params) {
if (isEmpty(params.message)) {
this.$toast({
title: "Message is empty",
icon: "x",
iconClasses: "text-red-600",
});
return 'Message is empty';
}
}
}
},
},
Expand Down
16 changes: 16 additions & 0 deletions desk/src/utils/editor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { isEmpty as isEmpty_ } from "lodash";

export function strip(content: string) {
const opening = new RegExp(/^<div class='content-block'><div>/);
const closing = new RegExp(/<\/div><\/div>$/);

return content.replace(opening, "").replace(closing, "");
}

/**
* Check if the content is empty. This is done by replacing all <div class="content-block">
* with empty strings.
*/
export function isEmpty(content: string) {
return isEmpty_(strip(content).trim());
}

0 comments on commit bc03132

Please sign in to comment.