mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
display notifications in a declarative way
This commit is contained in:
@@ -13,9 +13,8 @@ import { Action } from "../store/action_manager_mixin";
|
||||
|
||||
export class Root extends Widget<Store, State> {
|
||||
template = "web.web_client";
|
||||
widgets = { Navbar, HomeMenu };
|
||||
widgets = { Navbar, HomeMenu, Notification };
|
||||
|
||||
notifications: { [id: number]: Notification } = {};
|
||||
store: Store;
|
||||
|
||||
constructor(env: Env, store: Store) {
|
||||
@@ -23,22 +22,12 @@ export class Root extends Widget<Store, State> {
|
||||
this.store = store;
|
||||
this.state = store.state;
|
||||
}
|
||||
|
||||
mounted() {
|
||||
this.store.on("state_updated", this, newState => {
|
||||
this.updateState(newState);
|
||||
});
|
||||
|
||||
// notifications
|
||||
this.store.on("notification_added", this, notif => {
|
||||
const notification = new Notification(this, notif);
|
||||
this.notifications[notif.id] = notification;
|
||||
notification.mount(<any>this.refs.notification_container);
|
||||
});
|
||||
this.store.on("notification_closed", this, id => {
|
||||
this.notifications[id].destroy();
|
||||
delete this.notifications[id];
|
||||
});
|
||||
|
||||
// loading indicator
|
||||
this.store.on("rpc_status", this, status => {
|
||||
const method = status === "loading" ? "remove" : "add";
|
||||
|
||||
Reference in New Issue
Block a user