2019-02-03 14:14:09 +01:00
|
|
|
import { INotification } from "../core/notifications";
|
2019-02-02 16:51:24 +01:00
|
|
|
import { Widget } from "../core/widget";
|
|
|
|
|
import { Env } from "../env";
|
2019-02-03 14:14:09 +01:00
|
|
|
import { MenuInfo } from "../misc/menu_helpers";
|
2019-02-02 16:51:24 +01:00
|
|
|
import { ActionStack } from "../services/action_manager";
|
2019-02-03 14:07:25 +01:00
|
|
|
import { ActionContainer } from "./action_container";
|
2019-02-02 16:51:24 +01:00
|
|
|
import { HomeMenu } from "./home_menu";
|
|
|
|
|
import { Navbar } from "./navbar";
|
|
|
|
|
import { Notification } from "./notification";
|
2019-01-22 10:38:44 +01:00
|
|
|
|
2019-01-31 13:19:30 +01:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
// Types
|
|
|
|
|
//------------------------------------------------------------------------------
|
2019-01-22 10:38:44 +01:00
|
|
|
|
2019-01-31 10:55:41 +01:00
|
|
|
interface State {
|
|
|
|
|
notifications: INotification[];
|
2019-01-31 13:19:30 +01:00
|
|
|
stack: ActionStack;
|
2019-02-02 18:17:21 +01:00
|
|
|
inHome: boolean;
|
2019-01-31 10:55:41 +01:00
|
|
|
}
|
|
|
|
|
|
2019-02-03 14:14:09 +01:00
|
|
|
interface Props {
|
|
|
|
|
menuInfo: MenuInfo;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-31 13:19:30 +01:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
// Root Widget
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
|
|
2019-02-03 14:14:09 +01:00
|
|
|
export class Root extends Widget<Env, Props> {
|
2019-02-03 14:07:25 +01:00
|
|
|
template = "web.web_client";
|
|
|
|
|
widgets = { Navbar, Notification, HomeMenu, ActionContainer };
|
2019-01-22 10:38:44 +01:00
|
|
|
|
2019-01-31 10:55:41 +01:00
|
|
|
state: State = {
|
|
|
|
|
notifications: [],
|
2019-01-31 13:19:30 +01:00
|
|
|
stack: [],
|
2019-02-02 18:17:21 +01:00
|
|
|
inHome: false
|
2019-01-31 10:55:41 +01:00
|
|
|
};
|
|
|
|
|
|
2019-01-22 10:38:44 +01:00
|
|
|
mounted() {
|
2019-01-31 13:19:30 +01:00
|
|
|
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();
|
2019-01-29 16:13:05 +01:00
|
|
|
}
|
2019-01-31 10:55:41 +01:00
|
|
|
|
2019-01-31 13:19:30 +01:00
|
|
|
toggleHome() {
|
2019-02-02 18:17:21 +01:00
|
|
|
this.updateState({ inHome: !this.state.inHome });
|
2019-01-31 10:55:41 +01:00
|
|
|
}
|
2019-01-22 10:38:44 +01:00
|
|
|
}
|