[FIX] web: Kanban: allow to resequence a record twice
Before this rev., it was not possible to move a record (in the same column) at the top and then move another record above it. There is special class `o_updating` added on record being edited to avoid moving them. This class is normally removed afterwards when re-rendering the record. When resequencing, the record is re-rendered so the class won't be removed ; this is why it shouldn't be added in the first place (same behaviour as saas-15).
This commit is contained in:
@@ -109,7 +109,6 @@ var KanbanColumn = Widget.extend({
|
||||
var record = ui.item.data('record');
|
||||
var index = self.records.indexOf(record);
|
||||
record.$el.removeAttr('style'); // jqueryui sortable add display:block inline
|
||||
ui.item.addClass('o_updating');
|
||||
if (index >= 0) {
|
||||
if ($.contains(self.$el[0], record.$el[0])) {
|
||||
// resequencing records
|
||||
@@ -117,6 +116,7 @@ var KanbanColumn = Widget.extend({
|
||||
}
|
||||
} else {
|
||||
// adding record to this column
|
||||
ui.item.addClass('o_updating');
|
||||
self.trigger_up('kanban_column_add_record', {record: record, ids: self._getIDs()});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1685,6 +1685,75 @@ QUnit.module('Views', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.only('resequence a record twice', function (assert) {
|
||||
assert.expect(10);
|
||||
|
||||
this.data.partner.records = [];
|
||||
|
||||
var nbResequence = 0;
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<kanban>' +
|
||||
'<field name="product_id"/>' +
|
||||
'<templates><t t-name="kanban-box">' +
|
||||
'<div><field name="display_name"/></div>' +
|
||||
'</t></templates></kanban>',
|
||||
groupBy: ['product_id'],
|
||||
mockRPC: function (route) {
|
||||
if (route === '/web/dataset/resequence') {
|
||||
nbResequence++;
|
||||
return $.when();
|
||||
}
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
});
|
||||
|
||||
kanban.$('.o_column_quick_create').click();
|
||||
kanban.$('.o_column_quick_create input').val('column1');
|
||||
kanban.$('.o_column_quick_create button.o_kanban_add').click();
|
||||
|
||||
kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_add i').click();
|
||||
var $quickCreate = kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_create');
|
||||
$quickCreate.find('input').val('record1');
|
||||
$quickCreate.find('button.o_kanban_add').click();
|
||||
|
||||
kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_add i').click();
|
||||
$quickCreate = kanban.$('.o_kanban_group:eq(0) .o_kanban_quick_create');
|
||||
$quickCreate.find('input').val('record2');
|
||||
$quickCreate.find('button.o_kanban_add').click();
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record').length, 2,
|
||||
"column should contain 2 records");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(0)').text(), "record2",
|
||||
"records should be correctly ordered");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(1)').text(), "record1",
|
||||
"records should be correctly ordered");
|
||||
|
||||
var $record1 = kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(1)');
|
||||
var $record2 = kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(0)');
|
||||
testUtils.dragAndDrop($record1, $record2, {position: 'top'});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record').length, 2,
|
||||
"column should contain 2 records");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(0)').text(), "record1",
|
||||
"records should be correctly ordered");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(1)').text(), "record2",
|
||||
"records should be correctly ordered");
|
||||
|
||||
testUtils.dragAndDrop($record2, $record1, {position: 'top'});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record').length, 2,
|
||||
"column should contain 2 records");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(0)').text(), "record2",
|
||||
"records should be correctly ordered");
|
||||
assert.strictEqual(kanban.$('.o_kanban_group:eq(0) .o_kanban_record:eq(1)').text(), "record1",
|
||||
"records should be correctly ordered");
|
||||
assert.strictEqual(nbResequence, 2, "should have resequenced twice");
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('don\'t fold column quick create after creation', function (assert) {
|
||||
assert.expect(2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user