From 754d2ef6aa8567b91269dc89f180319a0a726e67 Mon Sep 17 00:00:00 2001 From: wan Date: Tue, 17 Sep 2019 11:36:48 +0000 Subject: [PATCH] [IMP] account: review the keyboard navigation for the reconciliation widget Task 2072312 * Ensure that the css is from Odoo and not from the browser * Only use up/down to navigate * Use Enter to validate a line * Remove the accesskeys --- .../reconciliation/reconciliation_action.js | 12 ++++++-- .../reconciliation/reconciliation_renderer.js | 30 ++----------------- .../src/scss/account_reconciliation.scss | 8 +++++ .../static/src/xml/account_reconciliation.xml | 4 +-- addons/account/views/account_move_views.xml | 2 +- 5 files changed, 22 insertions(+), 34 deletions(-) diff --git a/addons/account/static/src/js/reconciliation/reconciliation_action.js b/addons/account/static/src/js/reconciliation/reconciliation_action.js index 00326e8a10c..3c7969ed1b4 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_action.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_action.js @@ -57,15 +57,18 @@ var StatementAction = AbstractAction.extend({ var widget = false; switch (ev.data.direction) { case 'up': - case 'previous': ev.stopPropagation(); widget = this._getWidget(non_reconciled_keys[currentIndex-1]); break; case 'down': - case 'next': ev.stopPropagation(); widget = this._getWidget(non_reconciled_keys[currentIndex+1]); break; + case 'validate': + ev.stopPropagation(); + widget = this._getWidget(non_reconciled_keys[currentIndex]); + widget.$('caption .o_buttons button:visible').click(); + break; } if (widget) widget.$el.focus(); }, @@ -259,7 +262,10 @@ var StatementAction = AbstractAction.extend({ self._getWidget(handle).update(line); }).guardedCatch(function(){ self._getWidget(handle).update(line); - }); + }).then(function() { + self._getWidget(handle).$el.focus(); + } + ); } return handle; }, diff --git a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js index a9d0c0d9566..079a2632b1e 100644 --- a/addons/account/static/src/js/reconciliation/reconciliation_renderer.js +++ b/addons/account/static/src/js/reconciliation/reconciliation_renderer.js @@ -219,6 +219,7 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { 'click .accounting_view tfoot': '_onChangeTab', 'click': '_onTogglePanel', 'click .o_field_widget': '_onStopPropagation', + 'keydown .o_input': '_onStopPropagation', 'click .o_notebook li a': '_onChangeTab', 'click .cell': '_onEditAmount', 'change input.filter': '_onFilterChange', @@ -241,40 +242,19 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { _onKeydown: function (ev) { switch (ev.which) { - case $.ui.keyCode.TAB: - var event = this.trigger_up('navigation_move', { - direction: ev.shiftKey ? 'previous' : 'next', - handle: this.handle, - }); - if (event.is_stopped()) { - ev.preventDefault(); - ev.stopPropagation(); - } - break; case $.ui.keyCode.ENTER: - this.trigger_up('navigation_move', {direction: 'next_line', handle: this.handle}); - break; - case $.ui.keyCode.ESCAPE: - this.trigger_up('navigation_move', {direction: 'cancel', handle: this.handle, originalEvent: ev}); + this.trigger_up('navigation_move', {direction: 'validate', handle: this.handle}); break; case $.ui.keyCode.UP: ev.stopPropagation(); ev.preventDefault(); this.trigger_up('navigation_move', {direction: 'up', handle: this.handle}); break; - case $.ui.keyCode.RIGHT: - ev.stopPropagation(); - this.trigger_up('navigation_move', {direction: 'right', handle: this.handle}); - break; case $.ui.keyCode.DOWN: ev.stopPropagation(); ev.preventDefault(); this.trigger_up('navigation_move', {direction: 'down', handle: this.handle}); break; - case $.ui.keyCode.LEFT: - ev.stopPropagation(); - this.trigger_up('navigation_move', {direction: 'left', handle: this.handle}); - break; } }, @@ -477,12 +457,6 @@ var LineRenderer = Widget.extend(FieldManagerMixin, { }); } this.$('.create .add_line').toggle(!!state.balance.amount_currency); - - if (this.$el.is(':focus-within')) { - this.$('caption .o_buttons button:not(:disabled):visible').attr('accesskey', 'V'); - } else { - this.$('caption .o_buttons button').attr('accesskey', ''); - } }, updatePartialAmount: function(line_id, amount) { diff --git a/addons/account/static/src/scss/account_reconciliation.scss b/addons/account/static/src/scss/account_reconciliation.scss index b08f5941d55..ef323c9f78a 100644 --- a/addons/account/static/src/scss/account_reconciliation.scss +++ b/addons/account/static/src/scss/account_reconciliation.scss @@ -234,6 +234,14 @@ &:not(:focus-within) .o_web_accesskey_overlay { display: none; } + &:focus caption .o_buttons button { + outline: none; + box-shadow: 4px 4px 4px 0px $o-enterprise-color; + } + &:focus{ + outline: none; + box-shadow: 0 0 0 0; + } } .o_reconcile_models .btn-primary { diff --git a/addons/account/static/src/xml/account_reconciliation.xml b/addons/account/static/src/xml/account_reconciliation.xml index 9049cea5a68..264df83a3c2 100644 --- a/addons/account/static/src/xml/account_reconciliation.xml +++ b/addons/account/static/src/xml/account_reconciliation.xml @@ -93,8 +93,8 @@
- - + +
diff --git a/addons/account/views/account_move_views.xml b/addons/account/views/account_move_views.xml index 678bc4e1f47..dec9cc46a2a 100644 --- a/addons/account/views/account_move_views.xml +++ b/addons/account/views/account_move_views.xml @@ -164,7 +164,7 @@ account.move.line - +