Merge pull request #17071 from ankush/quick_awesomebar

feat(workspace): start searching on alphabetic keypress
This commit is contained in:
Ankush Menat 2022-06-06 15:21:53 +05:30 committed by GitHub
commit dd62749948
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 0 deletions

View file

@ -81,6 +81,7 @@ frappe.ui.keys.show_keyboard_shortcut_dialog = () => {
}
let html = shortcuts
.filter(s => s.condition ? s.condition() : true)
.filter(s => !!s.description)
.map(shortcut => {
let shortcut_label = shortcut.shortcut
.split('+')
@ -94,6 +95,8 @@ frappe.ui.keys.show_keyboard_shortcut_dialog = () => {
<td width="60%">${shortcut.description || ''}</td>
</tr>`;
}).join('');
if (!html) return '';
html = `<h5 style="margin: 0;">${heading}</h5>
<table style="margin-top: 10px;" class="table table-bordered">
${html}

View file

@ -106,6 +106,7 @@ frappe.search.AwesomeBar = class AwesomeBar {
frappe.set_route(item.route);
}
$input.val("");
$input.trigger('blur');
});
$input.on("awesomplete-selectcomplete", function(e) {

View file

@ -37,6 +37,7 @@ frappe.views.Workspace = class Workspace {
this.prepare_container();
this.setup_pages();
this.register_awesomebar_shortcut();
}
prepare_container() {
@ -1228,4 +1229,18 @@ frappe.views.Workspace = class Workspace {
$('.desk-sidebar').removeClass('hidden');
$('.list-sidebar').find('.workspace-sidebar-skeleton').remove();
}
register_awesomebar_shortcut() {
'abcdefghijklmnopqrstuvwxyz'.split('').forEach(letter => {
const default_shortcut = {
action: (e) => {
$("#navbar-search").focus();
return false; // don't prevent default = type the letter in awesomebar
},
page: this.page,
};
frappe.ui.keys.add_shortcut({shortcut: letter, ...default_shortcut});
frappe.ui.keys.add_shortcut({shortcut: `shift+${letter}`, ...default_shortcut});
});
}
};