diff options
| author | fja-odoo <fja@odoo.com> | 2019-06-11 12:26:57 +0000 |
|---|---|---|
| committer | fja-odoo <fja@odoo.com> | 2019-06-28 08:53:53 +0000 |
| commit | 283f8fed6e85f2df0386de46138129b4cadc52d7 (patch) | |
| tree | 296f46e0038125cf3b6a2e17b0c8d889f8c8dcac /addons/web/static/src/js/services | |
| parent | 0d1407a715901ea06e9a7211c0e3dbe09fadb785 (diff) | |
[IMP] web, *: display rpc warnings with toasts
* = test_website, partner_autocomplete
- All the rpc warnings are now displayed using the notification system
of https://github.com/odoo/odoo/commit/b94395b50175925fc7d1bd3655e5facb78a8ba2b
- test_website is up to date
Part of https://github.com/odoo/odoo/pull/32132
task-1894820
Diffstat (limited to 'addons/web/static/src/js/services')
| -rw-r--r-- | addons/web/static/src/js/services/crash_manager.js | 27 | ||||
| -rw-r--r-- | addons/web/static/src/js/services/notification_service.js | 1 |
2 files changed, 17 insertions, 11 deletions
diff --git a/addons/web/static/src/js/services/crash_manager.js b/addons/web/static/src/js/services/crash_manager.js index a8fafa4b897..6a78d776afa 100644 --- a/addons/web/static/src/js/services/crash_manager.js +++ b/addons/web/static/src/js/services/crash_manager.js @@ -4,6 +4,9 @@ odoo.define('web.CrashManager', function (require) { var ajax = require('web.ajax'); var core = require('web.core'); var Dialog = require('web.Dialog'); +var mixins = require('web.mixins'); +var ServicesMixin = require('web.ServicesMixin'); +var ServiceProviderMixin = require('web.ServiceProviderMixin'); var Widget = require('web.Widget'); var _t = core._t; @@ -75,12 +78,14 @@ var WarningDialog = CrashManagerDialog.extend({ }, }); -var CrashManager = core.Class.extend({ +var CrashManager = core.Class.extend(mixins.EventDispatcherMixin, ServicesMixin, ServiceProviderMixin,{ init: function () { var self = this; this.active = true; this.isConnected = true; + mixins.EventDispatcherMixin.init.call(this); + // crash manager integration core.bus.on('rpc_error', this, this.rpc_error); window.onerror = function (message, file, line, col, error) { @@ -139,6 +144,7 @@ var CrashManager = core.Class.extend({ ev.preventDefault(); } }); + ServiceProviderMixin.init.call(this); }, enable: function () { this.active = true; @@ -192,7 +198,7 @@ var CrashManager = core.Class.extend({ data: _.extend({}, error.data, { message: error.data.arguments[1], - title: error.data.arguments[0] !== 'Warning' ? (" - " + error.data.arguments[0]) : '', + title: error.data.arguments[0] !== 'Warning' ? error.data.arguments[0] : '', }) }); } @@ -213,14 +219,11 @@ var CrashManager = core.Class.extend({ data: _.extend({}, error.data, { message: error.data.arguments[0], - title: map_title[error.data.exception_type] !== 'Warning' ? (" - " + map_title[error.data.exception_type]) : '', + title: map_title[error.data.exception_type] !== 'Warning' ? map_title[error.data.exception_type] : '', }) }); } - this.show_warning(error); - //InternalError - } else { this.show_error(error); } @@ -230,12 +233,14 @@ var CrashManager = core.Class.extend({ return; } var message = error.data ? error.data.message : error.message; - return new WarningDialog(this, { - title: _.str.capitalize(error.type) || _t("Odoo Warning"), - subtitle: error.data.title, - }, { + var title = _.str.capitalize(error.type) || _t("Oops Something went wrong !"); + var subtitle = error.data ? error.data.title : error.title; + this.displayNotification({ + title: title, message: message, - }).open(); + subtitle: subtitle, + sticky: true, + }); }, show_error: function (error) { if (!this.active) { diff --git a/addons/web/static/src/js/services/notification_service.js b/addons/web/static/src/js/services/notification_service.js index ea16d9ef66f..295b49d760c 100644 --- a/addons/web/static/src/js/services/notification_service.js +++ b/addons/web/static/src/js/services/notification_service.js @@ -60,6 +60,7 @@ var NotificationService = AbstractService.extend({ * @param {function} [params.Notification] javascript class of a notification * to instantiate by default use 'web.Notification' * @param {string} params.title notification title + * @param {string} params.subtitle notification subtitle * @param {string} params.message notification main message * @param {string} params.type 'notification' or 'warning' * @param {boolean} [params.sticky=false] if true, the notification will stay |
