[IMP] web: x2many adds a new line by tabbing on a not dirty line

Before this change, when the focus was on the first field on a x2many
field, and the user pressed TAB, the line would be discarded and the
focus moved to the next field (at the level of the x2many) in the form.

This was an issue because if the first field was required, the focus
could not be moved out of the field with TAB so the user had to discard
the line manually (with ESC) before moving to the next field

This change works with 2 changes:
1. detecting if a line is dirty (has been modified by the user) and at
the end of the line, decide to either
    - discard the line and move the next field, if the line is not dirty
    - commit the line and add a new line, if the line is dirty

2. allow users to use TAB through required field inside x2many so they
can easilly go to the end of the line.

Task id : 1872248
This commit is contained in:
Vincent Schippefilt
2018-09-25 16:49:22 +02:00
parent 3dcf20284d
commit e343f5f5f9
6 changed files with 93 additions and 23 deletions
@@ -334,7 +334,8 @@ var InputField = DebouncedField.extend({
}
if (ev.data.direction ==='next' &&
this.attrs.modifiersValue &&
this.attrs.modifiersValue.required) {
this.attrs.modifiersValue.required &&
this.viewType !== 'list') {
if (!this.$input.val()){
this.setInvalidClass();
ev.stopPropagation();
@@ -388,7 +389,7 @@ var NumericField = InputField.extend({
*
* Note: We have to overwrite this method to set the input's type to number if
* option setted into the field.
*
*
* @override
* @private
*/