Skip to content

Commit

Permalink
fix: added ref doc instead of lead in task/note to handle both lead a…
Browse files Browse the repository at this point in the history
…nd deal
  • Loading branch information
shariquerik committed Nov 7, 2023
1 parent a685724 commit ce4a45c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 23 deletions.
18 changes: 13 additions & 5 deletions crm/fcrm/doctype/crm_note/crm_note.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"field_order": [
"title",
"content",
"lead"
"reference_doctype",
"reference_docname"
],
"fields": [
{
Expand All @@ -27,10 +28,17 @@
"label": "Content"
},
{
"fieldname": "lead",
"default": "CRM Lead",
"fieldname": "reference_doctype",
"fieldtype": "Link",
"label": "Lead",
"options": "CRM Lead"
"label": "Reference Document Type",
"options": "DocType"
},
{
"fieldname": "reference_docname",
"fieldtype": "Dynamic Link",
"label": "Reference Doc",
"options": "reference_doctype"
}
],
"index_web_pages_for_search": 1,
Expand All @@ -40,7 +48,7 @@
"link_fieldname": "note"
}
],
"modified": "2023-08-28 11:48:42.100802",
"modified": "2023-11-07 13:41:11.249515",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Note",
Expand Down
18 changes: 13 additions & 5 deletions crm/fcrm/doctype/crm_task/crm_task.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"title",
"priority",
"start_date",
"lead",
"reference_doctype",
"reference_docname",
"column_break_cqua",
"assigned_to",
"status",
Expand Down Expand Up @@ -70,15 +71,22 @@
"label": "Description"
},
{
"fieldname": "lead",
"default": "CRM Lead",
"fieldname": "reference_doctype",
"fieldtype": "Link",
"label": "Lead",
"options": "CRM Lead"
"label": "Reference Document Type",
"options": "DocType"
},
{
"fieldname": "reference_docname",
"fieldtype": "Dynamic Link",
"label": "Reference Doc",
"options": "reference_doctype"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-09-28 15:05:27.986420",
"modified": "2023-11-07 13:41:18.277998",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM Task",
Expand Down
16 changes: 11 additions & 5 deletions frontend/src/components/Activities.vue
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,15 @@
v-model="showNoteModal"
v-model:reloadNotes="notes"
:note="note"
:lead="doc.data?.name"
:doctype="doctype"
:doc="doc.data?.name"
/>
<TaskModal
v-model="showTaskModal"
v-model:reloadTasks="tasks"
:task="task"
:lead="doc.data?.name"
:doctype="doctype"
:doc="doc.data?.name"
/>
</template>
<script setup>
Expand Down Expand Up @@ -652,6 +654,10 @@ const props = defineProps({
type: String,
default: 'Activity',
},
doctype: {
type: String,
default: 'CRM Lead',
},
})
const doc = defineModel()
Expand Down Expand Up @@ -724,7 +730,7 @@ const notes = createListResource({
doctype: 'CRM Note',
cache: ['Notes', doc.value.data.name],
fields: ['name', 'title', 'content', 'owner', 'modified'],
filters: { lead: doc.value.data.name },
filters: { reference_docname: doc.value.data.name },
orderBy: 'modified desc',
pageLength: 999,
auto: true,
Expand All @@ -745,7 +751,7 @@ const tasks = createListResource({
'status',
'modified',
],
filters: { lead: doc.value.data.name },
filters: { reference_docname: doc.value.data.name },
orderBy: 'modified desc',
pageLength: 999,
auto: true,
Expand Down Expand Up @@ -819,7 +825,7 @@ function update_activities_details(activity) {
}
const emptyText = computed(() => {
let text = 'No emails communications'
let text = 'No email communications'
if (props.title == 'Calls') {
text = 'No call logs'
} else if (props.title == 'Notes') {
Expand Down
9 changes: 7 additions & 2 deletions frontend/src/components/Modals/NoteModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,11 @@ const props = defineProps({
type: Object,
default: {},
},
lead: {
doctype: {
type: String,
default: 'CRM Lead',
},
doc: {
type: String,
default: '',
},
Expand Down Expand Up @@ -85,7 +89,8 @@ async function updateNote(close) {
doctype: 'CRM Note',
title: _note.value.title,
content: _note.value.content,
lead: props.lead || '',
reference_doctype: props.doctype,
reference_docname: props.doc || '',
},
})
if (d.name) {
Expand Down
12 changes: 8 additions & 4 deletions frontend/src/components/Modals/TaskModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,18 @@ import {
DatePicker,
call,
} from 'frappe-ui'
import { ref, defineModel, h, watch, nextTick } from 'vue'
import { get } from '@vueuse/core'
import { ref, defineModel, watch, nextTick } from 'vue'
const props = defineProps({
task: {
type: Object,
default: {},
},
lead: {
doctype: {
type: String,
default: 'CRM Lead',
},
doc: {
type: String,
default: '',
},
Expand Down Expand Up @@ -149,7 +152,8 @@ async function updateTask(close) {
let d = await call('frappe.client.insert', {
doc: {
doctype: 'CRM Task',
lead: props.lead || null,
reference_doctype: props.doctype,
reference_docname: props.doc || null,
..._task.value,
},
})
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/Deal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
</LayoutHeader>
<div v-if="deal.data" class="flex h-full overflow-hidden">
<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>
<div class="flex w-[352px] flex-col justify-between border-l">
<div
Expand Down
7 changes: 6 additions & 1 deletion frontend/src/pages/Lead.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@
</LayoutHeader>
<div v-if="lead?.data" class="flex h-full overflow-hidden">
<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>
<div class="flex w-[352px] flex-col justify-between border-l">
<div
Expand Down

0 comments on commit ce4a45c

Please sign in to comment.