[FIX] web: editable list: don't sort rows in edition

This commit disables the sort feature when a row is being edited,
like it was in saas-15, because it didn't work correctly anyway.
This commit is contained in:
Deep Patel
2017-09-20 08:20:01 +02:00
committed by Aaron Bohy
parent 73bec3d60f
commit 9f8efb9d16
2 changed files with 45 additions and 0 deletions
@@ -666,6 +666,17 @@ ListRenderer.include({
this._super.apply(this, arguments);
}
},
/**
* Overrides to prevent from sorting if we are currently editing a record.
*
* @override
* @private
*/
_onSortColumn: function () {
if (this.currentRow === null) {
this._super.apply(this, arguments);
}
},
/**
* Triggers a delete event. I don't know why we stop the propagation of the
* event.
@@ -436,6 +436,39 @@ QUnit.module('Views', {
list.destroy();
});
QUnit.test('editable list view: save data when list sorting in edit mode', function (assert) {
assert.expect(3);
this.data.foo.fields.foo.sortable = true;
var list = createView({
View: ListView,
model: 'foo',
data: this.data,
arch: '<tree editable="bottom"><field name="foo"/></tree>',
mockRPC: function (route, args) {
if (args.method === 'write') {
assert.deepEqual(args.args, [[1], {foo: 'xyz'}],
"should correctly save the edited record");
}
return this._super.apply(this, arguments);
}
});
list.$('.o_data_cell:first').click();
list.$('input[name="foo"]').val('xyz').trigger('input');
list.$('.o_column_sortable').click();
assert.ok(list.$('.o_data_row:first').hasClass('o_selected_row'),
"first row should still be in edition");
list.$buttons.find('.o_list_button_save').click();
assert.ok(!list.$buttons.hasClass('o-editing'),
"list buttons should be back to their readonly mode");
list.destroy();
});
QUnit.test('selection changes are triggered correctly', function (assert) {
assert.expect(8);
@@ -861,6 +894,7 @@ QUnit.module('Views', {
assert.ok(form.$('tbody tr:eq(2) td input').val(),
"Value 2 should be third (shouldn't be sorted)");
form.$('.o_form_sheet_bg').click(); // validate the row before sorting
$o2m.find('.o_column_sortable').click();
assert.ok(form.$('tbody tr:first td:contains(Value 3)').length,
"Value 3 should be first");