fix: show notification_text in notification panel
This commit is contained in:
parent
b910045b25
commit
7b08359624
@ -1,4 +1,5 @@
|
|||||||
import frappe
|
import frappe
|
||||||
|
from frappe import _
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
def on_update(self, method):
|
def on_update(self, method):
|
||||||
@ -15,13 +16,30 @@ def notify_mentions(doc):
|
|||||||
return
|
return
|
||||||
mentions = extract_mentions(content)
|
mentions = extract_mentions(content)
|
||||||
for mention in mentions:
|
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()
|
||||||
|
notification_text = f"""
|
||||||
|
<div class="mb-2 space-x-1 leading-5 text-gray-600">
|
||||||
|
<span class="font-medium text-gray-900">
|
||||||
|
{ owner }
|
||||||
|
</span>
|
||||||
|
<span>{ _('mentioned you in {0}').format(doctype) }</span>
|
||||||
|
<span class="font-medium text-gray-900">
|
||||||
|
{ doc.reference_name }
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
values = frappe._dict(
|
values = frappe._dict(
|
||||||
doctype="CRM Notification",
|
doctype="CRM Notification",
|
||||||
from_user=doc.owner,
|
from_user=doc.owner,
|
||||||
to_user=mention.email,
|
to_user=mention.email,
|
||||||
type="Mention",
|
type="Mention",
|
||||||
message=doc.content,
|
message=doc.content,
|
||||||
comment=doc.name,
|
notification_text=notification_text,
|
||||||
|
notification_type_doctype="Comment",
|
||||||
|
notification_type_doc=doc.name,
|
||||||
reference_doctype=doc.reference_doctype,
|
reference_doctype=doc.reference_doctype,
|
||||||
reference_name=doc.reference_name,
|
reference_name=doc.reference_name,
|
||||||
)
|
)
|
||||||
|
|||||||
@ -28,6 +28,9 @@ def get_notifications():
|
|||||||
"to_user": notification.to_user,
|
"to_user": notification.to_user,
|
||||||
"read": notification.read,
|
"read": notification.read,
|
||||||
"comment": notification.comment,
|
"comment": notification.comment,
|
||||||
|
"notification_text": notification.notification_text,
|
||||||
|
"notification_type_doctype": notification.notification_type_doctype,
|
||||||
|
"notification_type_doc": notification.notification_type_doc,
|
||||||
"reference_doctype": "deal"
|
"reference_doctype": "deal"
|
||||||
if notification.reference_doctype == "CRM Deal"
|
if notification.reference_doctype == "CRM Deal"
|
||||||
else "lead",
|
else "lead",
|
||||||
|
|||||||
@ -58,11 +58,14 @@
|
|||||||
<UserAvatar :user="n.from_user.name" size="lg" />
|
<UserAvatar :user="n.from_user.name" size="lg" />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div class="mb-2 space-x-1 leading-5 text-gray-600">
|
<div v-if="n.notification_text" v-html="n.notification_text" />
|
||||||
|
<div v-else class="mb-2 space-x-1 leading-5 text-gray-600">
|
||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{ n.from_user.full_name }}
|
{{ n.from_user.full_name }}
|
||||||
</span>
|
</span>
|
||||||
<span>{{ __('mentioned you in {0}', [n.reference_doctype]) }}</span>
|
<span>
|
||||||
|
{{ __('mentioned you in {0}', [n.reference_doctype]) }}
|
||||||
|
</span>
|
||||||
<span class="font-medium text-gray-900">
|
<span class="font-medium text-gray-900">
|
||||||
{{ n.reference_name }}
|
{{ n.reference_name }}
|
||||||
</span>
|
</span>
|
||||||
@ -128,7 +131,7 @@ function getRoute(notification) {
|
|||||||
return {
|
return {
|
||||||
name: notification.route_name,
|
name: notification.route_name,
|
||||||
params: params,
|
params: params,
|
||||||
hash: '#' + notification.comment,
|
hash: '#' + notification.comment || notification.notification_type_doc,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user