You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.8 KiB

  1. /**********************************************************************************
  2. *
  3. * Copyright (c) 2017-2019 MuK IT GmbH.
  4. *
  5. * This file is part of MuK Web Notification
  6. * (see https://mukit.at).
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU Affero General Public License as
  10. * published by the Free Software Foundation, either version 3 of the
  11. * License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. *
  21. **********************************************************************************/
  22. odoo.define('muk_web_client_notification.channel', function (require) {
  23. "use strict";
  24. var WebClient = require('web.WebClient');
  25. var NotificationService = require('web.NotificationService');
  26. WebClient.include({
  27. show_application: function() {
  28. this.bus_declare_channel('notify', this.notify.bind(this));
  29. return this._super.apply(this, arguments);
  30. },
  31. notify: function(message) {
  32. this.call('notification', 'notify', _.extend(message, {
  33. buttons: _.map(message.buttons, function(button) {
  34. button.click = this._notification_click.bind(this, {
  35. 'action': button.action,
  36. 'options': button.options,
  37. 'button': button,
  38. 'message': message
  39. });
  40. return button;
  41. }, this),
  42. }));
  43. },
  44. _notification_click: function(params) {
  45. this.action_manager.doAction(params.action, params.options)
  46. }
  47. });
  48. });