[IMP] javascript_reference: apply changes from odoo/odoo#67009

task-2476867
This commit is contained in:
Sébastien Theys 2021-05-27 17:43:42 +02:00 committed by GitHub
parent 131f48bc38
commit ead1b9a533
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1660,52 +1660,54 @@ The notification system in Odoo is designed with the following components:
of a notification from python (e.g. in the method called when the user of a notification from python (e.g. in the method called when the user
clicked on a button of type object). clicked on a button of type object).
- two helper functions in *ServiceMixin*: *do_notify* and *do_warn* - an helper function in *ServiceMixin*: *displayNotification*
Displaying a notification Displaying a notification
------------------------- -------------------------
The most common way to display a notification is by using two methods that come The most common way to display a notification is by using the method that come
from the *ServiceMixin*: from the *ServiceMixin*:
- *do_notify(title, message, sticky, className)*: - *displayNotification(options)*:
Display a notification of type *notification*. Display a notification with the following *options*:
- *title*: string. This will be displayed on the top as a title - *title*: string, optional. This will be displayed on the top as a title.
- *message*: string, the content of the notification - *subtitle*: string, optional. This will be displayed on the top as a
subtitle.
- *sticky*: boolean, optional. If true, the notification will stay until the - *message*: string, optional. The content of the notification.
user dismisses it. Otherwise, the notification will be automatically
closed after a short delay. - *sticky*: boolean, optional (default false). If true, the notification
will stay until the user dismisses it. Otherwise, the notification will
be automatically closed after a short delay.
- *type*: string, optional (default 'warning'). Determines the style of the
notification. Possible values: 'info', 'success', 'warning', 'danger', ''.
- *className*: string, optional. This is a css class name that will be - *className*: string, optional. This is a css class name that will be
automatically added to the notification. This could be useful for styling automatically added to the notification. This could be useful for styling
purpose, even though its use is discouraged. purpose, even though its use is discouraged.
- *do_warn(title, message, sticky, className)*: - *messageIsHtml*: boolean, optional (default false). Allows passing an html
Display a notification of type *warning*. message. Strongly discouraged: other options should be considered before
enabling this option. The responsibility is on the caller to properly
- *title*: string. This will be displayed on the top as a title escape the message if this option is enabled.
- *message*: string, the content of the notification
- *sticky*: boolean, optional. If true, the notification will stay until the
user dismisses it. Otherwise, the notification will be automatically
closed after a short delay.
- *className*: string, optional. This is a css class name that will be
automatically added to the notification. This could be useful for styling
purpose, even though its use is discouraged.
Here are two examples on how to use these methods: Here are two examples on how to use these methods:
.. code-block:: javascript .. code-block:: javascript
// note that we call _t on the text to make sure it is properly translated. // note that we call _t on the text to make sure it is properly translated.
this.do_notify(_t("Success"), _t("Your signature request has been sent.")); this.displayNotification({
title: _t("Success"),
this.do_warn(_t("Error"), _t("Filter name is required.")); message: _t("Your signature request has been sent.")
});
this.displayNotification({
title: _t("Error"),
message: _t("Filter name is required."),
type: 'danger',
});
Here an example in python: Here an example in python: