[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>
This commit is contained in:
committed by
Aaron Bohy
co-authored by
Aaron Bohy
Christophe Matthieu
Mathieu Duckerts-Antoine
David Monjoie
Martin Geubelle
svs-odoo
parent
8356a00a68
commit
61b59c031f
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
})();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user