mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
rework registry
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
import { Widget } from "../core/widget";
|
||||
import { Env } from "../env";
|
||||
import { ActionStack } from "../services/action_manager";
|
||||
import { INotification } from "../core/notifications";
|
||||
import { Action } from "./action";
|
||||
import { HomeMenu } from "./home_menu";
|
||||
import { Navbar } from "./navbar";
|
||||
import { Notification } from "./notification";
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Types
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
interface State {
|
||||
notifications: INotification[];
|
||||
stack: ActionStack;
|
||||
inMenu: boolean;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Root Widget
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
export class Root extends Widget<Env, {}> {
|
||||
template = "web_client";
|
||||
widgets = { Navbar, Notification, HomeMenu, Action };
|
||||
|
||||
state: State = {
|
||||
notifications: [],
|
||||
stack: [],
|
||||
inMenu: false
|
||||
};
|
||||
|
||||
constructor(env: Env) {
|
||||
super(env);
|
||||
this.toggleHome = this.toggleHome.bind(this);
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.env.notifications.on("notifications_updated", this, notifs =>
|
||||
this.updateState({ notifications: notifs })
|
||||
);
|
||||
this.env.actionManager.on("action_stack_updated", this, stack =>
|
||||
this.updateState({ stack })
|
||||
);
|
||||
this.env.actionManager.activate();
|
||||
}
|
||||
|
||||
toggleHome() {
|
||||
this.updateState({ inMenu: !this.state.inMenu });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user