[FIX] web_tour: native events + better error messages

This commit is two-fold:
 1) events triggered with jQuery do not go through the native
    layer, so if an handler has been bound natively, it won't be
    called. Since our new code no longer uses jQuery, this caused
    issue in some tours.
 2) this commit explicitely logs the failing step when a tour
    crashes, which helps debugging.

Part-of: odoo/odoo#92475
This commit is contained in:
Samuel Degueldre
2022-06-30 09:29:40 +02:00
committed by Aaron Bohy
parent 442d855c2e
commit a535d7c6fb
2 changed files with 8 additions and 3 deletions
@@ -110,7 +110,7 @@ var RunningTourActionHelper = core.Class.extend({
values.$element.focusInEnd();
values.$element.trigger($.Event( "keyup", {key: '_', keyCode: 95}));
}
values.$element.trigger("change");
values.$element[0].dispatchEvent(new Event("change", { bubbles: true, cancelable: false }));
},
_text_blur: function (values, text) {
this._text(values, text);
@@ -189,7 +189,7 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, {
// redirect to its starting point (or /web by default)
window.location.href = window.location.origin + (tour.url || '/web');
},
run: function (tour_name, step_delay) {
run: async function (tour_name, step_delay) {
console.log(_.str.sprintf("Preparing tour %s", tour_name));
if (this.running_tour) {
this._deactivate_tip(this.active_tooltips[this.running_tour]);
@@ -534,7 +534,12 @@ return core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, {
tip.run.call(tip.widget, action_helper);
} else if (tip.run !== undefined) {
var m = tip.run.match(/^([a-zA-Z0-9_]+) *(?:\(? *(.+?) *\)?)?$/);
action_helper[m[1]](m[2]);
try {
action_helper[m[1]](m[2]);
} catch (e) {
console.error(`Tour ${tour_name} failed at step ${self._describeTip(tip)}: ${e.message}`);
throw e;
}
} else if (tour.current_step === tour.steps.length - 1) {
console.log('Tour %s: ignoring action (auto) of last step', tour_name);
} else {