summaryrefslogtreecommitdiff
path: root/addons/mail/static/src/js
diff options
context:
space:
mode:
authorAaron Bohy <aab@odoo.com>2016-02-05 10:50:41 +0100
committerAaron Bohy <aab@odoo.com>2016-02-08 08:29:53 +0100
commit5ba53f3b11ef8cf0c7e6bbdd655ff35d5ffde0ad (patch)
tree56d594250ce35dd6b22298a74fc7f3b5267177a1 /addons/mail/static/src/js
parent79a8eeb17d16a12ea7ce8fa946dd610c32035bd0 (diff)
[FIX] mail: display user status in chat windows
Diffstat (limited to 'addons/mail/static/src/js')
-rw-r--r--addons/mail/static/src/js/chat_window.js16
-rw-r--r--addons/mail/static/src/js/window_manager.js13
2 files changed, 27 insertions, 2 deletions
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) {