Skip to content

Commit

Permalink
fix: updated activities & communicationArea component to handle lead/…
Browse files Browse the repository at this point in the history
…deal activities
  • Loading branch information
shariquerik committed Nov 6, 2023
1 parent de4aa2a commit a685724
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 24 deletions.
34 changes: 15 additions & 19 deletions frontend/src/components/Activities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Button
v-if="title == 'Calls'"
variant="solid"
@click="makeCall(lead.data.mobile_no)"
@click="makeCall(doc.data.mobile_no)"
>
<template #prefix>
<PhoneIcon class="h-4 w-4" />
Expand Down Expand Up @@ -561,7 +561,7 @@
v-if="title == 'Calls'"
variant="solid"
label="Make a call"
@click="makeCall(lead.data.mobile_no)"
@click="makeCall(doc.data.mobile_no)"
/>
<Button
v-else-if="title == 'Notes'"
Expand All @@ -585,20 +585,20 @@
<CommunicationArea
ref="emailBox"
v-if="['Emails', 'Activity'].includes(title)"
v-model="lead"
v-model="doc"
v-model:reload="reload_email"
/>
<NoteModal
v-model="showNoteModal"
v-model:reloadNotes="notes"
:note="note"
:lead="lead.data?.name"
:lead="doc.data?.name"
/>
<TaskModal
v-model="showTaskModal"
v-model:reloadTasks="tasks"
:task="task"
:lead="lead.data?.name"
:lead="doc.data?.name"
/>
</template>
<script setup>
Expand Down Expand Up @@ -654,22 +654,22 @@ const props = defineProps({
},
})
const lead = defineModel()
const doc = defineModel()
const reload = defineModel('reload')
const reload_email = ref(false)
const versions = createResource({
url: 'crm.fcrm.doctype.crm_lead.api.get_activities',
params: { name: lead.value.data.name },
cache: ['activity', lead.value.data.name],
url: 'crm.api.activities.get_activities',
params: { name: doc.value.data.name },
cache: ['activity', doc.value.data.name],
auto: true,
})
const calls = createListResource({
type: 'list',
doctype: 'CRM Call Log',
cache: ['Call Logs', lead.value.data.name],
cache: ['Call Logs', doc.value.data.name],
fields: [
'name',
'caller',
Expand All @@ -685,7 +685,7 @@ const calls = createListResource({
'creation',
'note',
],
filters: { lead: lead.value.data.name },
filters: { lead: doc.value.data.name },
orderBy: 'creation desc',
pageLength: 999,
auto: true,
Expand Down Expand Up @@ -722,9 +722,9 @@ const calls = createListResource({
const notes = createListResource({
type: 'list',
doctype: 'CRM Note',
cache: ['Notes', lead.value.data.name],
cache: ['Notes', doc.value.data.name],
fields: ['name', 'title', 'content', 'owner', 'modified'],
filters: { lead: lead.value.data.name },
filters: { lead: doc.value.data.name },
orderBy: 'modified desc',
pageLength: 999,
auto: true,
Expand All @@ -733,7 +733,7 @@ const notes = createListResource({
const tasks = createListResource({
type: 'list',
doctype: 'CRM Task',
cache: ['Tasks', lead.value.data.name],
cache: ['Tasks', doc.value.data.name],
fields: [
'name',
'title',
Expand All @@ -745,7 +745,7 @@ const tasks = createListResource({
'status',
'modified',
],
filters: { lead: lead.value.data.name },
filters: { lead: doc.value.data.name },
orderBy: 'modified desc',
pageLength: 999,
auto: true,
Expand Down Expand Up @@ -805,10 +805,6 @@ function update_activities_details(activity) {
if (activity.activity_type == 'creation') {
activity.type = activity.data
} else if (activity.activity_type == 'deal') {
activity.type = 'converted the lead to this deal'
activity.data.field_label = ''
activity.data.value = ''
} else if (activity.activity_type == 'added') {
activity.type = 'added'
activity.value = 'as'
Expand Down
15 changes: 10 additions & 5 deletions frontend/src/components/CommunicationArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
},
}"
:editable="showCommunicationBox"
v-model="lead.data"
v-model="doc.data"
placeholder="Add a reply..."
/>
</div>
Expand All @@ -56,7 +56,7 @@ import { usersStore } from '@/stores/users'
import { call } from 'frappe-ui'
import { ref, watch, computed, defineModel } from 'vue'
const lead = defineModel()
const doc = defineModel()
const reload = defineModel('reload')
const { getUser } = usersStore()
Expand Down Expand Up @@ -84,14 +84,19 @@ const onNewEmailChange = (value) => {
}
async function sendMail() {
let doctype = 'CRM Lead'
if (doc.value.data.lead) {
doctype = 'CRM Deal'
}
await call('frappe.core.doctype.communication.email.make', {
recipients: lead.value.data.email,
recipients: doc.value.data.email,
cc: '',
bcc: '',
subject: 'Email from Agent',
content: newEmail.value,
doctype: 'CRM Lead',
name: lead.value.data.name,
doctype: doctype,
name: doc.value.data.name,
send_email: 1,
sender: getUser().name,
sender_full_name: getUser()?.full_name || undefined,
Expand Down

0 comments on commit a685724

Please sign in to comment.