From 674bb28239e3a7518472aad0f5cea6e3064fb417 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 30 Sep 2024 11:45:28 +0530 Subject: [PATCH 1/9] fix: notification text is not getting set --- crm/api/comment.py | 4 +++- crm/api/todo.py | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/crm/api/comment.py b/crm/api/comment.py index 7aa2fee5..7d78f0d4 100644 --- a/crm/api/comment.py +++ b/crm/api/comment.py @@ -18,16 +18,18 @@ def notify_mentions(doc): if not content: return mentions = extract_mentions(content) + reference_doc = frappe.get_doc(doc.reference_doctype, doc.reference_name) for mention in mentions: owner = frappe.get_cached_value("User", doc.owner, "full_name") doctype = doc.reference_doctype if doctype.startswith("CRM "): doctype = doctype[4:].lower() + name = reference_doc.lead_name or name if doctype == "lead" else reference_doc.organization or reference_doc.lead_name or name notification_text = f"""
{ owner } { _('mentioned you in {0}').format(doctype) } - { doc.reference_name } + { name }
""" notify_user({ diff --git a/crm/api/todo.py b/crm/api/todo.py index e4bb50b5..f30e19f4 100644 --- a/crm/api/todo.py +++ b/crm/api/todo.py @@ -52,8 +52,8 @@ def get_notification_text(owner, doc, reference_doc, is_cancelled=False): if doctype.startswith("CRM "): doctype = doctype[4:].lower() - if doctype in ["CRM Lead", "CRM Deal"]: - name = reference_doc.lead_name or name if doctype == "CRM Lead" else reference_doc.organization or reference_doc.lead_name or name + if doctype in ["lead", "deal"]: + name = reference_doc.lead_name or name if doctype == "lead" else reference_doc.organization or reference_doc.lead_name or name if is_cancelled: return f""" @@ -76,7 +76,7 @@ def get_notification_text(owner, doc, reference_doc, is_cancelled=False): """ - if doc.reference_type == "CRM Task": + if doctype == "task": if is_cancelled: return f"""
From cd4b87a067240140b4ad5b039d63a1f3c9e3a82c Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 30 Sep 2024 13:16:54 +0530 Subject: [PATCH 2/9] fix: redirect to specific comment or tab on click --- crm/api/notifications.py | 16 +++++++++++++++- frontend/src/components/Notifications.vue | 3 ++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/crm/api/notifications.py b/crm/api/notifications.py index 2067b8f0..afe495db 100644 --- a/crm/api/notifications.py +++ b/crm/api/notifications.py @@ -27,7 +27,7 @@ def get_notifications(): "type": notification.type, "to_user": notification.to_user, "read": notification.read, - "comment": notification.comment, + "hash": get_hash(notification), "notification_text": notification.notification_text, "notification_type_doctype": notification.notification_type_doctype, "notification_type_doc": notification.notification_type_doc, @@ -58,3 +58,17 @@ def mark_as_read(user=None, doc=None): d = frappe.get_doc("CRM Notification", n.name) d.read = True d.save() + +def get_hash(notification): + _hash = "" + if notification.type == "Mention" and notification.notification_type_doc: + _hash = "#" + notification.notification_type_doc + + if notification.type == "WhatsApp": + _hash = "#whatsapp" + + if notification.type == "Assignment" and notification.notification_type_doctype == "CRM Task": + _hash = "#tasks" + if "has been removed by" in notification.message: + _hash = "" + return _hash \ No newline at end of file diff --git a/frontend/src/components/Notifications.vue b/frontend/src/components/Notifications.vue index 74c2eca3..872e743b 100644 --- a/frontend/src/components/Notifications.vue +++ b/frontend/src/components/Notifications.vue @@ -147,10 +147,11 @@ function getRoute(notification) { dealId: notification.reference_name, } } + return { name: notification.route_name, params: params, - hash: '#' + notification.comment || notification.notification_type_doc, + hash: notification.hash, } } From 5c3196fb3db6fedf61ff781734b1744669360e17 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Mon, 30 Sep 2024 13:17:53 +0530 Subject: [PATCH 3/9] fix: redirect to notes/tasks tab if created from activity tab --- frontend/src/components/Activities/AllModals.vue | 16 ++++++++++++++++ frontend/src/components/Modals/TaskModal.vue | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/frontend/src/components/Activities/AllModals.vue b/frontend/src/components/Activities/AllModals.vue index b8b4a2c4..1217b039 100644 --- a/frontend/src/components/Activities/AllModals.vue +++ b/frontend/src/components/Activities/AllModals.vue @@ -5,6 +5,7 @@ :task="task" :doctype="doctype" :doc="doc.data?.name" + @after="redirect('tasks')" />