diff --git a/addons/mail/static/src/js/chat_window.js b/addons/mail/static/src/js/chat_window.js index 1a9c0fa93ea..e7d3f061b68 100644 --- a/addons/mail/static/src/js/chat_window.js +++ b/addons/mail/static/src/js/chat_window.js @@ -7,6 +7,7 @@ var config = require('web.config'); var core = require('web.core'); var Widget = require('web.Widget'); +var QWeb = core.qweb; var _t = core._t; var HEIGHT_OPEN = '400px'; @@ -33,11 +34,13 @@ return Widget.extend({ placeholder: _t("Say something"), input_less: false, }); + this.status = this.options.status; this.unread_msgs = unread_msgs || 0; this.is_hidden = false; }, start: function () { this.$input = this.$('.o_chat_input input'); + this.$header = this.$('.o_chat_header'); this.thread = new ChatThread(this, { channel_id: this.channel_id, @@ -62,7 +65,18 @@ return Widget.extend({ }, update_unread: function (counter) { this.unread_msgs = counter; - this.$('.o_unread_counter').text(counter > 0 ? '(' + counter + ')' : ''); + this.render_header(); + }, + update_status: function (status) { + this.status = status; + this.render_header(); + }, + render_header: function () { + this.$header.html(QWeb.render('mail.ChatWindowHeaderContent', { + status: this.status, + title: this.title, + unread_counter: this.unread_msgs, + })); }, fold: function () { this.$el.animate({ diff --git a/addons/mail/static/src/js/window_manager.js b/addons/mail/static/src/js/window_manager.js index a98a9de5cc0..dfd882e02d3 100644 --- a/addons/mail/static/src/js/window_manager.js +++ b/addons/mail/static/src/js/window_manager.js @@ -39,7 +39,10 @@ function open_chat (session) { var chat_session = _.findWhere(chat_sessions, {id: session.id}); if (!chat_session) { var prefix = !session.is_chat ? "#" : ""; - var options = { input_less: session.mass_mailing }; + var options = { + input_less: session.mass_mailing, + status: session.status, + }; chat_session = { id: session.id, uuid: session.uuid, @@ -332,6 +335,14 @@ core.bus.on('web_client_ready', null, function () { } }); + chat_manager.bus.on('update_dm_presence', null, function (channel) { + _.each(chat_sessions, function (session) { + if (channel.id === session.id) { + session.window.update_status(channel.status); + } + }); + }); + chat_manager.is_ready.then(function() { _.each(chat_manager.get_channels(), function (channel) { if (channel.is_detached) { diff --git a/addons/mail/static/src/less/client_action.less b/addons/mail/static/src/less/client_action.less index ecf4785f03e..430cc46d75a 100644 --- a/addons/mail/static/src/less/client_action.less +++ b/addons/mail/static/src/less/client_action.less @@ -273,7 +273,6 @@ font-size: 10px; position: relative; bottom: 1px; - margin-right: 3px; &.o_user_online { color: @odoo-brand-optional; } diff --git a/addons/mail/static/src/xml/chat_window.xml b/addons/mail/static/src/xml/chat_window.xml index 7bb854a274c..fda9222681a 100644 --- a/addons/mail/static/src/xml/chat_window.xml +++ b/addons/mail/static/src/xml/chat_window.xml @@ -5,6 +5,7 @@