This commit introduces the 'rainbowification' feature to the web client
(and to some affected addons). This feature is essentially a way to
display a nice friendly message when some business event happens. For
example, a encouraging message is displayed when the user clear her/his
inbox, or when a salesman closes a deal.
The mechanism currently only displays a 'rainbowman', but could be
extended later to add other kind of animation.
There are a few different ways to display a 'rainbowman':
- any JS code can simply trigger_up an event ('show_effect') with some
options: for example
this.trigger_up('show_effect', {
type: 'rainbow_man',
fadeout: 'no',
message: $done,
click_close: false,
});
- an action returned by the server can have an 'effect' key, with some
options
- the do_execute_action method accepts a 'effect' option. This is
useful when one wants to specify a rainbow on an action button in a
form view
Joint work with: dbh <dbh@odoo.com>, ged <ged@odoo.com>
38 lines
972 B
JavaScript
38 lines
972 B
JavaScript
odoo.define('web.rainbow_man_tests', function (require) {
|
|
"use strict";
|
|
|
|
var RainbowMan = require('web.rainbow_man');
|
|
|
|
QUnit.module('widgets', {}, function () {
|
|
|
|
QUnit.module('RainbowMan', {
|
|
beforeEach: function () {
|
|
this.data = {
|
|
message: 'Congrats!',
|
|
click_close: false
|
|
};
|
|
},
|
|
}, function () {
|
|
|
|
QUnit.test("rendering a rainbowman", function (assert) {
|
|
assert.expect(2);
|
|
|
|
var $target = $("#qunit-fixture");
|
|
|
|
// Create and display rainbowman
|
|
var rainbowman = new RainbowMan(this.data);
|
|
rainbowman.appendTo($target);
|
|
|
|
var $rainbow = rainbowman.$(".o_reward_rainbow");
|
|
assert.strictEqual($rainbow.length, 1,
|
|
"Should have displayed rainbow effect");
|
|
|
|
assert.ok(rainbowman.$('.o_reward_msg_content').html() === 'Congrats!',
|
|
"Card on the rainbowman should display 'Congrats!' message");
|
|
|
|
rainbowman.destroy();
|
|
});
|
|
});
|
|
});
|
|
});
|