fix: made notifications store generic
This commit is contained in:
parent
ace509dd80
commit
a0260bfb41
@ -31,13 +31,13 @@ def get_notifications():
|
|||||||
"notification_text": notification.notification_text,
|
"notification_text": notification.notification_text,
|
||||||
"notification_type_doctype": notification.notification_type_doctype,
|
"notification_type_doctype": notification.notification_type_doctype,
|
||||||
"notification_type_doc": notification.notification_type_doc,
|
"notification_type_doc": notification.notification_type_doc,
|
||||||
"reference_doctype": "deal"
|
"reference_doctype": (
|
||||||
if notification.reference_doctype == "CRM Deal"
|
"deal" if notification.reference_doctype == "CRM Deal" else "lead"
|
||||||
else "lead",
|
),
|
||||||
"reference_name": notification.reference_name,
|
"reference_name": notification.reference_name,
|
||||||
"route_name": "Deal"
|
"route_name": (
|
||||||
if notification.reference_doctype == "CRM Deal"
|
"Deal" if notification.reference_doctype == "CRM Deal" else "Lead"
|
||||||
else "Lead",
|
),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -45,12 +45,15 @@ def get_notifications():
|
|||||||
|
|
||||||
|
|
||||||
@frappe.whitelist()
|
@frappe.whitelist()
|
||||||
def mark_as_read(user=None, comment=None):
|
def mark_as_read(user=None, doc=None):
|
||||||
user = user or frappe.session.user
|
user = user or frappe.session.user
|
||||||
filters = {"to_user": user, "read": False}
|
filters = {"to_user": user, "read": False}
|
||||||
if comment:
|
if doc:
|
||||||
filters["comment"] = comment
|
or_filters = [
|
||||||
for n in frappe.get_all("CRM Notification", filters=filters):
|
{"comment": doc},
|
||||||
|
{"notification_type_doc": doc},
|
||||||
|
]
|
||||||
|
for n in frappe.get_all("CRM Notification", filters=filters, or_filters=or_filters):
|
||||||
d = frappe.get_doc("CRM Notification", n.name)
|
d = frappe.get_doc("CRM Notification", n.name)
|
||||||
d.read = True
|
d.read = True
|
||||||
d.save()
|
d.save()
|
||||||
|
|||||||
@ -48,7 +48,7 @@
|
|||||||
:key="n.comment"
|
:key="n.comment"
|
||||||
:to="getRoute(n)"
|
:to="getRoute(n)"
|
||||||
class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100"
|
class="flex cursor-pointer items-start gap-2.5 px-4 py-2.5 hover:bg-gray-100"
|
||||||
@click="mark_as_read(n.comment)"
|
@click="mark_as_read(n.comment || n.notification_type_doc)"
|
||||||
>
|
>
|
||||||
<div class="mt-1 flex items-center gap-2.5">
|
<div class="mt-1 flex items-center gap-2.5">
|
||||||
<div
|
<div
|
||||||
@ -120,8 +120,8 @@ function toggleNotificationPanel() {
|
|||||||
notificationsStore().toggle()
|
notificationsStore().toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
function mark_as_read(comment) {
|
function mark_as_read(doc) {
|
||||||
notificationsStore().mark_comment_as_read(comment)
|
notificationsStore().mark_doc_as_read(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getRoute(notification) {
|
function getRoute(notification) {
|
||||||
|
|||||||
@ -29,8 +29,8 @@ export const notificationsStore = defineStore('crm-notifications', () => {
|
|||||||
() => notifications.data?.filter((n) => !n.read).length || 0
|
() => notifications.data?.filter((n) => !n.read).length || 0
|
||||||
)
|
)
|
||||||
|
|
||||||
function mark_comment_as_read(comment) {
|
function mark_doc_as_read(doc) {
|
||||||
mark_as_read.params = { comment: comment }
|
mark_as_read.params = { doc: doc }
|
||||||
mark_as_read.reload()
|
mark_as_read.reload()
|
||||||
toggle()
|
toggle()
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ export const notificationsStore = defineStore('crm-notifications', () => {
|
|||||||
allNotifications,
|
allNotifications,
|
||||||
unreadNotificationsCount,
|
unreadNotificationsCount,
|
||||||
mark_as_read,
|
mark_as_read,
|
||||||
mark_comment_as_read,
|
mark_doc_as_read,
|
||||||
toggle,
|
toggle,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user