fix: add subject to email box

This commit is contained in:
Shariq Ansari 2024-01-18 17:54:57 +05:30
parent 4ebd56b417
commit 7c0d9703b8
2 changed files with 26 additions and 2 deletions

View File

@ -55,6 +55,7 @@
v-model="doc.data" v-model="doc.data"
v-model:attachments="attachments" v-model:attachments="attachments"
:doctype="doctype" :doctype="doctype"
:subject="subject"
placeholder="Add a reply..." placeholder="Add a reply..."
/> />
</div> </div>
@ -87,6 +88,16 @@ const newEmailEditor = ref(null)
const sendEmailRef = ref(null) const sendEmailRef = ref(null)
const attachments = ref([]) const attachments = ref([])
const subject = computed(() => {
let prefix = ''
if (doc.value.data?.lead_name) {
prefix = doc.value.data.lead_name
} else if (doc.value.data?.organization) {
prefix = doc.value.data.organization
}
return `${prefix} (#${doc.value.data.name})`
})
watch( watch(
() => showCommunicationBox.value, () => showCommunicationBox.value,
(value) => { (value) => {
@ -106,6 +117,7 @@ const onNewEmailChange = (value) => {
async function sendMail() { async function sendMail() {
let recipients = newEmailEditor.value.toEmails let recipients = newEmailEditor.value.toEmails
let subject = newEmailEditor.value.subject
let cc = newEmailEditor.value.ccEmails let cc = newEmailEditor.value.ccEmails
let bcc = newEmailEditor.value.bccEmails let bcc = newEmailEditor.value.bccEmails
await call('frappe.core.doctype.communication.email.make', { await call('frappe.core.doctype.communication.email.make', {
@ -113,7 +125,7 @@ async function sendMail() {
attachments: attachments.value.map((x) => x.name), attachments: attachments.value.map((x) => x.name),
cc: cc.join(', '), cc: cc.join(', '),
bcc: bcc.join(', '), bcc: bcc.join(', '),
subject: 'Email from Agent', subject: subject,
content: newEmail.value, content: newEmail.value,
doctype: props.doctype, doctype: props.doctype,
name: doc.value.data.name, name: doc.value.data.name,

View File

@ -9,6 +9,13 @@
:editable="editable" :editable="editable"
> >
<template #top> <template #top>
<div class="mx-10 flex items-center gap-2 border-t py-2.5">
<span class="text-xs text-gray-500">SUBJECT:</span>
<TextInput
class="flex-1 border-none bg-white hover:bg-white focus:border-none focus:!shadow-none focus-visible:!ring-0"
v-model="subject"
/>
</div>
<div <div
class="mx-10 flex items-center gap-2 border-t py-2.5" class="mx-10 flex items-center gap-2 border-t py-2.5"
:class="[cc || bcc ? '' : 'border-b']" :class="[cc || bcc ? '' : 'border-b']"
@ -136,6 +143,10 @@ const props = defineProps({
type: String, type: String,
default: 'CRM Lead', default: 'CRM Lead',
}, },
subject: {
type: String,
default: 'Email from Lead',
},
editorProps: { editorProps: {
type: Object, type: Object,
default: () => ({}), default: () => ({}),
@ -158,6 +169,7 @@ const textEditor = ref(null)
const cc = ref(false) const cc = ref(false)
const bcc = ref(false) const bcc = ref(false)
const subject = ref(props.subject)
const toEmails = ref(modelValue.value.email ? [modelValue.value.email] : []) const toEmails = ref(modelValue.value.email ? [modelValue.value.email] : [])
const ccEmails = ref([]) const ccEmails = ref([])
const bccEmails = ref([]) const bccEmails = ref([])
@ -170,7 +182,7 @@ function removeAttachment(attachment) {
attachments.value = attachments.value.filter((a) => a !== attachment) attachments.value = attachments.value.filter((a) => a !== attachment)
} }
defineExpose({ editor, cc, bcc, toEmails, ccEmails, bccEmails }) defineExpose({ editor, subject, cc, bcc, toEmails, ccEmails, bccEmails })
const textEditorMenuButtons = [ const textEditorMenuButtons = [
'Paragraph', 'Paragraph',