Merge pull request #35052 from iamejaaz/move-notification-to-sidebar
feat: move notification to sidebar
This commit is contained in:
commit
bea30458b8
10 changed files with 106 additions and 44 deletions
|
|
@ -99,7 +99,9 @@ context("Form", () => {
|
|||
cy.new_form("User");
|
||||
|
||||
jump_to_field("Location"); // this is in collapsed section
|
||||
cy.wait(500);
|
||||
type_value("Bermuda");
|
||||
cy.wait(500);
|
||||
|
||||
cy.get_field("location").should("have.value", "Bermuda");
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,7 +8,8 @@ frappe.ui.Notifications = class Notifications {
|
|||
}
|
||||
|
||||
make() {
|
||||
this.dropdown = $(".navbar").find(".dropdown-notifications").removeClass("hidden");
|
||||
$(".standard-items-sections").find(".sidebar-notification").removeClass("hidden");
|
||||
this.dropdown = $(".standard-items-sections").find(".dropdown-notifications");
|
||||
this.dropdown_list = this.dropdown.find(".notifications-list");
|
||||
this.header_items = this.dropdown_list.find(".header-items");
|
||||
this.header_actions = this.dropdown_list.find(".header-actions");
|
||||
|
|
@ -25,19 +26,19 @@ frappe.ui.Notifications = class Notifications {
|
|||
|
||||
setup_headers() {
|
||||
// Add header actions
|
||||
$(`<span class="notification-settings pull-right" data-action="go_to_settings">
|
||||
$(`<span class="notification-settings" data-action="go_to_settings">
|
||||
${frappe.utils.icon("setting-gear")}
|
||||
</span>`)
|
||||
.on("click", (e) => {
|
||||
e.stopImmediatePropagation();
|
||||
this.dropdown.dropdown("hide");
|
||||
console.log("what");
|
||||
frappe.set_route("Form", "Notification Settings", frappe.session.user);
|
||||
})
|
||||
.appendTo(this.header_actions)
|
||||
.attr("title", __("Notification Settings"))
|
||||
.tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" });
|
||||
|
||||
$(`<span class="mark-all-read pull-right" data-action="mark_all_as_read">
|
||||
$(`<span class="mark-all-read" data-action="mark_all_as_read">
|
||||
${frappe.utils.icon("mark-as-read")}
|
||||
</span>`)
|
||||
.on("click", (e) => this.mark_all_as_read(e))
|
||||
|
|
@ -45,6 +46,16 @@ frappe.ui.Notifications = class Notifications {
|
|||
.attr("title", __("Mark all as read"))
|
||||
.tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" });
|
||||
|
||||
$(`<span class="close-notification-dialogue pull-right">
|
||||
${frappe.utils.icon("x")}
|
||||
</span>`)
|
||||
.on("click", (e) => {
|
||||
this.dropdown.addClass("hidden");
|
||||
})
|
||||
.appendTo(this.header_actions)
|
||||
.attr("title", __("Close"))
|
||||
.tooltip({ delay: { show: 600, hide: 100 }, trigger: "hover" });
|
||||
|
||||
this.categories = [
|
||||
{
|
||||
label: __("Notifications"),
|
||||
|
|
@ -118,6 +129,7 @@ frappe.ui.Notifications = class Notifications {
|
|||
}
|
||||
|
||||
setup_dropdown_events() {
|
||||
const dropdown = this.dropdown;
|
||||
this.dropdown.on("hide.bs.dropdown", (e) => {
|
||||
let hide = $(e.currentTarget).data("closable");
|
||||
$(e.currentTarget).data("closable", true);
|
||||
|
|
@ -127,6 +139,25 @@ frappe.ui.Notifications = class Notifications {
|
|||
this.dropdown.on("click", (e) => {
|
||||
$(e.currentTarget).data("closable", true);
|
||||
});
|
||||
|
||||
$(document).on("click", function (e) {
|
||||
const isInsideNotificationBtn =
|
||||
$(e.target).closest(".standard-items-sections .sidebar-notification").length > 0;
|
||||
const isInsideDropdown = $(e.target).closest(".notifications-list").length > 0;
|
||||
|
||||
if (!isInsideNotificationBtn && !isInsideDropdown) {
|
||||
dropdown.addClass("hidden");
|
||||
}
|
||||
});
|
||||
|
||||
dropdown.find(".notification-item").on("click", (e) => {
|
||||
dropdown.addClass("hidden");
|
||||
});
|
||||
$(document).on("page-change", function () {
|
||||
if (dropdown && dropdown.length) {
|
||||
dropdown.addClass("hidden");
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,21 @@
|
|||
<div class="body-sidebar-container {%= expanded ? 'expanded' : ''%}">
|
||||
<div class="body-sidebar-placeholder"></div>
|
||||
<div class="body-sidebar">
|
||||
<div class="standard-items-sections"></div>
|
||||
<div class="standard-items-sections">
|
||||
<div class="dropdown-notifications hidden">
|
||||
<div class="notifications-list" role="menu">
|
||||
<div class="notification-list-header">
|
||||
<div class="header-items"></div>
|
||||
<div class="header-actions"></div>
|
||||
</div>
|
||||
<div class="notification-list-body">
|
||||
<div class="panel-notifications"></div>
|
||||
<div class="panel-events"></div>
|
||||
<div class="panel-changelog-feed"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="body-sidebar-top">
|
||||
<div class="sidebar-items">
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -248,10 +248,23 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
class: "navbar-search-bar hidden",
|
||||
});
|
||||
}
|
||||
this.standard_items.push({
|
||||
label: "Notification",
|
||||
icon: "bell",
|
||||
type: "Button",
|
||||
class: "sidebar-notification hidden",
|
||||
onClick: () => {
|
||||
this.wrapper.find(".dropdown-notifications").toggleClass("hidden");
|
||||
if (frappe.is_mobile()) {
|
||||
this.wrapper.removeClass("expanded");
|
||||
}
|
||||
},
|
||||
});
|
||||
this.standard_items.forEach((w) => {
|
||||
this.add_item(this.$standard_items_sections, w);
|
||||
});
|
||||
this.setup_awesomebar();
|
||||
this.setup_notifications();
|
||||
this.standard_items_setup = true;
|
||||
}
|
||||
setup_awesomebar() {
|
||||
|
|
@ -270,6 +283,11 @@ frappe.ui.Sidebar = class Sidebar {
|
|||
}
|
||||
}
|
||||
}
|
||||
setup_notifications() {
|
||||
if (frappe.boot.desk_settings.notifications && frappe.session.user !== "Guest") {
|
||||
this.notifications = new frappe.ui.Notifications();
|
||||
}
|
||||
}
|
||||
add_item(container, item) {
|
||||
this.items.push(
|
||||
this.make_sidebar_item({
|
||||
|
|
|
|||
|
|
@ -382,6 +382,7 @@ frappe.ui.sidebar_item.TypeButton = class SidebarButton extends frappe.ui.sideba
|
|||
super(item);
|
||||
this.title = frappe.app.sidebar.workspace_title;
|
||||
this.item.id && this.wrapper.attr("id", this.item.id);
|
||||
this.item.class && this.wrapper.attr("class", this.item.class);
|
||||
this.wrapper.attr("title", this.item.label);
|
||||
this.setup_click();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ frappe.provide("frappe.tags");
|
|||
|
||||
frappe.search.AwesomeBar = class AwesomeBar {
|
||||
setup(element) {
|
||||
$(".search-bar").removeClass("hidden");
|
||||
$(".search-bar, .navbar-search-bar").removeClass("hidden");
|
||||
|
||||
this.options = [];
|
||||
this.global_results = [];
|
||||
|
|
|
|||
|
|
@ -26,34 +26,6 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<ul class="navbar-nav">
|
||||
<li class="nav-item dropdown dropdown-notifications dropdown-mobile hidden">
|
||||
<button
|
||||
class="btn-reset nav-link notifications-icon text-muted"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="false"
|
||||
>
|
||||
<span class="notifications-seen">
|
||||
<span class="sr-only">{{ __("No new notifications") }}</span>
|
||||
<svg class="es-icon icon-sm" style="stroke:none;"><use href="#es-line-notifications"></use></svg>
|
||||
</span>
|
||||
<span class="notifications-unseen">
|
||||
<span class="sr-only">{{ __("You have unseen notifications") }}</span>
|
||||
<svg class="es-icon icon-sm"><use href="#es-line-notifications-unseen"></use></svg>
|
||||
</span>
|
||||
</button>
|
||||
<div class="dropdown-menu notifications-list dropdown-menu-right" role="menu">
|
||||
<div class="notification-list-header">
|
||||
<div class="header-items"></div>
|
||||
<div class="header-actions"></div>
|
||||
</div>
|
||||
<div class="notification-list-body">
|
||||
<div class="panel-notifications"></div>
|
||||
<div class="panel-events"></div>
|
||||
<div class="panel-changelog-feed"></div>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li class="nav-item dropdown dropdown-message dropdown-mobile hidden">
|
||||
<button
|
||||
class="btn-reset nav-link notifications-icon text-muted"
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ frappe.ui.toolbar.Toolbar = class {
|
|||
});
|
||||
|
||||
// this.setup_awesomebar();
|
||||
this.setup_notifications();
|
||||
this.setup_help();
|
||||
this.setup_read_only_mode();
|
||||
this.setup_announcement_widget();
|
||||
|
|
@ -181,12 +180,6 @@ frappe.ui.toolbar.Toolbar = class {
|
|||
}
|
||||
}
|
||||
|
||||
setup_notifications() {
|
||||
if (frappe.boot.desk_settings.notifications && frappe.session.user !== "Guest") {
|
||||
this.notifications = new frappe.ui.Notifications();
|
||||
}
|
||||
}
|
||||
|
||||
add_back_button() {
|
||||
if (!frappe.is_mobile()) return;
|
||||
this.navbar = $(".navbar-brand");
|
||||
|
|
|
|||
|
|
@ -14,12 +14,20 @@
|
|||
|
||||
.mark-all-read {
|
||||
margin-top: 2px;
|
||||
margin-right: 15px;
|
||||
margin-right: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.close-notification-dialogue {
|
||||
cursor: pointer;
|
||||
.icon {
|
||||
stroke-width: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.notification-settings {
|
||||
margin-top: 2px;
|
||||
margin-right: 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +59,11 @@
|
|||
padding: 0px;
|
||||
min-height: 480px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
box-shadow: var(--shadow-2xl);
|
||||
background-color: var(--bg-color);
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
|
||||
.notification-list-header {
|
||||
margin: 0px 10px;
|
||||
|
|
@ -60,9 +72,8 @@
|
|||
}
|
||||
|
||||
.notification-list-body {
|
||||
// margin: 10px 0px;
|
||||
max-height: 450px;
|
||||
overflow-y: auto;
|
||||
height: 93%;
|
||||
|
||||
.panel-events,
|
||||
.panel-notifications {
|
||||
|
|
|
|||
|
|
@ -155,6 +155,14 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.standard-items-sections {
|
||||
.dropdown-notifications {
|
||||
.notifications-list {
|
||||
left: 3.4%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@mixin body-sidebar-expanded {
|
||||
|
|
@ -162,6 +170,11 @@
|
|||
// make it an overlay on hover
|
||||
position: absolute;
|
||||
width: var(--sidebar-width);
|
||||
.dropdown-notifications {
|
||||
.notifications-list {
|
||||
left: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// show placeholder so that main section remains static
|
||||
|
|
@ -182,6 +195,13 @@
|
|||
padding: 0px;
|
||||
width: 0px;
|
||||
overflow: hidden;
|
||||
.standard-items-sections {
|
||||
.dropdown-notifications {
|
||||
.notifications-list {
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue