diff --git a/addons/web_tour/static/src/js/tour_manager.js b/addons/web_tour/static/src/js/tour_manager.js index e622d3929d7..18b2c47d6b3 100644 --- a/addons/web_tour/static/src/js/tour_manager.js +++ b/addons/web_tour/static/src/js/tour_manager.js @@ -49,7 +49,7 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, { * the url to load when manually running the tour * @param {boolean} [options.rainbowMan=true] * whether or not the rainbowman must be shown at the end of the tour - * @param {Deferred} [options.wait_for] + * @param {Promise} [options.wait_for] * indicates when the tour can be started * @param {Object[]} steps - steps' descriptions, each step being an object * containing a tip description @@ -70,7 +70,7 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, { url: options.url, rainbowMan: options.rainbowMan === undefined ? true : !!options.rainbowMan, test: options.test, - wait_for: options.wait_for || $.when(), + wait_for: options.wait_for || Promise.resolve(), }; if (options.skip_enabled) { tour.skip_link = '
' + _t('Skip tour') + '
'; @@ -88,7 +88,7 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, { _.each(this.tours, this._register.bind(this, do_update)); }, _register: function (do_update, tour, name) { - if (tour.ready) return $.when(); + if (tour.ready) return Promise.resolve(); var tour_is_consumed = _.contains(this.consumed_tours, name); diff --git a/addons/web_tour/static/src/js/tour_service.js b/addons/web_tour/static/src/js/tour_service.js index b0507d22e43..6f2300853f8 100644 --- a/addons/web_tour/static/src/js/tour_service.js +++ b/addons/web_tour/static/src/js/tour_service.js @@ -1,20 +1,15 @@ odoo.define('web_tour.tour', function (require) { "use strict"; -var ajax = require('web.ajax'); var config = require('web.config'); -var core = require('web.core'); var rootWidget = require('root.widget'); var rpc = require('web.rpc'); var session = require('web.session'); var TourManager = require('web_tour.TourManager'); -var QWeb = core.qweb; - if (config.device.isMobile) { - return $.Deferred().reject(); + return Promise.reject(); } - /** * @namespace * @property {Object} active_tooltips @@ -37,8 +32,8 @@ return session.is_bound.then(function () { }); defs.push(def); } - return $.when.apply($, defs).then(function (consumed_tours) { - consumed_tours = session.is_frontend ? consumed_tours : session.web_tours; + return Promise.all(defs).then(function (results) { + var consumed_tours = session.is_frontend ? results[0] : session.web_tours; var tour_manager = new TourManager(rootWidget, consumed_tours); // Use a MutationObserver to detect DOM changes @@ -64,25 +59,26 @@ return session.is_bound.then(function () { return function (observe) { - var def = $.Deferred(); - $(function () { - /** - * Once the DOM is ready, we still have to wait all the modules are loaded before completing the tours - * registration and starting listening for DOM mutations. - */ - _.defer(function () { - tour_manager._register_all(observe); - if (observe) { - observer.observe(document.body, { - attributes: true, - childList: true, - subtree: true, - }); - } - def.resolve(); + var promise = new Promise(function (resolve, reject) { + $(function () { + /** + * Once the DOM is ready, we still have to wait all the modules are loaded before completing the tours + * registration and starting listening for DOM mutations. + */ + _.defer(function () { + tour_manager._register_all(observe); + if (observe) { + observer.observe(document.body, { + attributes: true, + childList: true, + subtree: true, + }); + } + resolve(); + }); }); }); - return def; + return promise; }; })();