From 7962d3a89597a11edb960ec994999f9c9af3ffc4 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 14:44:08 +0530 Subject: [PATCH 1/7] fix: added statuses in form script boilerplate --- crm/fcrm/doctype/crm_form_script/crm_form_script.js | 1 + 1 file changed, 1 insertion(+) diff --git a/crm/fcrm/doctype/crm_form_script/crm_form_script.js b/crm/fcrm/doctype/crm_form_script/crm_form_script.js index 2c8c2ff1b..0fbea0bb7 100644 --- a/crm/fcrm/doctype/crm_form_script/crm_form_script.js +++ b/crm/fcrm/doctype/crm_form_script/crm_form_script.js @@ -48,6 +48,7 @@ frappe.ui.form.on("CRM Form Script", { function setupForm({ doc }) { return { actions: [], + statuses: [], } }`.trim(); } From 01cbdb9ba90edf348861822d80ef5c313b6f075a Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 14:44:32 +0530 Subject: [PATCH 2/7] fix: minor fixes in side panel layout --- frontend/src/components/SectionFields.vue | 3 +-- frontend/src/components/Settings/SidePanelModal.vue | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/SectionFields.vue b/frontend/src/components/SectionFields.vue index f2029aa20..dfaff47f2 100644 --- a/frontend/src/components/SectionFields.vue +++ b/frontend/src/components/SectionFields.vue @@ -125,7 +125,6 @@ import { computed } from 'vue' const props = defineProps({ fields: { type: Object, - required: true, }, isLastSection: { type: Boolean, @@ -146,7 +145,7 @@ const _fields = computed(() => { if (df?.depends_on) evaluate_depends_on(df.depends_on, field) all_fields.push({ ...field, - filters: df.link_filters && JSON.parse(df.link_filters), + filters: df?.link_filters && JSON.parse(df.link_filters), placeholder: field.placeholder || field.label, }) }) diff --git a/frontend/src/components/Settings/SidePanelModal.vue b/frontend/src/components/Settings/SidePanelModal.vue index 0e3665ad0..a35c74089 100644 --- a/frontend/src/components/Settings/SidePanelModal.vue +++ b/frontend/src/components/Settings/SidePanelModal.vue @@ -40,12 +40,12 @@ v-for="(section, i) in sections.data" :key="section.label" class="flex flex-col py-1.5 px-1" - :class="{ 'border-b': i !== sections.data.length - 1 }" + :class="{ 'border-b': i !== sections.data?.length - 1 }" >
From c9f3fc8e6d4f067149d9e8153444401a529f4390 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 15:10:09 +0530 Subject: [PATCH 3/7] fix: set contact as primary not working --- frontend/src/pages/Deal.vue | 2 +- frontend/src/pages/MobileDeal.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/Deal.vue b/frontend/src/pages/Deal.vue index 9429cd6cb..64eba3a08 100644 --- a/frontend/src/pages/Deal.vue +++ b/frontend/src/pages/Deal.vue @@ -607,7 +607,7 @@ function contactOptions(contact) { options.push({ label: __('Set as Primary Contact'), icon: h(SuccessIcon, { class: 'h-4 w-4' }), - onClick: () => setPrimaryContact(contact), + onClick: () => setPrimaryContact(contact.name), }) } diff --git a/frontend/src/pages/MobileDeal.vue b/frontend/src/pages/MobileDeal.vue index 08b8a54d2..b6d6e7318 100644 --- a/frontend/src/pages/MobileDeal.vue +++ b/frontend/src/pages/MobileDeal.vue @@ -522,7 +522,7 @@ function contactOptions(contact) { options.push({ label: __('Set as Primary Contact'), icon: h(SuccessIcon, { class: 'h-4 w-4' }), - onClick: () => setPrimaryContact(contact), + onClick: () => setPrimaryContact(contact.name), }) } From 9e156efe9be068c741a0d4861097f23ac3012094 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 15:25:22 +0530 Subject: [PATCH 4/7] fix: mark all as read not working --- crm/api/notifications.py | 1 + 1 file changed, 1 insertion(+) diff --git a/crm/api/notifications.py b/crm/api/notifications.py index 972fa58e9..2067b8f0c 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -48,6 +48,7 @@ def get_notifications(): def mark_as_read(user=None, doc=None): user = user or frappe.session.user filters = {"to_user": user, "read": False} + or_filters = [] if doc: or_filters = [ {"comment": doc}, From 2f58da93a635844f68adbbfe203f62269f5eb4c2 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 19:44:39 +0530 Subject: [PATCH 5/7] fix: while last opened tab is loaded instead of rerouting just update the route with hash --- frontend/src/composables/useActiveTabManager.js | 1 - frontend/src/router.js | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/frontend/src/composables/useActiveTabManager.js b/frontend/src/composables/useActiveTabManager.js index 5b9cd4848..4fffdedf1 100644 --- a/frontend/src/composables/useActiveTabManager.js +++ b/frontend/src/composables/useActiveTabManager.js @@ -46,7 +46,6 @@ export function useActiveTabManager(tabs, storageKey) { let lastVisitedTab = getActiveTabFromLocalStorage() if (lastVisitedTab) { - setActiveTabInUrl(lastVisitedTab) return getTabIndex(lastVisitedTab) } diff --git a/frontend/src/router.js b/frontend/src/router.js index 9490d4f04..2cb37387c 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -145,10 +145,16 @@ router.beforeEach(async (to, from, next) => { if (to.name === 'Home' && isLoggedIn) { next({ name: 'Leads' }) } else if (!isLoggedIn) { - window.location.href = "/login?redirect-to=/crm"; + window.location.href = '/login?redirect-to=/crm' } else if (to.matched.length === 0) { next({ name: 'Invalid Page' }) } else { + if (['Deal', 'Lead'].includes(to.name) && !to.hash) { + let storageKey = to.name === 'Deal' ? 'lastDealTab' : 'lastLeadTab' + const activeTab = localStorage.getItem(storageKey) || 'activity' + const hash = '#' + activeTab + next({ ...to, hash }) + } next() } }) From 6be83291f33d3c748485cca337eede03e39874c3 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 19:52:03 +0530 Subject: [PATCH 6/7] fix: use router instead of window.location to set hash --- frontend/src/composables/useActiveTabManager.js | 6 ++++-- frontend/src/router.js | 11 +++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/frontend/src/composables/useActiveTabManager.js b/frontend/src/composables/useActiveTabManager.js index 4fffdedf1..3de4c48fb 100644 --- a/frontend/src/composables/useActiveTabManager.js +++ b/frontend/src/composables/useActiveTabManager.js @@ -1,17 +1,19 @@ import { ref, watch } from 'vue' -import { useRoute } from 'vue-router' +import { useRoute, useRouter } from 'vue-router' import { useDebounceFn, useStorage } from '@vueuse/core' export function useActiveTabManager(tabs, storageKey) { const activieTab = useStorage(storageKey, 'activity') const route = useRoute() + const router = useRouter() const preserveLastVisitedTab = useDebounceFn((tabName) => { activieTab.value = tabName.toLowerCase() }, 300) function setActiveTabInUrl(tabName) { - window.location.hash = '#' + tabName.toLowerCase() + let hash = '#' + tabName.toLowerCase() + router.push({ ...route, hash }) } function getActiveTabFromUrl() { diff --git a/frontend/src/router.js b/frontend/src/router.js index 2cb37387c..3c7e9604e 100644 --- a/frontend/src/router.js +++ b/frontend/src/router.js @@ -148,13 +148,12 @@ router.beforeEach(async (to, from, next) => { window.location.href = '/login?redirect-to=/crm' } else if (to.matched.length === 0) { next({ name: 'Invalid Page' }) + } else if (['Deal', 'Lead'].includes(to.name) && !to.hash) { + let storageKey = to.name === 'Deal' ? 'lastDealTab' : 'lastLeadTab' + const activeTab = localStorage.getItem(storageKey) || 'activity' + const hash = '#' + activeTab + next({ ...to, hash }) } else { - if (['Deal', 'Lead'].includes(to.name) && !to.hash) { - let storageKey = to.name === 'Deal' ? 'lastDealTab' : 'lastLeadTab' - const activeTab = localStorage.getItem(storageKey) || 'activity' - const hash = '#' + activeTab - next({ ...to, hash }) - } next() } }) From 371a903ad7bb91d52bf2af99bfb3f921faa510b9 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Sat, 28 Sep 2024 21:34:03 +0530 Subject: [PATCH 7/7] fix: show placeholder in fields from docfield --- crm/api/doc.py | 5 +++-- crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crm/api/doc.py b/crm/api/doc.py index 84a84458f..de1b82dc7 100644 --- a/crm/api/doc.py +++ b/crm/api/doc.py @@ -611,10 +611,10 @@ def get_field_obj(field): "all_properties": field, } - obj["placeholder"] = "Add " + field.label + "..." + obj["placeholder"] = field.placeholder or "Add " + field.label + "..." if field.fieldtype == "Link": - obj["placeholder"] = "Select " + field.label + "..." + obj["placeholder"] = field.placeholder or "Select " + field.label + "..." obj["doctype"] = field.options elif field.fieldtype == "Select" and field.options: obj["options"] = [{"label": option, "value": option} for option in field.options.split("\n")] @@ -686,6 +686,7 @@ def get_fields(doctype: str, allow_all_fieldtypes: bool = False): "mandatory_depends_on": field.mandatory_depends_on, "read_only_depends_on": field.read_only_depends_on, "link_filters": field.get("link_filters"), + "placeholder": field.placeholder, }) return _fields diff --git a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py index 3129c4780..72bbcf78d 100644 --- a/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py +++ b/crm/fcrm/doctype/crm_fields_layout/crm_fields_layout.py @@ -44,6 +44,7 @@ def get_fields_layout(doctype: str, type: str): "type": field.fieldtype, "options": field.options, "mandatory": field.reqd, + "placeholder": field.placeholder, } section["fields"][section.get("fields").index(field["name"])] = field