[IMP] web: Kanban: cancel column quick create on ESC
Record quick create can be cancelled by pressing ESC, so this rev. ensures that the same behavior applies for the column quick create, for the sake of consistency.
This commit is contained in:
@@ -266,6 +266,15 @@ var ColumnQuickCreate = AbstractQuickCreate.extend({
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @override
|
||||
* @private
|
||||
*/
|
||||
_cancel: function () {
|
||||
this.folded = true;
|
||||
this.$input.val('');
|
||||
this._update();
|
||||
},
|
||||
/**
|
||||
* Triggers up an event to quick create a column with the given value
|
||||
*
|
||||
@@ -298,9 +307,7 @@ var ColumnQuickCreate = AbstractQuickCreate.extend({
|
||||
if (hasFocus) {
|
||||
return;
|
||||
}
|
||||
this.folded = true;
|
||||
this.$input.val('');
|
||||
this._update();
|
||||
this._cancel();
|
||||
},
|
||||
/**
|
||||
* Stops the propagation of the event to prevent the quick create from
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
odoo.define('web.kanban_tests', function (require) {
|
||||
"use strict";
|
||||
|
||||
var core = require('web.core');
|
||||
var KanbanColumnProgressBar = require('web.KanbanColumnProgressBar');
|
||||
var KanbanRenderer = require('web.KanbanRenderer');
|
||||
var KanbanView = require('web.KanbanView');
|
||||
@@ -9,7 +8,6 @@ var testUtils = require('web.test_utils');
|
||||
var Widget = require('web.Widget');
|
||||
var widgetRegistry = require('web.widget_registry');
|
||||
|
||||
var createAsyncView = testUtils.createAsyncView;
|
||||
var createView = testUtils.createView;
|
||||
|
||||
QUnit.module('Views', {
|
||||
@@ -1425,6 +1423,43 @@ QUnit.module('Views', {
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('cancel column quick create by pressing ESCAPE', function (assert) {
|
||||
assert.expect(4);
|
||||
|
||||
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'],
|
||||
});
|
||||
|
||||
assert.strictEqual(kanban.$('.o_column_quick_create').length, 1, "should have a quick create column");
|
||||
assert.notOk(kanban.$('.o_column_quick_create input').is(':visible'),
|
||||
"the input should not be visible");
|
||||
|
||||
kanban.$('.o_column_quick_create').click();
|
||||
|
||||
assert.ok(kanban.$('.o_column_quick_create input').is(':visible'),
|
||||
"the input should be visible");
|
||||
|
||||
// discard the column creation by pressing ESCAPE
|
||||
kanban.$('.o_column_quick_create input').trigger($.Event('keydown', {
|
||||
keyCode: $.ui.keyCode.ESCAPE,
|
||||
which: $.ui.keyCode.ESCAPE,
|
||||
}));
|
||||
|
||||
assert.notOk(kanban.$('.o_column_quick_create input').is(':visible'),
|
||||
"the input should not be visible anymore");
|
||||
|
||||
kanban.destroy();
|
||||
});
|
||||
|
||||
QUnit.test('if view was grouped at start, it stays grouped', function (assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user