mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] web_notify: action button name and close
- We can now set a button name to the notification action. - We can set an icon button as well. - After the button is clicked, the notification gets closed.
This commit is contained in:
@@ -16,28 +16,34 @@ export const webNotificationService = {
|
||||
browser.clearTimeout(notif)
|
||||
);
|
||||
webNotifTimeouts = {};
|
||||
notifications.forEach(function (notif) {
|
||||
browser.setTimeout(function () {
|
||||
let buttons = [];
|
||||
|
||||
if (notif.action) {
|
||||
buttons = [
|
||||
{
|
||||
name: env._t("Open"),
|
||||
primary: true,
|
||||
onClick: async () => {
|
||||
await action.doAction(notif.action);
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
notification.add(Markup(notif.message), {
|
||||
notifications.forEach((notif) => {
|
||||
browser.setTimeout(() => {
|
||||
const notificationRemove = notification.add(Markup(notif.message), {
|
||||
title: notif.title,
|
||||
type: notif.type,
|
||||
sticky: notif.sticky,
|
||||
className: notif.className,
|
||||
messageIsHtml: notif.html,
|
||||
buttons: buttons,
|
||||
buttons:
|
||||
notif.action &&
|
||||
notif.action.context &&
|
||||
notif.action.context.params
|
||||
? [
|
||||
{
|
||||
name:
|
||||
notif.action.context.params.button_name ||
|
||||
env._t("Open"),
|
||||
primary: true,
|
||||
onClick: async function () {
|
||||
await action.doAction(notif.action);
|
||||
notificationRemove();
|
||||
},
|
||||
icon:
|
||||
notif.action.context.params.button_icon ||
|
||||
undefined,
|
||||
},
|
||||
]
|
||||
: [],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user