fix: added ref doc instead of lead in task/note to handle both lead and deal

This commit is contained in:
Shariq Ansari 2023-11-07 13:42:24 +05:30
parent a685724d3d
commit ce4a45ccd5
7 changed files with 64 additions and 23 deletions

View File

@ -9,7 +9,8 @@
"field_order": [ "field_order": [
"title", "title",
"content", "content",
"lead" "reference_doctype",
"reference_docname"
], ],
"fields": [ "fields": [
{ {
@ -27,10 +28,17 @@
"label": "Content" "label": "Content"
}, },
{ {
"fieldname": "lead", "default": "CRM Lead",
"fieldname": "reference_doctype",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Lead", "label": "Reference Document Type",
"options": "CRM Lead" "options": "DocType"
},
{
"fieldname": "reference_docname",
"fieldtype": "Dynamic Link",
"label": "Reference Doc",
"options": "reference_doctype"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
@ -40,7 +48,7 @@
"link_fieldname": "note" "link_fieldname": "note"
} }
], ],
"modified": "2023-08-28 11:48:42.100802", "modified": "2023-11-07 13:41:11.249515",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "CRM Note", "name": "CRM Note",

View File

@ -10,7 +10,8 @@
"title", "title",
"priority", "priority",
"start_date", "start_date",
"lead", "reference_doctype",
"reference_docname",
"column_break_cqua", "column_break_cqua",
"assigned_to", "assigned_to",
"status", "status",
@ -70,15 +71,22 @@
"label": "Description" "label": "Description"
}, },
{ {
"fieldname": "lead", "default": "CRM Lead",
"fieldname": "reference_doctype",
"fieldtype": "Link", "fieldtype": "Link",
"label": "Lead", "label": "Reference Document Type",
"options": "CRM Lead" "options": "DocType"
},
{
"fieldname": "reference_docname",
"fieldtype": "Dynamic Link",
"label": "Reference Doc",
"options": "reference_doctype"
} }
], ],
"index_web_pages_for_search": 1, "index_web_pages_for_search": 1,
"links": [], "links": [],
"modified": "2023-09-28 15:05:27.986420", "modified": "2023-11-07 13:41:18.277998",
"modified_by": "Administrator", "modified_by": "Administrator",
"module": "FCRM", "module": "FCRM",
"name": "CRM Task", "name": "CRM Task",

View File

@ -592,13 +592,15 @@
v-model="showNoteModal" v-model="showNoteModal"
v-model:reloadNotes="notes" v-model:reloadNotes="notes"
:note="note" :note="note"
:lead="doc.data?.name" :doctype="doctype"
:doc="doc.data?.name"
/> />
<TaskModal <TaskModal
v-model="showTaskModal" v-model="showTaskModal"
v-model:reloadTasks="tasks" v-model:reloadTasks="tasks"
:task="task" :task="task"
:lead="doc.data?.name" :doctype="doctype"
:doc="doc.data?.name"
/> />
</template> </template>
<script setup> <script setup>
@ -652,6 +654,10 @@ const props = defineProps({
type: String, type: String,
default: 'Activity', default: 'Activity',
}, },
doctype: {
type: String,
default: 'CRM Lead',
},
}) })
const doc = defineModel() const doc = defineModel()
@ -724,7 +730,7 @@ const notes = createListResource({
doctype: 'CRM Note', doctype: 'CRM Note',
cache: ['Notes', doc.value.data.name], cache: ['Notes', doc.value.data.name],
fields: ['name', 'title', 'content', 'owner', 'modified'], fields: ['name', 'title', 'content', 'owner', 'modified'],
filters: { lead: doc.value.data.name }, filters: { reference_docname: doc.value.data.name },
orderBy: 'modified desc', orderBy: 'modified desc',
pageLength: 999, pageLength: 999,
auto: true, auto: true,
@ -745,7 +751,7 @@ const tasks = createListResource({
'status', 'status',
'modified', 'modified',
], ],
filters: { lead: doc.value.data.name }, filters: { reference_docname: doc.value.data.name },
orderBy: 'modified desc', orderBy: 'modified desc',
pageLength: 999, pageLength: 999,
auto: true, auto: true,
@ -819,7 +825,7 @@ function update_activities_details(activity) {
} }
const emptyText = computed(() => { const emptyText = computed(() => {
let text = 'No emails communications' let text = 'No email communications'
if (props.title == 'Calls') { if (props.title == 'Calls') {
text = 'No call logs' text = 'No call logs'
} else if (props.title == 'Notes') { } else if (props.title == 'Notes') {

View File

@ -50,7 +50,11 @@ const props = defineProps({
type: Object, type: Object,
default: {}, default: {},
}, },
lead: { doctype: {
type: String,
default: 'CRM Lead',
},
doc: {
type: String, type: String,
default: '', default: '',
}, },
@ -85,7 +89,8 @@ async function updateNote(close) {
doctype: 'CRM Note', doctype: 'CRM Note',
title: _note.value.title, title: _note.value.title,
content: _note.value.content, content: _note.value.content,
lead: props.lead || '', reference_doctype: props.doctype,
reference_docname: props.doc || '',
}, },
}) })
if (d.name) { if (d.name) {

View File

@ -92,15 +92,18 @@ import {
DatePicker, DatePicker,
call, call,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, defineModel, h, watch, nextTick } from 'vue' import { ref, defineModel, watch, nextTick } from 'vue'
import { get } from '@vueuse/core'
const props = defineProps({ const props = defineProps({
task: { task: {
type: Object, type: Object,
default: {}, default: {},
}, },
lead: { doctype: {
type: String,
default: 'CRM Lead',
},
doc: {
type: String, type: String,
default: '', default: '',
}, },
@ -149,7 +152,8 @@ async function updateTask(close) {
let d = await call('frappe.client.insert', { let d = await call('frappe.client.insert', {
doc: { doc: {
doctype: 'CRM Task', doctype: 'CRM Task',
lead: props.lead || null, reference_doctype: props.doctype,
reference_docname: props.doc || null,
..._task.value, ..._task.value,
}, },
}) })

View File

@ -37,7 +37,12 @@
</LayoutHeader> </LayoutHeader>
<div v-if="deal.data" class="flex h-full overflow-hidden"> <div v-if="deal.data" class="flex h-full overflow-hidden">
<Tabs v-model="tabIndex" v-slot="{ tab }" :tabs="tabs"> <Tabs v-model="tabIndex" v-slot="{ tab }" :tabs="tabs">
<Activities :title="tab.label" v-model:reload="reload" v-model="deal" /> <Activities
doctype="CRM Deal"
:title="tab.label"
v-model:reload="reload"
v-model="deal"
/>
</Tabs> </Tabs>
<div class="flex w-[352px] flex-col justify-between border-l"> <div class="flex w-[352px] flex-col justify-between border-l">
<div <div

View File

@ -41,7 +41,12 @@
</LayoutHeader> </LayoutHeader>
<div v-if="lead?.data" class="flex h-full overflow-hidden"> <div v-if="lead?.data" class="flex h-full overflow-hidden">
<Tabs v-model="tabIndex" v-slot="{ tab }" :tabs="tabs"> <Tabs v-model="tabIndex" v-slot="{ tab }" :tabs="tabs">
<Activities :title="tab.label" v-model:reload="reload" v-model="lead" /> <Activities
doctype="CRM Lead"
:title="tab.label"
v-model:reload="reload"
v-model="lead"
/>
</Tabs> </Tabs>
<div class="flex w-[352px] flex-col justify-between border-l"> <div class="flex w-[352px] flex-col justify-between border-l">
<div <div