mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
rename root_widget into root
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { Widget } from "./core/widget";
|
||||
import { Navbar } from "./widgets/navbar";
|
||||
import { ActionWidget } from "./services/action_manager";
|
||||
import { Env } from "./env";
|
||||
|
||||
const template = `
|
||||
<div class="o_web_client">
|
||||
<t t-widget="Navbar"/>
|
||||
<div class="o_content" t-ref="content">
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export class Root extends Widget<Env, {}> {
|
||||
name = "root";
|
||||
template = template;
|
||||
widgets = { Navbar };
|
||||
content: Widget<Env, {}> | null = null;
|
||||
|
||||
mounted() {
|
||||
this.env.actionManager.on("action_ready", this, this.setContentWidget);
|
||||
const actionWidget = this.env.actionManager.getCurrentAction();
|
||||
if (actionWidget) {
|
||||
this.setContentWidget(actionWidget);
|
||||
}
|
||||
}
|
||||
|
||||
async setContentWidget(actionWidget: ActionWidget) {
|
||||
const currentWidget = this.content;
|
||||
const newWidget = new actionWidget.Widget(this, actionWidget.props);
|
||||
await newWidget.mount(<HTMLElement>this.refs.content);
|
||||
if (currentWidget) {
|
||||
currentWidget.destroy();
|
||||
}
|
||||
this.content = newWidget;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user