From 5058c5a55395806052a5e40f91bd6d3dfd96b319 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 29 Nov 2023 12:57:48 +0530 Subject: [PATCH 1/6] fix: added crm lead/deal status doctype --- crm/fcrm/doctype/crm_deal_status/__init__.py | 0 .../crm_deal_status/crm_deal_status.js | 8 +++ .../crm_deal_status/crm_deal_status.json | 62 ++++++++++++++++++ .../crm_deal_status/crm_deal_status.py | 9 +++ .../crm_deal_status/test_crm_deal_status.py | 9 +++ crm/fcrm/doctype/crm_lead_status/__init__.py | 0 .../crm_lead_status/crm_lead_status.js | 8 +++ .../crm_lead_status/crm_lead_status.json | 63 +++++++++++++++++++ .../crm_lead_status/crm_lead_status.py | 9 +++ .../crm_lead_status/test_crm_lead_status.py | 9 +++ 10 files changed, 177 insertions(+) create mode 100644 crm/fcrm/doctype/crm_deal_status/__init__.py create mode 100644 crm/fcrm/doctype/crm_deal_status/crm_deal_status.js create mode 100644 crm/fcrm/doctype/crm_deal_status/crm_deal_status.json create mode 100644 crm/fcrm/doctype/crm_deal_status/crm_deal_status.py create mode 100644 crm/fcrm/doctype/crm_deal_status/test_crm_deal_status.py create mode 100644 crm/fcrm/doctype/crm_lead_status/__init__.py create mode 100644 crm/fcrm/doctype/crm_lead_status/crm_lead_status.js create mode 100644 crm/fcrm/doctype/crm_lead_status/crm_lead_status.json create mode 100644 crm/fcrm/doctype/crm_lead_status/crm_lead_status.py create mode 100644 crm/fcrm/doctype/crm_lead_status/test_crm_lead_status.py diff --git a/crm/fcrm/doctype/crm_deal_status/__init__.py b/crm/fcrm/doctype/crm_deal_status/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.js b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.js new file mode 100644 index 00000000..5033645f --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("CRM Deal Status", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json new file mode 100644 index 00000000..d683bf68 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.json @@ -0,0 +1,62 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:deal_status", + "creation": "2023-11-29 11:24:55.543387", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "deal_status", + "color", + "position" + ], + "fields": [ + { + "default": "gray", + "fieldname": "color", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Color", + "options": "black\ngray\nblue\ngreen\nred\npink\norange\namber\nyellow\ncyan\nteal\nviolet\npurple" + }, + { + "fieldname": "deal_status", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Status", + "reqd": 1, + "unique": 1 + }, + { + "fieldname": "position", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Position" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-11-29 12:52:03.070218", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Deal Status", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_deal_status/crm_deal_status.py b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.py new file mode 100644 index 00000000..4386d698 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_status/crm_deal_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class CRMDealStatus(Document): + pass diff --git a/crm/fcrm/doctype/crm_deal_status/test_crm_deal_status.py b/crm/fcrm/doctype/crm_deal_status/test_crm_deal_status.py new file mode 100644 index 00000000..b5463dc1 --- /dev/null +++ b/crm/fcrm/doctype/crm_deal_status/test_crm_deal_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestCRMDealStatus(FrappeTestCase): + pass diff --git a/crm/fcrm/doctype/crm_lead_status/__init__.py b/crm/fcrm/doctype/crm_lead_status/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/crm/fcrm/doctype/crm_lead_status/crm_lead_status.js b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.js new file mode 100644 index 00000000..24b63188 --- /dev/null +++ b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.js @@ -0,0 +1,8 @@ +// Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +// For license information, please see license.txt + +// frappe.ui.form.on("CRM Lead Status", { +// refresh(frm) { + +// }, +// }); diff --git a/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json new file mode 100644 index 00000000..a13281ba --- /dev/null +++ b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.json @@ -0,0 +1,63 @@ +{ + "actions": [], + "allow_rename": 1, + "autoname": "field:lead_status", + "creation": "2023-11-29 11:09:53.678414", + "doctype": "DocType", + "engine": "InnoDB", + "field_order": [ + "lead_status", + "color", + "position" + ], + "fields": [ + { + "default": "gray", + "fieldname": "color", + "fieldtype": "Select", + "in_list_view": 1, + "label": "Color", + "options": "black\ngray\nblue\ngreen\nred\npink\norange\namber\nyellow\ncyan\nteal\nviolet\npurple" + }, + { + "fieldname": "lead_status", + "fieldtype": "Data", + "in_list_view": 1, + "label": "Status", + "reqd": 1, + "unique": 1 + }, + { + "default": "1", + "fieldname": "position", + "fieldtype": "Int", + "in_list_view": 1, + "label": "Position" + } + ], + "index_web_pages_for_search": 1, + "links": [], + "modified": "2023-11-29 12:52:25.641581", + "modified_by": "Administrator", + "module": "FCRM", + "name": "CRM Lead Status", + "naming_rule": "By fieldname", + "owner": "Administrator", + "permissions": [ + { + "create": 1, + "delete": 1, + "email": 1, + "export": 1, + "print": 1, + "read": 1, + "report": 1, + "role": "System Manager", + "share": 1, + "write": 1 + } + ], + "sort_field": "modified", + "sort_order": "DESC", + "states": [] +} \ No newline at end of file diff --git a/crm/fcrm/doctype/crm_lead_status/crm_lead_status.py b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.py new file mode 100644 index 00000000..d4c8a332 --- /dev/null +++ b/crm/fcrm/doctype/crm_lead_status/crm_lead_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and contributors +# For license information, please see license.txt + +# import frappe +from frappe.model.document import Document + + +class CRMLeadStatus(Document): + pass diff --git a/crm/fcrm/doctype/crm_lead_status/test_crm_lead_status.py b/crm/fcrm/doctype/crm_lead_status/test_crm_lead_status.py new file mode 100644 index 00000000..9cb24fd4 --- /dev/null +++ b/crm/fcrm/doctype/crm_lead_status/test_crm_lead_status.py @@ -0,0 +1,9 @@ +# Copyright (c) 2023, Frappe Technologies Pvt. Ltd. and Contributors +# See license.txt + +# import frappe +from frappe.tests.utils import FrappeTestCase + + +class TestCRMLeadStatus(FrappeTestCase): + pass From cf2868953d473b498989c1ac6f58af93696828d4 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 29 Nov 2023 12:59:09 +0530 Subject: [PATCH 2/6] fix: changed lead/deal status from select to link field --- crm/fcrm/doctype/crm_deal/crm_deal.json | 6 +++--- crm/fcrm/doctype/crm_lead/crm_lead.json | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crm/fcrm/doctype/crm_deal/crm_deal.json b/crm/fcrm/doctype/crm_deal/crm_deal.json index cefe2e2e..4cf453ea 100644 --- a/crm/fcrm/doctype/crm_deal/crm_deal.json +++ b/crm/fcrm/doctype/crm_deal/crm_deal.json @@ -111,10 +111,10 @@ { "default": "Qualification", "fieldname": "status", - "fieldtype": "Select", + "fieldtype": "Link", "in_list_view": 1, "label": "Status", - "options": "Qualification\nDemo/Making\nProposal/Quotation\nNegotiation\nReady to Close\nWon\nLost", + "options": "CRM Deal Status", "reqd": 1, "search_index": 1 }, @@ -138,7 +138,7 @@ ], "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-24 16:50:07.177125", + "modified": "2023-11-29 11:31:46.968519", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Deal", diff --git a/crm/fcrm/doctype/crm_lead/crm_lead.json b/crm/fcrm/doctype/crm_lead/crm_lead.json index 8a60704d..300f9901 100644 --- a/crm/fcrm/doctype/crm_lead/crm_lead.json +++ b/crm/fcrm/doctype/crm_lead/crm_lead.json @@ -74,10 +74,10 @@ { "default": "Open", "fieldname": "status", - "fieldtype": "Select", + "fieldtype": "Link", "in_list_view": 1, "label": "Status", - "options": "Open\nContacted\nNurture\nQualified\nUnqualified\nJunk", + "options": "CRM Lead Status", "reqd": 1, "search_index": 1 }, @@ -201,7 +201,7 @@ "image_field": "image", "index_web_pages_for_search": 1, "links": [], - "modified": "2023-11-24 16:38:36.695965", + "modified": "2023-11-29 11:31:08.555096", "modified_by": "Administrator", "module": "FCRM", "name": "CRM Lead", From f6adadf040e3a452407e30ba9fe1bd9f505e14cd Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 29 Nov 2023 13:00:00 +0530 Subject: [PATCH 3/6] fix: created store for lead/deal statuses --- frontend/src/stores/statuses.js | 79 +++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 frontend/src/stores/statuses.js diff --git a/frontend/src/stores/statuses.js b/frontend/src/stores/statuses.js new file mode 100644 index 00000000..fc9d840c --- /dev/null +++ b/frontend/src/stores/statuses.js @@ -0,0 +1,79 @@ +import { defineStore } from 'pinia' +import { createListResource } from 'frappe-ui' +import { reactive, h } from 'vue' +import IndicatorIcon from '@/components/Icons/IndicatorIcon.vue' + +export const statusesStore = defineStore('crm-statuses', () => { + let leadStatusesByName = reactive({}) + let dealStatusesByName = reactive({}) + + const leadStatuses = createListResource({ + doctype: 'CRM Lead Status', + fields: ['name', 'color', 'position'], + orderBy: 'position asc', + cache: 'lead-statuses', + initialData: [], + auto: true, + transform(statuses) { + for (let status of statuses) { + status.color = + status.color == 'black' + ? '!text-gray-900' + : `!text-${status.color}-600` + leadStatusesByName[status.name] = status + } + return statuses + }, + }) + + const dealStatuses = createListResource({ + doctype: 'CRM Deal Status', + fields: ['name', 'color', 'position'], + orderBy: 'position asc', + cache: 'deal-statuses', + initialData: [], + auto: true, + transform(statuses) { + for (let status of statuses) { + status.color = + status.color == 'black' + ? '!text-gray-900' + : `!text-${status.color}-600` + dealStatusesByName[status.name] = status + } + return statuses + }, + }) + + function getLeadStatus(name) { + return leadStatusesByName[name] + } + + function getDealStatus(name) { + return dealStatusesByName[name] + } + + function statusOptions(doctype, action) { + let statusesByName = + doctype == 'deal' ? dealStatusesByName : leadStatusesByName + let options = [] + for (const status in statusesByName) { + options.push({ + label: statusesByName[status].name, + icon: () => h(IndicatorIcon, { class: statusesByName[status].color }), + onClick: () => { + action && action('status', statusesByName[status].name) + }, + }) + } + return options + } + + return { + leadStatuses, + dealStatuses, + getLeadStatus, + getDealStatus, + statusOptions, + } +}) From dd87502829f64a2453f3d1d7651ba448b28f911b Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Wed, 29 Nov 2023 13:03:01 +0530 Subject: [PATCH 4/6] fix: replaced hardcoded lead/deal status with status store --- frontend/src/components/NewDeal.vue | 12 +++--- frontend/src/components/NewLead.vue | 12 +++--- frontend/src/pages/CallLog.vue | 3 +- frontend/src/pages/Contact.vue | 8 ++-- frontend/src/pages/Deal.vue | 20 ++++------ frontend/src/pages/Deals.vue | 7 ++-- frontend/src/pages/Lead.vue | 16 +++----- frontend/src/pages/Leads.vue | 14 +++---- frontend/src/pages/Organization.vue | 10 ++--- frontend/src/utils/index.js | 62 ----------------------------- 10 files changed, 47 insertions(+), 117 deletions(-) diff --git a/frontend/src/components/NewDeal.vue b/frontend/src/components/NewDeal.vue index b31baaf8..b9d3b324 100644 --- a/frontend/src/components/NewDeal.vue +++ b/frontend/src/components/NewDeal.vue @@ -11,7 +11,7 @@ v-model="newDeal[field.name]" >