[IMP] web_tour: rainbowManMessage as a function

Task 2327599

In some cases, we want a function to evaluate the string shown by the
rainbow man.
For instance, if the message should depend on the state of other tours.
This commit is contained in:
wan
2020-09-10 12:32:11 +00:00
parent 9c58c51179
commit 7ceb7782b4
@@ -64,6 +64,9 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, {
* sequence will be executed in a non deterministic order).
* @param {Promise} [options.wait_for]
* indicates when the tour can be started
* @param {string|function} [options.rainbowManMessage]
text or function returning the text displayed under the rainbowman
at the end of the tour.
* @param {Object[]} steps - steps' descriptions, each step being an object
* containing a tip description
*/
@@ -396,8 +399,12 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, {
//display rainbow at the end of any tour
if (this.tours[tour_name].rainbowMan && this.running_tour !== tour_name &&
this.tours[tour_name].current_step === this.tours[tour_name].steps.length) {
const message = this.tours[tour_name].rainbowManMessage ||
_t('<strong><b>Good job!</b> You went through all steps of this tour.</strong>');
let message = this.tours[tour_name].rainbowManMessage;
if (message) {
message = typeof message === 'function' ? message() : message;
} else {
message = _t('<strong><b>Good job!</b> You went through all steps of this tour.</strong>');
}
const fadeout = this.tours[tour_name].fadeout;
new RainbowMan({message, fadeout}).appendTo(this.$body);
}