rework registry

This commit is contained in:
Géry Debongnie
2019-02-02 16:51:24 +01:00
parent c9f2a6147c
commit e26cf25bd3
10 changed files with 57 additions and 63 deletions
+52
View File
@@ -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 });
}
}