[FIX] web: don't fold quickcreate after adding a column in Kanban view
This commit aims to replicate saas-15 behaviour when adding columns in a Kanban view by not folding the column quick create widget when creating a new column, thereby allowing users to add multiple columns in one go.
This commit is contained in:
@@ -164,9 +164,10 @@ var KanbanController = BasicController.extend({
|
|||||||
_onAddColumn: function (event) {
|
_onAddColumn: function (event) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.model.createGroup(event.data.value, this.handle).then(function () {
|
this.model.createGroup(event.data.value, this.handle).then(function () {
|
||||||
self.update({}, {reload: false});
|
return self.update({}, {reload: false});
|
||||||
|
}).then(function () {
|
||||||
self._updateButtons();
|
self._updateButtons();
|
||||||
self.trigger_up('scrollTo', {selector: '.o_column_quick_create'});
|
self.renderer.quickCreateToggleFold();
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ var RecordQuickCreate = AbstractQuickCreate.extend({
|
|||||||
var ColumnQuickCreate = AbstractQuickCreate.extend({
|
var ColumnQuickCreate = AbstractQuickCreate.extend({
|
||||||
template: 'KanbanView.ColumnQuickCreate',
|
template: 'KanbanView.ColumnQuickCreate',
|
||||||
events: _.extend({}, AbstractQuickCreate.prototype.events, {
|
events: _.extend({}, AbstractQuickCreate.prototype.events, {
|
||||||
'click': '_onClick',
|
'click': 'toggleFold',
|
||||||
'click input': '_onInputClicked',
|
'click input': '_onInputClicked',
|
||||||
'focusout': '_onFocusout',
|
'focusout': '_onFocusout',
|
||||||
}),
|
}),
|
||||||
@@ -180,6 +180,22 @@ var ColumnQuickCreate = AbstractQuickCreate.extend({
|
|||||||
return this._super.apply(this, arguments);
|
return this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
// Public
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Toggle fold/unfold the Column quick create widget
|
||||||
|
*/
|
||||||
|
toggleFold: function () {
|
||||||
|
this.folded = !this.folded;
|
||||||
|
this._update();
|
||||||
|
if (!this.folded) {
|
||||||
|
this.$input.focus();
|
||||||
|
this.trigger_up('scrollTo', {selector: '.o_column_quick_create'});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
// Private
|
// Private
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
@@ -208,18 +224,6 @@ var ColumnQuickCreate = AbstractQuickCreate.extend({
|
|||||||
// Handlers
|
// Handlers
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
/**
|
|
||||||
* @private
|
|
||||||
* @param {MouseEvent} event
|
|
||||||
*/
|
|
||||||
_onClick: function () {
|
|
||||||
this.folded = !this.folded;
|
|
||||||
this._update();
|
|
||||||
if (!this.folded) {
|
|
||||||
this.$input.focus();
|
|
||||||
this.trigger_up('scrollTo', {selector: '.o_column_quick_create'});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ var KanbanRenderer = BasicRenderer.extend({
|
|||||||
addQuickCreate: function () {
|
addQuickCreate: function () {
|
||||||
this.widgets[0].addQuickCreate();
|
this.widgets[0].addQuickCreate();
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Toggle fold/unfold the Column quick create widget
|
||||||
|
*/
|
||||||
|
quickCreateToggleFold: function () {
|
||||||
|
this.quickCreate.toggleFold();
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Removes a widget (record if ungrouped, column if grouped) from the view.
|
* Removes a widget (record if ungrouped, column if grouped) from the view.
|
||||||
*
|
*
|
||||||
@@ -244,8 +250,8 @@ var KanbanRenderer = BasicRenderer.extend({
|
|||||||
|
|
||||||
// Enable column quickcreate
|
// Enable column quickcreate
|
||||||
if (this.columnOptions.group_creatable) {
|
if (this.columnOptions.group_creatable) {
|
||||||
var quickCreate = new ColumnQuickCreate(this);
|
this.quickCreate = new ColumnQuickCreate(this);
|
||||||
quickCreate.appendTo(fragment);
|
this.quickCreate.appendTo(fragment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1614,6 +1614,35 @@ QUnit.module('Views', {
|
|||||||
"column should contain 1 records");
|
"column should contain 1 records");
|
||||||
kanban.destroy();
|
kanban.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('don\'t fold column quick create after creation', function (assert) {
|
||||||
|
assert.expect(2);
|
||||||
|
|
||||||
|
var kanban = createView({
|
||||||
|
View: KanbanView,
|
||||||
|
model: 'partner',
|
||||||
|
data: this.data,
|
||||||
|
arch: '<kanban on_create="quick_create">' +
|
||||||
|
'<field name="product_id"/>' +
|
||||||
|
'<templates><t t-name="kanban-box">' +
|
||||||
|
'<div><field name="foo"/></div>' +
|
||||||
|
'</t></templates>' +
|
||||||
|
'</kanban>',
|
||||||
|
groupBy: ['product_id'],
|
||||||
|
});
|
||||||
|
|
||||||
|
// add a new column
|
||||||
|
kanban.$('.o_kanban_group:first .o_kanban_quick_add').click();
|
||||||
|
var $quickCreate = kanban.$('.o_kanban_quick_create');
|
||||||
|
$quickCreate.find('input').val('new partner');
|
||||||
|
$quickCreate.find('button.o_kanban_add').click();
|
||||||
|
assert.strictEqual(this.data.partner.records.length, 5,
|
||||||
|
"should have created a 'new partner' column");
|
||||||
|
|
||||||
|
assert.strictEqual(kanban.$('.o_kanban_add:visible').length, 1,
|
||||||
|
"the add button should still be visible");
|
||||||
|
kanban.destroy();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user