mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
improve notification system
This commit is contained in:
@@ -8,7 +8,7 @@ import { Env } from "./env";
|
||||
const template = `
|
||||
<div class="o_web_client">
|
||||
<t t-widget="Navbar"/>
|
||||
<div class="o_content" t-ref="content"></div>
|
||||
<div class="o_content" t-ref="content"/>
|
||||
<div class="o_notification_container">
|
||||
<t t-foreach="state.notifications" t-as="notif">
|
||||
<t t-widget="Notification" t-props="notif"/>
|
||||
@@ -27,7 +27,9 @@ export class Root extends Widget<Env, {}> {
|
||||
|
||||
mounted() {
|
||||
this.env.actionManager.on("action_ready", this, this.setContentWidget);
|
||||
this.env.notifications.on("notification_added", this, this.addNotification);
|
||||
this.env.notifications.on("notification_added", this, this.addNotif);
|
||||
this.env.notifications.on("notification_removed", this, this.removeNotif);
|
||||
|
||||
const actionWidget = this.env.actionManager.getCurrentAction();
|
||||
if (actionWidget) {
|
||||
this.setContentWidget(actionWidget);
|
||||
@@ -44,8 +46,12 @@ export class Root extends Widget<Env, {}> {
|
||||
this.content = newWidget;
|
||||
}
|
||||
|
||||
addNotification(notif: INotification) {
|
||||
addNotif(notif: INotification) {
|
||||
const notifications = this.state.notifications.concat(notif);
|
||||
this.updateState({ notifications });
|
||||
}
|
||||
removeNotif(notif: INotification) {
|
||||
const notifs = this.state.notifications.filter(f => f.id !== notif.id);
|
||||
this.updateState({ notifications: notifs });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user