1
0
forked from test/crm

fix: show lead and deal activities with different icon and field titles

Lead Owner for deal will be Deal Owner
This commit is contained in:
Shariq Ansari 2023-09-27 19:02:04 +05:30
parent 4eb8a5aa77
commit 045d2dc358
6 changed files with 50 additions and 23 deletions

View File

@ -29,21 +29,28 @@ def get_activities(name):
docinfo = frappe.response["docinfo"]
lead_fields_meta = frappe.get_meta("CRM Lead").fields
doc = frappe.get_doc("CRM Lead", name, fields=["creation", "owner"])
doc = frappe.db.get_values("CRM Lead", name, ["creation", "owner", "created_as_deal"])[0]
created_as_deal = doc[2]
is_lead = False if created_as_deal else True
activities = [{
"activity_type": "creation",
"creation": doc.creation,
"owner": doc.owner,
"data": "created this lead",
"creation": doc[0],
"owner": doc[1],
"data": "created this " + ("deal" if created_as_deal else "lead"),
"is_lead": is_lead,
}]
docinfo.versions.reverse()
for version in docinfo.versions:
data = json.loads(version.data)
if not data.get("changed"):
continue
if change := data.get("changed")[0]:
activity_type = "changed"
field_label = next((f.label for f in lead_fields_meta if f.fieldname == change[0]), None)
activity_type = "changed"
if field_label == "Lead Owner" and (created_as_deal or not is_lead):
field_label = "Deal Owner"
data = {
"field": change[0],
"field_label": field_label,
@ -59,6 +66,9 @@ def get_activities(name):
"field_label": field_label,
"value": change[2],
}
if field_label == "Is Deal" and change[2] and is_lead:
activity_type = "deal"
is_lead = False
elif change[1] and not change[2]:
activity_type = "removed"
data = {
@ -72,6 +82,7 @@ def get_activities(name):
"creation": version.creation,
"owner": version.owner,
"data": data,
"is_lead": is_lead,
}
activities.append(activity)
@ -89,6 +100,7 @@ def get_activities(name):
"bcc": communication.bcc,
"read_by_recipient": communication.read_by_recipient,
},
"is_lead": is_lead,
}
activities.append(activity)

View File

@ -14,6 +14,7 @@
"middle_name",
"last_name",
"is_deal",
"created_as_deal",
"column_break_izjs",
"lead_name",
"gender",
@ -251,12 +252,19 @@
{
"fieldname": "section_break_jyxr",
"fieldtype": "Section Break"
},
{
"default": "0",
"fieldname": "created_as_deal",
"fieldtype": "Check",
"hidden": 1,
"label": "Created as Deal"
}
],
"image_field": "image",
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-08-25 19:21:22.778067",
"modified": "2023-09-27 18:54:18.196159",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Lead",

View File

@ -448,6 +448,7 @@ import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
import NoteIcon from '@/components/Icons/NoteIcon.vue'
import DurationIcon from '@/components/Icons/DurationIcon.vue'
import PlayIcon from '@/components/Icons/PlayIcon.vue'
import LeadsIcon from '@/components/Icons/LeadsIcon.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue'
import DotIcon from '@/components/Icons/DotIcon.vue'
import EmailAtIcon from '@/components/Icons/EmailAtIcon.vue'
@ -582,7 +583,7 @@ const activities = computed(() => {
return notes.data
}
activities.forEach((activity) => {
activity.icon = timelineIcon(activity.activity_type)
activity.icon = timelineIcon(activity.activity_type, activity.is_lead)
if (
activity.activity_type == 'incoming_call' ||
@ -611,6 +612,10 @@ 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'
@ -644,10 +649,13 @@ const emptyTextIcon = computed(() => {
return h(icon, { class: 'text-gray-500' })
})
function timelineIcon(activity_type) {
function timelineIcon(activity_type, is_lead) {
let icon
switch (activity_type) {
case 'creation':
icon = is_lead ? LeadsIcon : DealsIcon
break
case 'deal':
icon = DealsIcon
break
case 'communication':

View File

@ -1,21 +1,16 @@
<template>
<svg
width="18"
height="18"
viewBox="0 0 18 18"
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12.6562 13.7812H13.5725H15.052C16.1315 13.7812 16.9335 12.7815 16.6993 11.7277L16.6179 11.3616C16.2748 9.81742 14.9051 8.71875 13.3233 8.71875H10.8629C10.4404 8.71875 10.033 8.79714 9.65626 8.94148C9.4976 9.00227 9.34438 9.07475 9.19775 9.158"
stroke="currentColor"
/>
<circle cx="6.46875" cy="6.1875" r="2.03125" stroke="currentColor" />
<circle cx="12.375" cy="4.78125" r="1.75" stroke="currentColor" />
<path
d="M2.0092 12.7555C2.31423 11.3828 3.53167 10.4062 4.93776 10.4062H7.99974C9.40583 10.4062 10.6233 11.3828 10.9283 12.7555L11.1256 13.6434C11.3338 14.5801 10.6209 15.4688 9.66133 15.4688H3.27617C2.31655 15.4688 1.60372 14.5801 1.81189 13.6434L2.0092 12.7555Z"
fill="white"
stroke="currentColor"
fill-rule="evenodd"
clip-rule="evenodd"
d="M11.9011 3.88117C11.9011 4.46845 11.4251 4.94454 10.8378 4.94454C10.2505 4.94454 9.77442 4.46845 9.77442 3.88117C9.77442 3.29389 10.2505 2.81781 10.8378 2.81781C11.4251 2.81781 11.9011 3.29389 11.9011 3.88117ZM12.9011 3.88117C12.9011 5.02074 11.9773 5.94454 10.8378 5.94454C9.69822 5.94454 8.77442 5.02074 8.77442 3.88117C8.77442 2.74161 9.69822 1.81781 10.8378 1.81781C11.9773 1.81781 12.9011 2.74161 12.9011 3.88117ZM9.45115 6.99206C9.00149 6.99206 8.56731 7.07554 8.16567 7.22941C7.9966 7.29419 7.83337 7.37141 7.67722 7.46007L8.17096 8.32968C8.28372 8.26566 8.40152 8.20994 8.52344 8.16322C8.81278 8.05237 9.12582 7.99206 9.45115 7.99206H11.7074C12.9237 7.99206 13.9768 8.83683 14.2407 10.0242L14.3153 10.3599C14.4606 11.0141 13.9628 11.6346 13.2927 11.6346H11.936H11.0957V12.6346H11.936H13.2927C14.6026 12.6346 15.5756 11.4216 15.2915 10.1429L15.2168 9.80723C14.8513 8.16236 13.3924 6.99206 11.7074 6.99206H9.45115ZM4.29314 9.53958C3.07685 9.53958 2.02374 10.3844 1.75989 11.5717L1.68529 11.9074C1.53992 12.5616 2.03772 13.1822 2.70787 13.1822H8.13467C8.80482 13.1822 9.30263 12.5616 9.15725 11.9074L9.08265 11.5717C8.8188 10.3844 7.76569 9.53958 6.5494 9.53958H4.29314ZM0.783705 11.3548C1.14923 9.70989 2.60815 8.53958 4.29314 8.53958H6.5494C8.23439 8.53958 9.69331 9.70989 10.0588 11.3548L10.1334 11.6905C10.4176 12.9692 9.44457 14.1822 8.13467 14.1822H2.70787C1.39797 14.1822 0.424947 12.9692 0.709104 11.6905L0.783705 11.3548ZM6.74274 5.17078C6.74274 5.9005 6.15118 6.49206 5.42145 6.49206C4.69173 6.49206 4.10017 5.9005 4.10017 5.17078C4.10017 4.44105 4.69173 3.84949 5.42145 3.84949C6.15118 3.84949 6.74274 4.44105 6.74274 5.17078ZM7.74274 5.17078C7.74274 6.45279 6.70346 7.49206 5.42145 7.49206C4.13944 7.49206 3.10017 6.45279 3.10017 5.17078C3.10017 3.88877 4.13944 2.84949 5.42145 2.84949C6.70346 2.84949 7.74274 3.88877 7.74274 5.17078Z"
fill="currentColor"
/>
</svg>
</template>

View File

@ -258,6 +258,8 @@ let newDeal = reactive({
email: '',
mobile_no: '',
lead_owner: getUser().email,
is_deal: 1,
created_as_deal: 1,
})
const createLead = createResource({
@ -284,9 +286,9 @@ function createNewDeal(close) {
},
onSuccess(data) {
router.push({
name: 'Lead',
name: 'Deal',
params: {
leadId: data.name,
dealId: data.name,
},
})
},

View File

@ -378,6 +378,9 @@ function updateLead(fieldname, value) {
},
auto: true,
onSuccess: () => {
if (fieldname == 'is_deal') {
router.push({ name: 'Deal', params: { dealId: lead.data.name } })
}
lead.reload()
contacts.reload()
reload.value = true
@ -575,7 +578,6 @@ function convertToDeal() {
lead.data.status = 'Qualified'
lead.data.is_deal = 1
updateLead('is_deal', 1)
router.push({ name: 'Deal', params: { dealId: lead.data.name } })
}
function updateAssignedAgent(email) {