feat: Init unified desk [WIP]

This commit is contained in:
Suraj Shetty 2020-11-05 12:32:51 +05:30
parent 34a32061c6
commit cdcfe844cb
3 changed files with 110 additions and 7 deletions

View file

@ -88,6 +88,7 @@ def get_bootinfo():
bootinfo.frequently_visited_links = frequently_visited_links()
bootinfo.link_preview_doctypes = get_link_preview_doctypes()
bootinfo.additional_filters_config = get_additional_filters_from_hooks()
bootinfo.desk_settings = get_desk_settings()
return bootinfo
@ -308,3 +309,17 @@ def get_additional_filters_from_hooks():
return filter_config
def get_desk_settings():
role_list = frappe.get_all('Role', fields=['*'], filters=dict(
name=['in', frappe.get_roles()]
))
desk_settings = {}
desk_properties = ("search_bar", "notification", "chat", "list_sidebar",
"bulk_actions", "view_switcher", "form_sidebar", "timeline", "dashboard")
for role in role_list:
for key in desk_properties:
desk_settings[key] = desk_settings[key] or role[key]
return desk_settings

View file

@ -13,7 +13,19 @@
"column_break_4",
"disabled",
"desk_access",
"two_factor_auth"
"two_factor_auth",
"navigation_settings_section",
"search_bar",
"notification",
"chat",
"list_settings_section",
"list_sidebar",
"bulk_actions",
"view_switcher",
"form_settings_section",
"form_sidebar",
"timeline",
"dashboard"
],
"fields": [
{
@ -60,12 +72,82 @@
{
"fieldname": "column_break_4",
"fieldtype": "Column Break"
},
{
"fieldname": "navigation_settings_section",
"fieldtype": "Section Break",
"label": "Navigation Settings"
},
{
"default": "0",
"fieldname": "search_bar",
"fieldtype": "Check",
"label": "Search Bar"
},
{
"default": "0",
"fieldname": "notification",
"fieldtype": "Check",
"label": "Notification"
},
{
"default": "1",
"fieldname": "chat",
"fieldtype": "Check",
"label": "Chat"
},
{
"fieldname": "list_settings_section",
"fieldtype": "Section Break",
"label": "List Settings"
},
{
"default": "0",
"fieldname": "list_sidebar",
"fieldtype": "Check",
"label": "Sidebar"
},
{
"default": "0",
"fieldname": "bulk_actions",
"fieldtype": "Check",
"label": "Bulk Actions"
},
{
"fieldname": "form_settings_section",
"fieldtype": "Section Break",
"label": "Form Settings"
},
{
"default": "0",
"fieldname": "form_sidebar",
"fieldtype": "Check",
"label": "Sidebar"
},
{
"default": "0",
"fieldname": "timeline",
"fieldtype": "Check",
"label": "Timeline"
},
{
"default": "0",
"fieldname": "dashboard",
"fieldtype": "Check",
"label": "Dashboard"
},
{
"default": "0",
"fieldname": "view_switcher",
"fieldtype": "Check",
"label": "View Switcher"
}
],
"icon": "fa fa-bookmark",
"idx": 1,
"index_web_pages_for_search": 1,
"links": [],
"modified": "2020-08-06 15:42:59.036960",
"modified": "2020-11-05 01:25:10.536546",
"modified_by": "Administrator",
"module": "Core",
"name": "Role",

View file

@ -12,10 +12,7 @@ frappe.ui.toolbar.Toolbar = class {
}));
$('.dropdown-toggle').dropdown();
let awesome_bar = new frappe.search.AwesomeBar();
awesome_bar.setup("#navbar-search");
// awesome_bar.setup("#modal-search");
this.setup_awesomebar();
this.setup_notifications();
this.make();
}
@ -157,8 +154,17 @@ frappe.ui.toolbar.Toolbar = class {
}
}
setup_awesomebar() {
if (frappe.boot.desk_settings.search_bar) {
let awesome_bar = new frappe.search.AwesomeBar();
awesome_bar.setup("#navbar-search");
}
}
setup_notifications () {
this.notifications = new frappe.ui.Notifications();
if (frappe.boot.desk_settings.notifications) {
this.notifications = new frappe.ui.Notifications();
}
}
}