feat: make dashboards searchable in awesomebar (#10385)
This commit is contained in:
parent
10c5f6316c
commit
77a333086c
3 changed files with 28 additions and 1 deletions
|
|
@ -106,6 +106,7 @@ def load_desktop_data(bootinfo):
|
|||
from frappe.desk.desktop import get_desk_sidebar_items
|
||||
bootinfo.allowed_modules = get_modules_from_all_apps_for_user()
|
||||
bootinfo.allowed_workspaces = get_desk_sidebar_items(True)
|
||||
bootinfo.dashboards = frappe.get_list("Dashboard")
|
||||
|
||||
def get_allowed_pages(cache=False):
|
||||
return get_user_pages_or_reports('Page', cache=cache)
|
||||
|
|
|
|||
|
|
@ -177,6 +177,7 @@ frappe.search.AwesomeBar = Class.extend({
|
|||
frappe.search.utils.get_reports(txt),
|
||||
frappe.search.utils.get_pages(txt),
|
||||
frappe.search.utils.get_workspaces(txt),
|
||||
frappe.search.utils.get_dashboards(txt),
|
||||
frappe.search.utils.get_recent_pages(txt || ""),
|
||||
frappe.search.utils.get_executables(txt)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -288,7 +288,7 @@ frappe.search.utils = {
|
|||
var out = [];
|
||||
frappe.boot.allowed_workspaces.forEach(function(item) {
|
||||
var level = me.fuzzy_search(keywords, item.name);
|
||||
if(level > 0) {
|
||||
if (level > 0) {
|
||||
var ret = {
|
||||
type: "Workspace",
|
||||
label: __("Open {0}", [me.bolden_match_part(__(item.name), keywords)]),
|
||||
|
|
@ -303,6 +303,26 @@ frappe.search.utils = {
|
|||
return out;
|
||||
},
|
||||
|
||||
get_dashboards: function(keywords) {
|
||||
var me = this;
|
||||
var out = [];
|
||||
frappe.boot.dashboards.forEach(function(item) {
|
||||
var level = me.fuzzy_search(keywords, item.name);
|
||||
if (level > 0) {
|
||||
var ret = {
|
||||
type: "Dashboard",
|
||||
label: __("{0} Dashboard", [me.bolden_match_part(__(item.name), keywords)]),
|
||||
value: __("{0} Dashboard", [__(item.name)]),
|
||||
index: level,
|
||||
route: ["dashboard", item.name]
|
||||
};
|
||||
|
||||
out.push(ret);
|
||||
}
|
||||
});
|
||||
return out;
|
||||
},
|
||||
|
||||
get_global_results: function(keywords, start, limit, doctype = "") {
|
||||
var me = this;
|
||||
function get_results_sets(data) {
|
||||
|
|
@ -490,6 +510,11 @@ frappe.search.utils = {
|
|||
fetch_type: "Nav",
|
||||
results: sort_uniques(this.get_workspaces(keywords))
|
||||
},
|
||||
{
|
||||
title: "Dashboard",
|
||||
fetch_type: "Nav",
|
||||
results: sort_uniques(this.get_dashboards(keywords))
|
||||
},
|
||||
{
|
||||
title: "Setup",
|
||||
fetch_type: "Nav",
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue