diff options
| author | Dharmraj Jhala <dja@openerp.com> | 2017-05-11 17:15:15 +0530 |
|---|---|---|
| committer | Géry Debongnie <ged@odoo.com> | 2017-07-12 13:43:08 +0200 |
| commit | 4330ea02676a4afd88707bb463a007e7de3c8686 (patch) | |
| tree | f547124a18fd30e09433a65cd9aa7b5a6645131a /addons/mail/static/src | |
| parent | 578edf73b9f637b0d27708c511b542a27bd7a3b8 (diff) | |
[ADD] web, *: add rainbowification
This commit introduces the 'rainbowification' feature to the web client
(and to some affected addons). This feature is essentially a way to
display a nice friendly message when some business event happens. For
example, a encouraging message is displayed when the user clear her/his
inbox, or when a salesman closes a deal.
The mechanism currently only displays a 'rainbowman', but could be
extended later to add other kind of animation.
There are a few different ways to display a 'rainbowman':
- any JS code can simply trigger_up an event ('show_effect') with some
options: for example
this.trigger_up('show_effect', {
type: 'rainbow_man',
fadeout: 'no',
message: $done,
click_close: false,
});
- an action returned by the server can have an 'effect' key, with some
options
- the do_execute_action method accepts a 'effect' option. This is
useful when one wants to specify a rainbow on an action button in a
form view
Joint work with: dbh <dbh@odoo.com>, ged <ged@odoo.com>
Diffstat (limited to 'addons/mail/static/src')
| -rw-r--r-- | addons/mail/static/src/js/chat_manager.js | 2 | ||||
| -rw-r--r-- | addons/mail/static/src/js/client_action.js | 18 |
2 files changed, 16 insertions, 4 deletions
diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index ce44841533c..d0c41ad67b3 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -511,7 +511,7 @@ function on_mark_as_read_notification (data) { if (message) { invalidate_caches(message.channel_ids); remove_message_from_channel("channel_inbox", message); - chat_manager.bus.trigger('update_message', message); + chat_manager.bus.trigger('update_message', message, data.type); } }); if (data.channel_ids) { diff --git a/addons/mail/static/src/js/client_action.js b/addons/mail/static/src/js/client_action.js index 691d1ee968d..a3cbc75a949 100644 --- a/addons/mail/static/src/js/client_action.js +++ b/addons/mail/static/src/js/client_action.js @@ -511,11 +511,19 @@ var ChatAction = Widget.extend(ControlPanelMixin, { }); }, - update_button_status: function (disabled) { + update_button_status: function (disabled, type) { if (this.channel.id === "channel_inbox") { this.$buttons .find('.o_mail_chat_button_mark_read') .toggleClass('disabled', disabled); + // Display Rainbowman when all inbox messages are read through + // 'MARK ALL READ' or marking last inbox message as read + if (disabled && type === 'mark_as_read') { + this.trigger_up('show_effect', { + message: _t('Congratulations, your inbox is empty!'), + type: 'rainbow_man', + }); + } } if (this.channel.id === "channel_starred") { this.$buttons @@ -607,7 +615,11 @@ var ChatAction = Widget.extend(ControlPanelMixin, { // Dump scroll position of channels in which the new message arrived this.channels_scrolltop = _.omit(this.channels_scrolltop, message.channel_ids); }, - on_update_message: function (message) { + on_update_message: function (message, type) { + // To identify 'update_button_status' method is called from from 'Mark as read / Mark all read' + // button, we are passing type to this method so that rainbowman will only appear on marking all + // messages as read (because the same method is also called from 'fetch_and_render_thread' when + // clicking @inbox, and we don't want rainbowman to appear everytime on empty inbox) var self = this; var current_channel_id = this.channel.id; if ((current_channel_id === "channel_starred" && !message.is_starred) || @@ -615,7 +627,7 @@ var ChatAction = Widget.extend(ControlPanelMixin, { chat_manager.get_messages({channel_id: this.channel.id, domain: this.domain}).then(function (messages) { var options = self.get_thread_rendering_options(messages); self.thread.remove_message_and_render(message.id, messages, options).then(function () { - self.update_button_status(messages.length === 0); + self.update_button_status(messages.length === 0, type); }); }); } else if (_.contains(message.channel_ids, current_channel_id)) { |
