fix: reload emails after sending it

This commit is contained in:
Shariq Ansari 2023-09-27 19:56:26 +05:30
parent 424d8feab2
commit 47ded1a7f1
2 changed files with 13 additions and 8 deletions

View File

@ -454,8 +454,9 @@
</div> </div>
<CommunicationArea <CommunicationArea
ref="emailBox" ref="emailBox"
v-if="['Emails', 'Activity'].includes(title) && lead" v-if="['Emails', 'Activity'].includes(title)"
v-model="lead" v-model="lead"
v-model:reload="reload_email"
/> />
<NoteModal v-model="showNoteModal" :note="note" @updateNote="updateNote" /> <NoteModal v-model="showNoteModal" :note="note" @updateNote="updateNote" />
</template> </template>
@ -508,6 +509,8 @@ const props = defineProps({
const lead = defineModel() const lead = defineModel()
const reload = defineModel('reload') const reload = defineModel('reload')
const reload_email = ref(false)
const versions = createResource({ const versions = createResource({
url: 'crm.fcrm.doctype.crm_lead.api.get_activities', url: 'crm.fcrm.doctype.crm_lead.api.get_activities',
params: { name: lead.value.data.name }, params: { name: lead.value.data.name },
@ -739,10 +742,11 @@ async function updateNote(note) {
} }
} }
watch(reload, (value) => { watch([reload, reload_email], ([reload_value, reload_email_value]) => {
if (value) { if (reload_value || reload_email_value) {
versions.reload() versions.reload()
reload.value = false reload.value = false
reload_email.value = false
} }
}) })
</script> </script>

View File

@ -42,7 +42,7 @@
}, },
}" }"
:editable="showCommunicationBox" :editable="showCommunicationBox"
v-model="modelValue.data" v-model="lead.data"
placeholder="Add a reply..." placeholder="Add a reply..."
/> />
</div> </div>
@ -56,7 +56,8 @@ import { usersStore } from '@/stores/users'
import { call } from 'frappe-ui' import { call } from 'frappe-ui'
import { ref, watch, computed, defineModel } from 'vue' import { ref, watch, computed, defineModel } from 'vue'
const modelValue = defineModel() const lead = defineModel()
const reload = defineModel('reload')
const { getUser } = usersStore() const { getUser } = usersStore()
@ -84,13 +85,13 @@ const onNewEmailChange = (value) => {
async function sendMail() { async function sendMail() {
await call('frappe.core.doctype.communication.email.make', { await call('frappe.core.doctype.communication.email.make', {
recipients: modelValue.value.data.email, recipients: lead.value.data.email,
cc: '', cc: '',
bcc: '', bcc: '',
subject: 'Email from Agent', subject: 'Email from Agent',
content: newEmail.value, content: newEmail.value,
doctype: 'CRM Lead', doctype: 'CRM Lead',
name: modelValue.value.data.name, name: lead.value.data.name,
send_email: 1, send_email: 1,
sender: getUser().name, sender: getUser().name,
sender_full_name: getUser()?.full_name || undefined, sender_full_name: getUser()?.full_name || undefined,
@ -102,7 +103,7 @@ async function submitComment() {
showCommunicationBox.value = false showCommunicationBox.value = false
await sendMail() await sendMail()
newEmail.value = '' newEmail.value = ''
modelValue.value.reload() reload.value = true
} }
defineExpose({ show: showCommunicationBox }) defineExpose({ show: showCommunicationBox })