From c1377f597205026e76d86ca5240ec7f4b6e1fbf1 Mon Sep 17 00:00:00 2001 From: qsm-odoo Date: Fri, 5 May 2017 13:50:46 +0200 Subject: [FIX] web: properly handle field navigation for all fields Before this commit, only fields which were specializations of the `InputField` were handling up/right/down/left navigation in editable list view. As m2o field is not an `InputField` (yet?), it was not possible to navigate from one of those for example. Now, navigation events are handled by the `AbstractField` class. If a given field has to handle navigation a different way, it is its responsability to stop the associated navigation event. For example, `InputField` instances are stopping the left/right event if the cursor is not at the start/end of the element. Also, before this commit, there were many events ("move_down", "move_left", "move_next", ...). Now there is only one event for navigation: "navigation_move". This event is given a "direction" data ("left", "next", ...). It also comes with a "target" data which is a reference to the last `AbstractField` instance the navigation event has crossed. --- .../static/src/js/views/basic/basic_renderer.js | 24 +++++----------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js') diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 65f444ad7b3..5babc71ab6b 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -16,12 +16,7 @@ var qweb = core.qweb; var BasicRenderer = AbstractRenderer.extend({ custom_events: { - /** - * All basic renderers should be able to handle widget navigation - * through the TAB key. - */ - move_next: '_onMoveNext', - move_previous: '_onMovePrevious', + navigation_move: '_onNavigationMove', }, /** * Basic renderers implements the concept of "mode", they can either be in @@ -600,24 +595,15 @@ var BasicRenderer = AbstractRenderer.extend({ //-------------------------------------------------------------------------- /** - * When someone presses TAB in a widget, it is nice to be able to go to the - * next widget, especially since the TAB key event is preventDefaulted + * When someone presses the TAB/UP/DOWN/... key in a widget, it is nice to + * be able to navigate in the view (default browser behaviors are disabled + * by Odoo). * * @abstract * @private * @param {OdooEvent} ev */ - _onMoveNext: function (ev) {}, - /** - * When someone presses SHIFT+TAB in a widget, it is nice to be able to go - * back to the previous widget, especially since the TAB key event is - * preventDefaulted - * - * @abstract - * @private - * @param {OdooEvent} ev - */ - _onMovePrevious: function (ev) {}, + _onNavigationMove: function (ev) {}, }); return BasicRenderer; -- cgit v1.2.3 From e1edd62320fef4991ba9554ee197021b45987a60 Mon Sep 17 00:00:00 2001 From: David Monjoie Date: Fri, 5 May 2017 16:34:54 +0200 Subject: [FIX] web: toggle checkboxes when clicked in editable list view Previously, the checkbox was not checked when it was clicked in editable list view, it only opened the row but did not check the checkbox. --- addons/web/static/src/js/views/basic/basic_renderer.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'addons/web/static/src/js/views/basic/basic_renderer.js') diff --git a/addons/web/static/src/js/views/basic/basic_renderer.js b/addons/web/static/src/js/views/basic/basic_renderer.js index 5babc71ab6b..907ea7ddc07 100644 --- a/addons/web/static/src/js/views/basic/basic_renderer.js +++ b/addons/web/static/src/js/views/basic/basic_renderer.js @@ -164,7 +164,7 @@ var BasicRenderer = AbstractRenderer.extend({ var recordWidgets = this.allFieldWidgets[record.id] || []; for (var i = 0 ; i < recordWidgets.length ; i++) { - var activated = recordWidgets[currentIndex].activate(); + var activated = recordWidgets[currentIndex].activate({event: options.event}); if (activated) { return currentIndex; } -- cgit v1.2.3