[FIX] web: customization of text in button for kanban example never used

Before this commit, the customization of text in button to apply kanban
example is never used because the variable which contains the text is
missspelled and thus is always undefined. That's why, we always have the
default text in this button.

This commit changes the `options.applyExampleText` to
`options.applyExamplesText` to get the text customization in project
module for instance and adds a test in order to check that the text
is well rendered.

Co-authored-by: Laurent Stukkens (LTU) <ltu@odoo.com>

task-2440564
Closes #65095
This commit is contained in:
Xavier BOL (xbo)
2021-02-01 13:48:00 +01:00
committed by Laurent Stukkens (LTU)
parent 0a50436e5a
commit 1361d0720e
2 changed files with 42 additions and 1 deletions
@@ -32,7 +32,7 @@ var ColumnQuickCreate = Widget.extend({
*/
init: function (parent, options) {
this._super.apply(this, arguments);
this.applyExamplesText = options.applyExampleText || _t("Use This For My Kanban");
this.applyExamplesText = options.applyExamplesText || _t("Use This For My Kanban");
this.examples = options.examples;
this.folded = true;
this.isMobile = false;
@@ -3801,6 +3801,47 @@ QUnit.module('Views', {
kanban.destroy();
});
QUnit.test("quick create column's apply button's display text", async function (assert) {
assert.expect(1);
const applyExamplesText = 'Use This For My Test';
kanbanExamplesRegistry.add('test', {
applyExamplesText: applyExamplesText,
examples:[{
name: "A first example",
columns: ["Column 1", "Column 2", "Column 3"],
description: "Some description",
}, {
name: "A second example",
columns: ["Col 1", "Col 2"],
}],
});
var kanban = await createView({
View: KanbanView,
model: 'partner',
data: this.data,
arch: '<kanban examples="test">' +
'<field name="product_id"/>' +
'<templates><t t-name="kanban-box">' +
'<div><field name="foo"/></div>' +
'</t></templates>' +
'</kanban>',
groupBy: ['product_id'],
});
// open the quick create
await testUtils.dom.click(kanban.$('.o_column_quick_create .o_quick_create_folded'));
// click to see the examples
await testUtils.dom.click(kanban.$('.o_column_quick_create .o_kanban_examples'));
const $primaryActionButton = $('.modal footer.modal-footer button.btn-primary > span');
assert.strictEqual($primaryActionButton.text(), applyExamplesText, 'the primary button should display the value of applyExamplesText');
kanban.destroy();
});
QUnit.test('quick create column and examples background with ghostColumns titles', async function (assert) {
assert.expect(4);