feat: Show frequently visited links on awesome bar
This commit is contained in:
parent
c60d2b33b0
commit
45c7eb4c71
3 changed files with 21 additions and 3 deletions
|
|
@ -19,6 +19,7 @@ from frappe.email.inbox import get_email_accounts
|
|||
from frappe.core.doctype.feedback_trigger.feedback_trigger import get_enabled_feedback_trigger
|
||||
from frappe.social.doctype.energy_point_settings.energy_point_settings import is_energy_point_enabled
|
||||
from frappe.social.doctype.energy_point_log.energy_point_log import get_energy_points
|
||||
from frappe.social.doctype.post.post import frequently_visited_links
|
||||
|
||||
def get_bootinfo():
|
||||
"""build and return boot info"""
|
||||
|
|
@ -82,6 +83,7 @@ def get_bootinfo():
|
|||
bootinfo.update(get_email_accounts(user=frappe.session.user))
|
||||
bootinfo.energy_points_enabled = is_energy_point_enabled()
|
||||
bootinfo.points = get_energy_points(frappe.session.user)
|
||||
bootinfo.frequently_visited_links = frequently_visited_links()
|
||||
|
||||
return bootinfo
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,7 @@ frappe.search.AwesomeBar = Class.extend({
|
|||
me.options = me.options.concat(me.build_options(txt));
|
||||
me.options = me.options.concat(me.global_results);
|
||||
} else {
|
||||
me.options = me.options.concat(
|
||||
me.deduplicate(frappe.search.utils.get_recent_pages(txt || "")));
|
||||
me.options = me.options.concat(frappe.search.utils.get_frequent_links());
|
||||
}
|
||||
me.add_help();
|
||||
|
||||
|
|
@ -203,7 +202,7 @@ frappe.search.AwesomeBar = Class.extend({
|
|||
return out;
|
||||
},
|
||||
|
||||
set_global_results: function(global_results, txt){
|
||||
set_global_results: function(global_results, txt) {
|
||||
this.global_results = this.global_results.concat(global_results);
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -80,6 +80,23 @@ frappe.search.utils = {
|
|||
return options;
|
||||
},
|
||||
|
||||
get_frequent_links() {
|
||||
let options = [];
|
||||
frappe.boot.frequently_visited_links.forEach(link => {
|
||||
const label = frappe.utils.get_route_label(link.route);
|
||||
options.push({
|
||||
'route': link.route,
|
||||
'label': label,
|
||||
'value': label,
|
||||
'index': link.count,
|
||||
});
|
||||
});
|
||||
if (!options.length) {
|
||||
return this.get_recent_pages('');
|
||||
}
|
||||
return options;
|
||||
},
|
||||
|
||||
get_search_in_list: function(keywords) {
|
||||
var me = this;
|
||||
var out = [];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue