[FIX] mail: display user status in chat windows
This commit is contained in:
@@ -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({
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -273,7 +273,6 @@
|
||||
font-size: 10px;
|
||||
position: relative;
|
||||
bottom: 1px;
|
||||
margin-right: 3px;
|
||||
&.o_user_online {
|
||||
color: @odoo-brand-optional;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<div class="o_chat_window">
|
||||
<div class="o_chat_header">
|
||||
<t t-call="mail.ChatWindowHeaderContent">
|
||||
<t t-set="status" t-value="widget.status"/>
|
||||
<t t-set="title" t-value="widget.title"/>
|
||||
<t t-set="unread_counter" t-value="widget.unread_msgs"/>
|
||||
</t>
|
||||
@@ -39,6 +40,7 @@
|
||||
<t t-foreach="sessions" t-as="session">
|
||||
<li class="o_chat_header" t-att-data-session-id="session.id">
|
||||
<t t-call="mail.ChatWindowHeaderContent">
|
||||
<t t-set="status" t-value="session.window.status"/>
|
||||
<t t-set="title" t-value="session.window.title"/>
|
||||
<t t-set="unread_counter" t-value="session.window.unread_msgs"/>
|
||||
</t>
|
||||
@@ -50,10 +52,9 @@
|
||||
|
||||
<t t-name="mail.ChatWindowHeaderContent">
|
||||
<span class="o_chat_title">
|
||||
<t t-if="status" t-call="mail.chat.UserStatus"/>
|
||||
<t t-esc="title"/>
|
||||
<span class="o_unread_counter">
|
||||
<t t-if="unread_counter">(<t t-esc="unread_counter"/>)</t>
|
||||
</span>
|
||||
<span t-if="unread_counter"> (<t t-esc="unread_counter"/>)</span>
|
||||
</span>
|
||||
<span>
|
||||
<a href="#" class="o_chat_window_close fa fa-close"/>
|
||||
|
||||
Reference in New Issue
Block a user