[IMP] web: Kanban open ColumnQuickCreate if no column
Part of task #38740
This commit is contained in:
@@ -36,6 +36,14 @@ var ColumnQuickCreate = Widget.extend({
|
||||
this.$input = this.$('input');
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
/**
|
||||
* Called each time the quick create is attached into the DOM
|
||||
*/
|
||||
on_attach_callback: function () {
|
||||
if (!this.folded) {
|
||||
this.$input.focus();
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
|
||||
@@ -40,6 +40,12 @@ var KanbanController = BasicController.extend({
|
||||
this.on_create = params.on_create;
|
||||
this.hasButtons = params.hasButtons;
|
||||
},
|
||||
/**
|
||||
* Called each time the kanban view is attached into the DOM.
|
||||
*/
|
||||
on_attach_callback: function () {
|
||||
this.renderer.on_attach_callback();
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
|
||||
@@ -109,6 +109,14 @@ var KanbanRenderer = BasicRenderer.extend({
|
||||
|
||||
this._setState(state);
|
||||
},
|
||||
/**
|
||||
* Called each time the renderer is attached into the DOM.
|
||||
*/
|
||||
on_attach_callback: function () {
|
||||
if (this.quickCreate) {
|
||||
this.quickCreate.on_attach_callback();
|
||||
}
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
@@ -284,7 +292,13 @@ var KanbanRenderer = BasicRenderer.extend({
|
||||
// Enable column quickcreate
|
||||
if (this.createColumnEnabled) {
|
||||
this.quickCreate = new ColumnQuickCreate(this);
|
||||
this.quickCreate.appendTo(fragment);
|
||||
this.quickCreate.appendTo(fragment).then(function () {
|
||||
// Open it directly if there is no column yet
|
||||
if (!self.state.data.length) {
|
||||
self.quickCreate.toggleFold();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1888,6 +1888,33 @@ QUnit.module('Views', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('quick create column should be opened if there is no column', function (assert) {
|
||||
assert.expect(3);
|
||||
|
||||
var kanban = createView({
|
||||
View: KanbanView,
|
||||
model: 'partner',
|
||||
data: this.data,
|
||||
arch: '<kanban class="o_kanban_test">' +
|
||||
'<field name="product_id"/>' +
|
||||
'<templates><t t-name="kanban-box">' +
|
||||
'<div><field name="foo"/></div>' +
|
||||
'</t></templates>' +
|
||||
'</kanban>',
|
||||
groupBy: ['product_id'],
|
||||
domain: [['foo', '=', 'norecord']],
|
||||
});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_kanban_group').length, 0,
|
||||
"there should be no column");
|
||||
assert.strictEqual(kanban.$('.o_column_quick_create').length, 1,
|
||||
"should have a quick create column");
|
||||
assert.ok(kanban.$('.o_column_quick_create input').is(':visible'),
|
||||
"the quick create should be opened");
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('cancel column quick create by pressing ESCAPE', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user