Merge pull request #17071 from ankush/quick_awesomebar
feat(workspace): start searching on alphabetic keypress
This commit is contained in:
commit
dd62749948
3 changed files with 19 additions and 0 deletions
|
|
@ -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}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue