From 366a72c9d7c4ecb4c7c2fe8d499cf409dd81299e Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Fri, 17 Mar 2023 21:08:38 +0530 Subject: [PATCH 1/3] feat: mutliple values for cc/bcc --- desk/src/pages/desk/Ticket.vue | 83 ++++++++++++++++++++++------------ 1 file changed, 53 insertions(+), 30 deletions(-) diff --git a/desk/src/pages/desk/Ticket.vue b/desk/src/pages/desk/Ticket.vue index b325d3269..5dadd6932 100644 --- a/desk/src/pages/desk/Ticket.vue +++ b/desk/src/pages/desk/Ticket.vue @@ -144,40 +144,55 @@ >
To
-
+
{{ ticket.raised_by }}
Cc
+
+ {{ email }} +
-
-
Bcc
- +
Bcc
+
+ {{ email }} +
-
as @@ -504,20 +519,13 @@ export default { const showBcc = ref(false); const showCcBtn = ref(true); const showBccBtn = ref(true); - const validateEmail = toFieldValidator(zod.string().email()); - const { value: cc, errorMessage: ccValidationError } = useField( - "ccField", - validateEmail - ); - const { value: bcc, errorMessage: bccValidationError } = useField( - "bccField", - validateEmail - ); + const ccList = ref([]); + const bccList = ref([]); return { - cc, - bcc, + ccList, + bccList, showTextFormattingMenu, viewportWidth, user, @@ -531,8 +539,6 @@ export default { tempContent, editingSubject, replied, - ccValidationError, - bccValidationError, showCc, showBcc, showCcBtn, @@ -669,8 +675,8 @@ export default { this.$resources.ticket.replyViaAgent.submit({ attachments: this.attachments.map((x) => x.name), - bcc: this.bcc, - cc: this.cc, + bcc: this.bccList.join(","), + cc: this.ccList.join(","), message, }); @@ -723,6 +729,23 @@ export default { this.tempContent = content; this.content = this.tempContent; }, + validateEmail(email) { + return zod.string().email().safeParse(email).success; + }, + pushToEmailList(list, e) { + if (!this.validateEmail(e.target.value)) { + this.$toast({ + title: "Invalid email", + icon: "x", + iconClasses: "text-red-500", + }); + + return; + } + + list.push(e.currentTarget.value); + e.currentTarget.value = ""; + }, }, }; From bd9999108f00cad7f25d4407846c1afdeadf40e9 Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Fri, 17 Mar 2023 21:59:04 +0530 Subject: [PATCH 2/3] feat: cc/bcc: remove from list --- desk/src/pages/desk/Ticket.vue | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/desk/src/pages/desk/Ticket.vue b/desk/src/pages/desk/Ticket.vue index 5dadd6932..02707bba9 100644 --- a/desk/src/pages/desk/Ticket.vue +++ b/desk/src/pages/desk/Ticket.vue @@ -162,12 +162,19 @@
Cc
- {{ email }} +
+ {{ email }} +
+
Bcc
- {{ email }} +
+ {{ email }} +
+
From 4a2b5444bcd57b0a2aefb0b6d08abc90b7ba67f1 Mon Sep 17 00:00:00 2001 From: Sabu Siyad Date: Fri, 17 Mar 2023 22:12:22 +0530 Subject: [PATCH 3/3] feat: cc/bcc: fetch from last communication --- desk/package.json | 2 +- desk/src/pages/desk/Ticket.vue | 16 +++++++++++++++- desk/yarn.lock | 8 ++++---- frappedesk/frappedesk/doctype/ticket/ticket.py | 1 + 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/desk/package.json b/desk/package.json index dd8eae3a3..e8a3cf378 100644 --- a/desk/package.json +++ b/desk/package.json @@ -17,7 +17,7 @@ "autoprefixer": "^10.4.13", "dayjs": "^1.11.7", "echarts": "^5.4.1", - "frappe-ui": "^0.0.103", + "frappe-ui": "^0.0.105", "vee-validate": "^4.8.2", "vue": "^3.2.47", "vue-echarts": "^6.5.4", diff --git a/desk/src/pages/desk/Ticket.vue b/desk/src/pages/desk/Ticket.vue index 02707bba9..99cf92fa4 100644 --- a/desk/src/pages/desk/Ticket.vue +++ b/desk/src/pages/desk/Ticket.vue @@ -574,7 +574,21 @@ export default { type: "document", doctype: "Ticket", name: this.ticketId, + onSuccess: () => { + this.$resources.ticket.lastCommunication.fetch(); + }, whitelistedMethods: { + lastCommunication: { + method: "last_communication", + onSuccess: (data) => { + this.ccList = this.ccList.length + ? this.ccList + : data.cc?.split(",") || []; + this.bccList = this.bccList.length + ? this.bccList + : data.bcc?.split(",") || []; + }, + }, markSeen: "mark_seen", replyViaAgent: { method: "reply_via_agent", @@ -747,7 +761,7 @@ export default { return zod.string().email().safeParse(email).success; }, pushToEmailList(list, e) { - if (list.indexOf(email)) return; + if (list.indexOf(e.target.value) > 0) return; if (!this.validateEmail(e.target.value)) { this.$toast({ diff --git a/desk/yarn.lock b/desk/yarn.lock index 0dc18c46e..42b1d5c04 100644 --- a/desk/yarn.lock +++ b/desk/yarn.lock @@ -892,10 +892,10 @@ fraction.js@^4.2.0: resolved "https://registry.yarnpkg.com/fraction.js/-/fraction.js-4.2.0.tgz#448e5109a313a3527f5a3ab2119ec4cf0e0e2950" integrity sha512-MhLuK+2gUcnZe8ZHlaaINnQLl0xRIGRfcGk2yl8xoQAfHrSsL3rYu6FCmBdkdbhc9EPlwyGHewaRsvwRMJtAlA== -frappe-ui@^0.0.103: - version "0.0.103" - resolved "https://registry.yarnpkg.com/frappe-ui/-/frappe-ui-0.0.103.tgz#54be8966b4602f66b0eee36df94e2f0137889e4d" - integrity sha512-TEfAUsmJLzfIT28rFbl2eCA//apgOwMA12DIPOxOpUB8+mh0s6Ze5ADK1pE+/p3hJlPG9QSS8JxRXvH9t/lOKQ== +frappe-ui@^0.0.105: + version "0.0.105" + resolved "https://registry.yarnpkg.com/frappe-ui/-/frappe-ui-0.0.105.tgz#173acd4dbf8e14f1d072c1a19a4dd597af0d7833" + integrity sha512-/CbbpAgEHgOXQ6L69hg1hW99rHsc6Q5VKccaBSCZbczU9iWNXvnm+YZ3LggnwNiFpiJBjNsy1TqMUy448ry+oQ== dependencies: "@headlessui/vue" "^1.5.0" "@popperjs/core" "^2.11.2" diff --git a/frappedesk/frappedesk/doctype/ticket/ticket.py b/frappedesk/frappedesk/doctype/ticket/ticket.py index ed7c10069..0e4e44712 100644 --- a/frappedesk/frappedesk/doctype/ticket/ticket.py +++ b/frappedesk/frappedesk/doctype/ticket/ticket.py @@ -314,6 +314,7 @@ def instantly_send_email(self): return bool(int(check)) + @frappe.whitelist() def last_communication(self): filters = {"reference_doctype": "Ticket", "reference_name": ["=", self.name]}