ch2.8 lazy loading

This commit is contained in:
Matt Marcha 2024-09-20 15:55:56 -10:00
parent a9713b4667
commit 7aa696f174
10 changed files with 22 additions and 3 deletions

View file

@ -24,6 +24,10 @@
'assets': { 'assets': {
'web.assets_backend': [ 'web.assets_backend': [
'awesome_dashboard/static/src/**/*', 'awesome_dashboard/static/src/**/*',
('remove', 'awesome_dashboard/static/src/dashboard/**/*'),
],
'awesome_dashboard.dashboard': [
'awesome_dashboard/static/src/dashboard/**/*'
], ],
}, },
'license': 'AGPL-3' 'license': 'AGPL-3'

View file

@ -1,10 +1,10 @@
/** @odoo-module **/ /** @odoo-module **/
import { Component, onWillStart, useState } from "@odoo/owl"; import { Component, useState } from "@odoo/owl";
import { registry } from "@web/core/registry"; import { registry } from "@web/core/registry";
import { Layout } from "@web/search/layout"; import { Layout } from "@web/search/layout";
import { useService } from "@web/core/utils/hooks" import { useService } from "@web/core/utils/hooks"
import { DashboardItem } from "./dashboard_item"; import { DashboardItem } from "./dashboard_item/dashboard_item";
import { Piechart } from "./piechart/piechart"; import { Piechart } from "./piechart/piechart";
class AwesomeDashboard extends Component { class AwesomeDashboard extends Component {
@ -35,4 +35,4 @@ class AwesomeDashboard extends Component {
} }
} }
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboard); registry.category("lazy_components").add("AwesomeDashboard", AwesomeDashboard);

View file

@ -0,0 +1,15 @@
/** @odoo-module */
import { registry } from "@web/core/registry";
import { LazyComponent } from "@web/core/assets";
import { Component, xml } from "@odoo/owl";
class AwesomeDashboardLoader extends Component {
static components = { LazyComponent };
static template = xml`
<LazyComponent bundle="'awesome_dashboard.dashboard'" Component="'AwesomeDashboard'" props="props"/>
`;
}
registry.category("actions").add("awesome_dashboard.dashboard", AwesomeDashboardLoader);