Files
web/web_help/static/src/helpers.esm.js
tarteo 52119a7984 web_help: Improve helpers
web_help: Improve helpers

fix layout issue

fix layout issue
2023-07-04 14:18:11 +02:00

41 lines
1.1 KiB
JavaScript

/** @odoo-module **/
import {registry} from "@web/core/registry";
import {Component} from "@odoo/owl";
export async function findTrip(model, viewType) {
const trips = registry.category("trips").getAll();
const selectorResults = await Promise.all(
trips.map((trip) => trip.selector(model, viewType))
);
const matchedTrips = trips.filter((trip, i) => selectorResults[i]);
if (matchedTrips.length >= 1) {
if (matchedTrips.length != 1) {
console.warn("More than one trip found", model, viewType);
}
return matchedTrips[0].Trip;
}
return null;
}
export function wait(ms) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
export async function waitUntilAvailable(selector, ms = 50) {
const selection = $(selector);
if (!selection.length) {
await wait(ms);
return await waitUntilAvailable(selector, ms);
}
return selection;
}
export async function doAction(xmlId, options = {}) {
Component.env.bus.trigger("do-action", {
action: xmlId,
options: options,
});
}