From 7ceb7782b43e375a135127a755b50caa0c275507 Mon Sep 17 00:00:00 2001 From: wan Date: Fri, 4 Sep 2020 13:58:43 +0000 Subject: [PATCH] [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. --- addons/web_tour/static/src/js/tour_manager.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index f4055acfcef..cb7f02dba5d 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -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('Good job! You went through all steps of this tour.'); + let message = this.tours[tour_name].rainbowManMessage; + if (message) { + message = typeof message === 'function' ? message() : message; + } else { + message = _t('Good job! You went through all steps of this tour.'); + } const fadeout = this.tours[tour_name].fadeout; new RainbowMan({message, fadeout}).appendTo(this.$body); }