summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/chrome/abstract_web_client.js
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2018-04-05 14:00:36 +0200
committerVincent Schippefilt <vsc@odoo.com>2018-04-10 09:39:08 +0200
commita4d00a56b640d9da5129e2611667b3f491157ca5 (patch)
tree06237a66f8240f775cac797027149a01396448d5 /addons/web/static/src/js/chrome/abstract_web_client.js
parent02a063fd73d662bfe175db03aad96685543c5ca9 (diff)
[IMP] web: auto-assign and show access keys on ALT
This commits aims at adding an accesskey (a shortcut) to all buttons in odoo. This is done by either by assigning an accesskey in the view XML or by automatically assigning a key to the buttons using the first available (not yet assigned as a shortcut key) letter of the text of the button, failing that we use the latin alphabetical order to find the first unused key. Included in this commit: 1. Using the ALT key, automatically assign 2. When the ALT key is pressed, show the assigned shortcuts 3. Assign a number to the menu items (enterprise) 4. Activate number accesskeys without using SHIFT 5. Extra logic to support the activation of the alphabetical accesskeys without needing to add the SHIFT key in the key combination (except for Firefox on linux) 6. Assign a fixed accesskey to the search field Not done: 1. Executing the primary action on dialogs using SHIFT+ENTER 2. Show the input using TAB on the appswitcher screen Things to consider: 1. Fixing more access keys on forms that share the same features (b.e. Validate in customer invoice and vendor bills) 2. Not assigning keys to the chatter section
Diffstat (limited to 'addons/web/static/src/js/chrome/abstract_web_client.js')
-rw-r--r--addons/web/static/src/js/chrome/abstract_web_client.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/addons/web/static/src/js/chrome/abstract_web_client.js b/addons/web/static/src/js/chrome/abstract_web_client.js
index 71ff0cf31c2..3492af748f5 100644
--- a/addons/web/static/src/js/chrome/abstract_web_client.js
+++ b/addons/web/static/src/js/chrome/abstract_web_client.js
@@ -19,6 +19,7 @@ var crash_manager = require('web.crash_manager');
var data_manager = require('web.data_manager');
var Dialog = require('web.Dialog');
var dom = require('web.dom');
+var KeyboardNavigationMixin = require('web.KeyboardNavigationMixin');
var Loading = require('web.Loading');
var NotificationManager = require('web.NotificationManager');
var RainbowMan = require('web.RainbowMan');
@@ -29,7 +30,8 @@ var Widget = require('web.Widget');
var _t = core._t;
var qweb = core.qweb;
-var AbstractWebClient = Widget.extend(ServiceProviderMixin, {
+var AbstractWebClient = Widget.extend(ServiceProviderMixin, KeyboardNavigationMixin, {
+ events: _.extend(KeyboardNavigationMixin.events, {}),
custom_events: {
clear_uncommitted_changes: function (e) {
this.clear_uncommitted_changes().then(e.data.callback);
@@ -95,6 +97,7 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, {
this.client_options = {};
this._super(parent);
ServiceProviderMixin.init.call(this);
+ KeyboardNavigationMixin.init.call(this);
this.origin = undefined;
this._current_state = null;
this.menu_dm = new concurrency.DropMisordered();
@@ -134,6 +137,7 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, {
core.bus.trigger('web_client_ready');
});
},
+
bind_events: function () {
var self = this;
$('.oe_systray').show();
@@ -161,12 +165,14 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, {
}
}, 0);
});
+ window.addEventListener('blur', function (e) { self._hideAccessKeyOverlay(); });
core.bus.on('click', this, function (ev) {
$('.tooltip').remove();
if (!$(ev.target).is('input[type=file]')) {
$(this.el.getElementsByClassName('oe_dropdown_menu oe_opened')).removeClass('oe_opened');
$(this.el.getElementsByClassName('oe_dropdown_toggle oe_opened')).removeClass('oe_opened');
}
+ this._hideAccessKeyOverlay();
});
core.bus.on('connection_lost', this, this.on_connection_lost);
core.bus.on('connection_restored', this, this.on_connection_restored);
@@ -242,7 +248,7 @@ var AbstractWebClient = Widget.extend(ServiceProviderMixin, {
* Sets the first part of the title of the window, dedicated to the current action.
*/
set_title: function (title) {
- this.set_title_part("action", title);
+ this.set_title_part("action", title);
},
/**
* Sets an arbitrary part of the title of the window. Title parts are