mirror of
https://github.com/bringout/oca-ocb-report.git
synced 2026-04-22 11:42:06 +02:00
19.0 vanilla
This commit is contained in:
parent
62d197ac8b
commit
184bb0e321
667 changed files with 691406 additions and 239886 deletions
|
|
@ -0,0 +1,77 @@
|
|||
import { Model, Spreadsheet } from "@odoo/o-spreadsheet";
|
||||
import { loadBundle } from "@web/core/assets";
|
||||
|
||||
import { getFixture } from "@odoo/hoot";
|
||||
import { animationFrame } from "@odoo/hoot-mock";
|
||||
import { Component, xml } from "@odoo/owl";
|
||||
import { useSpreadsheetNotificationStore } from "@spreadsheet/hooks";
|
||||
import { PublicReadonlySpreadsheet } from "@spreadsheet/public_readonly_app/public_readonly";
|
||||
import { mountWithCleanup } from "@web/../tests/web_test_helpers";
|
||||
|
||||
class Parent extends Component {
|
||||
static template = xml`<Spreadsheet model="props.model"/>`;
|
||||
static components = { Spreadsheet };
|
||||
static props = { model: Model };
|
||||
setup() {
|
||||
useSpreadsheetNotificationStore();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mount o-spreadsheet component with the given spreadsheet model
|
||||
* @param {Model} model
|
||||
* @returns {Promise<HTMLElement>}
|
||||
*/
|
||||
export async function mountSpreadsheet(model) {
|
||||
// const serviceRegistry = registry.category("services");
|
||||
// serviceRegistry.add("dialog", makeFakeDialogService(), { force: true });
|
||||
// serviceRegistry.add("notification", makeFakeNotificationService(), { force: true });
|
||||
await loadBundle("web.chartjs_lib");
|
||||
mountWithCleanup(Parent, {
|
||||
props: {
|
||||
model,
|
||||
},
|
||||
env: model.config.custom.env,
|
||||
noMainContainer: true,
|
||||
});
|
||||
await animationFrame();
|
||||
return getFixture();
|
||||
}
|
||||
|
||||
/**
|
||||
* Mount public spreadsheet component with the given data
|
||||
* @returns {Promise<HTMLElement>}
|
||||
*/
|
||||
export async function mountPublicSpreadsheet(dataUrl, mode, downloadExcelUrl = "") {
|
||||
mountWithCleanup(PublicReadonlySpreadsheet, {
|
||||
props: {
|
||||
dataUrl,
|
||||
downloadExcelUrl,
|
||||
mode,
|
||||
},
|
||||
noMainContainer: true,
|
||||
});
|
||||
await animationFrame();
|
||||
return getFixture();
|
||||
}
|
||||
|
||||
export async function doMenuAction(registry, path, env) {
|
||||
await getActionMenu(registry, path, env).execute(env);
|
||||
}
|
||||
|
||||
export function getActionMenu(registry, _path, env) {
|
||||
const path = [..._path];
|
||||
let items = registry.getMenuItems();
|
||||
while (items.length && path.length) {
|
||||
const id = path.shift();
|
||||
const item = items.find((item) => item.id === id);
|
||||
if (!item) {
|
||||
throw new Error(`Menu item ${id} not found`);
|
||||
}
|
||||
if (path.length === 0) {
|
||||
return item;
|
||||
}
|
||||
items = item.children(env);
|
||||
}
|
||||
throw new Error(`Menu item not found`);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue