summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorVincent Schippefilt <vsc@odoo.com>2019-03-06 14:02:33 +0100
committerAaron Bohy <aab@odoo.com>2019-03-06 20:07:17 +0100
commit61b59c031f574475a7c4ebbc7bd1c952306aeb7a (patch)
tree93e255c00611bd41ea6e71dba6d8f659d54f91c4 /addons
parent8356a00a68ebdc97829d6b4b2896bdcec9a6b67f (diff)
[REF] web_tour: adapt code after jQuery update
Part of task 1896658 Co-authored-by: Aaron Bohy <aab@odoo.com> Co-authored-by: Christophe Matthieu <chm@odoo.com> Co-authored-by: Mathieu Duckerts-Antoine <dam@odoo.com> Co-authored-by: David Monjoie <dmo@odoo.com> Co-authored-by: Martin Geubelle <mge@odoo.com> Co-authored-by: svs-odoo <svs@odoo.com> Co-authored-by: Vincent Schippefilt <vsc@odoo.com>
Diffstat (limited to 'addons')
-rw-r--r--addons/web_tour/static/src/js/tour_manager.js6
-rw-r--r--addons/web_tour/static/src/js/tour_service.js46
2 files changed, 24 insertions, 28 deletions
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 = '<p><span class="o_skip_tour">' + _t('Skip tour') + '</span></p>';
@@ -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;
};
})();