fix: notification badge not clearing on click and missing on sidebar
This commit is contained in:
parent
c5aa51a7e6
commit
7111e942f2
2 changed files with 27 additions and 20 deletions
|
|
@ -131,6 +131,19 @@ frappe.ui.Notifications = class Notifications {
|
||||||
frappe.call("frappe.desk.doctype.notification_log.notification_log.mark_all_as_read");
|
frappe.call("frappe.desk.doctype.notification_log.notification_log.mark_all_as_read");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mark_notifications_as_seen() {
|
||||||
|
if ($(".notification-badge").length === 0) return;
|
||||||
|
$(".notification-badge").remove();
|
||||||
|
this.notification_settings.seen = 1;
|
||||||
|
frappe.call(
|
||||||
|
"frappe.desk.doctype.notification_settings.notification_settings.set_seen_value",
|
||||||
|
{ value: 1, user: frappe.session.user }
|
||||||
|
);
|
||||||
|
frappe.call(
|
||||||
|
"frappe.desk.doctype.notification_log.notification_log.trigger_indicator_hide"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
setup_dropdown_events() {
|
setup_dropdown_events() {
|
||||||
const dropdown = this.dropdown;
|
const dropdown = this.dropdown;
|
||||||
const full_height = this.full_height;
|
const full_height = this.full_height;
|
||||||
|
|
@ -144,6 +157,16 @@ frappe.ui.Notifications = class Notifications {
|
||||||
$(e.currentTarget).data("closable", true);
|
$(e.currentTarget).data("closable", true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.dropdown.on("show.bs.dropdown", () => {
|
||||||
|
this.mark_notifications_as_seen();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.full_height) {
|
||||||
|
this.wrapper.find(".sidebar-notification").on("click", () => {
|
||||||
|
this.mark_notifications_as_seen();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(document).on("click", function (e) {
|
$(document).on("click", function (e) {
|
||||||
const isInsideNotificationBtn =
|
const isInsideNotificationBtn =
|
||||||
$(e.target).closest(".standard-items-sections .sidebar-notification").length > 0;
|
$(e.target).closest(".standard-items-sections .sidebar-notification").length > 0;
|
||||||
|
|
@ -400,16 +423,6 @@ class NotificationsView extends BaseNotificationsView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_seen(flag) {
|
|
||||||
frappe.call(
|
|
||||||
"frappe.desk.doctype.notification_settings.notification_settings.set_seen_value",
|
|
||||||
{
|
|
||||||
value: cint(flag),
|
|
||||||
user: frappe.session.user,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
setup_notification_listeners() {
|
setup_notification_listeners() {
|
||||||
frappe.realtime.on("notification", () => {
|
frappe.realtime.on("notification", () => {
|
||||||
this.toggle_notification_icon(false);
|
this.toggle_notification_icon(false);
|
||||||
|
|
@ -419,16 +432,6 @@ class NotificationsView extends BaseNotificationsView {
|
||||||
frappe.realtime.on("indicator_hide", () => {
|
frappe.realtime.on("indicator_hide", () => {
|
||||||
this.toggle_notification_icon(true);
|
this.toggle_notification_icon(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("click", ".sidebar-notification, .desktop-notification-icon", () => {
|
|
||||||
if ($(".notification-badge").length > 0) {
|
|
||||||
this.toggle_notification_icon(true);
|
|
||||||
this.toggle_seen(true);
|
|
||||||
frappe.call(
|
|
||||||
"frappe.desk.doctype.notification_log.notification_log.trigger_indicator_hide"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sidebar-notification .item-anchor {
|
||||||
|
overflow: visible;
|
||||||
|
}
|
||||||
|
|
||||||
.notification-badge {
|
.notification-badge {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue