changeset 86a41bc1deea in sao:default
details: https://hg.tryton.org/sao?cmd=changeset;node=86a41bc1deea
description:
Let the focus set by Screen.new_
The Screen.new_ method set the cursor on the right cell so we should
set the
focus only when no new record is created.
issue8508
review263911002
diffstat:
src/view/tree.js | 51 +++++++++++++++++++++------------------------------
1 files changed, 21 insertions(+), 30 deletions(-)
diffs (97 lines):
diff -r e83c8f432bee -r 86a41bc1deea src/view/tree.js
--- a/src/view/tree.js Tue Jul 23 00:05:09 2019 +0200
+++ b/src/view/tree.js Thu Jul 25 10:16:31 2019 +0200
@@ -1411,7 +1411,7 @@
return this._get_column_td(this.edited_column);
},
key_press: function(event_) {
- var current_td, selector, next_column, next_idx, i, next_row;
+ var current_td, selector, next_column, next_idx, i;
var states;
if ((event_.which != Sao.common.TAB_KEYCODE) &&
@@ -1444,22 +1444,10 @@
} else if (event_.which == Sao.common.UP_KEYCODE ||
event_.which == Sao.common.DOWN_KEYCODE ||
event_.which == Sao.common.RETURN_KEYCODE) {
- if (event_.which == Sao.common.UP_KEYCODE) {
- next_row = this.el.prev('tr');
- } else if (event_.which == Sao.common.DOWN_KEYCODE) {
- next_row = this.el.next('tr');
- } else {
- if (this.tree.attributes.editable == 'bottom') {
- next_row = this.el.next('tr');
- } else {
- next_row = this.el.prev('tr');
- }
- }
next_column = this.edited_column;
this.record.validate(this.tree.get_fields())
.then(function(validate) {
if (!validate) {
- next_row = null;
var invalid_fields =
this.record.invalid_fields();
for (i = 0; i < this.tree.columns.length; i++)
{
@@ -1469,6 +1457,8 @@
break;
}
}
+ this._get_column_td(next_column)
+ .find(':input,[tabindex=0]').focus();
} else {
var prm = jQuery.when();
if (!this.tree.screen.group.parent) {
@@ -1479,6 +1469,18 @@
prm.fail(function() {
widget.focus();
});
+ var next_row;
+ if (event_.which == Sao.common.UP_KEYCODE) {
+ next_row = this.el.prev('tr');
+ } else if (event_.which ==
Sao.common.DOWN_KEYCODE) {
+ next_row = this.el.next('tr');
+ } else {
+ if (this.tree.attributes.editable ==
'bottom') {
+ next_row = this.el.next('tr');
+ } else {
+ next_row = this.el.prev('tr');
+ }
+ }
if (!next_row.length &&
((event_.which ==
Sao.common.RETURN_KEYCODE) ||
((event_.which ==
Sao.common.UP_KEYCODE) &&
@@ -1491,27 +1493,16 @@
var limit = ((this.tree.screen.size_limit
!== null) &&
(model.length >=
this.tree.screen.size_limit));
if (access.create && !limit) {
- prm = prm.then(function() {
+ prm.then(function() {
return this.tree.screen.new_();
- }.bind(this))
- .then(function() {
- var rows =
this.tree.tbody.children('tr');
- if
(this.tree.attributes.editable == 'bottom') {
- next_row = rows.last();
- } else {
- next_row = rows.first();
- }
- }.bind(this));
+ }.bind(this));
}
+ } else {
+ this._get_column_td(next_column, next_row)
+ .trigger('click')
+ .find(':input,[tabindex=0]').focus();
}
- return prm;
}
- }.bind(this)).then(function() {
- window.setTimeout(function() {
- this._get_column_td(next_column, next_row)
- .click()
- .find(':input,[tabindex=0]').focus();
- }.bind(this), 0);
}.bind(this));
} else if (event_.which == Sao.common.ESC_KEYCODE) {
this.tree.edit_row(null);