now displays the number of pending messages when a discussion is minimized

bzr revid: nicolas.vanhoren@openerp.com-20130207143717-wg52x7lkbwm2g0rl
This commit is contained in:
niv-openerp
2013-02-07 15:37:17 +01:00
parent ebad1bd7a9
commit f9abb27128
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -353,6 +353,7 @@ openerp.web_im = function(instance) {
this.user.add_watcher();
this.set("right_position", 0);
this.shown = true;
this.set("pending", 0);
},
start: function() {
var change_status = function() {
@@ -366,6 +367,13 @@ openerp.web_im = function(instance) {
this.on("change:right_position", this, this.calc_pos);
this.full_height = this.$el.height();
this.calc_pos();
this.on("change:pending", this, _.bind(function() {
if (this.get("pending") === 0) {
this.$(".oe_im_chatview_nbr_messages").text("");
} else {
this.$(".oe_im_chatview_nbr_messages").text("(" + this.get("pending") + ")");
}
}, this));
},
show_hide: function() {
if (this.shown) {
@@ -378,11 +386,19 @@ openerp.web_im = function(instance) {
});
}
this.shown = ! this.shown;
if (this.shown) {
this.set("pending", 0);
}
},
calc_pos: function() {
this.$el.css("right", this.get("right_position"));
},
received_message: function(message) {
if (this.shown) {
this.set("pending", 0);
} else {
this.set("pending", this.get("pending") + 1);
}
this._add_bubble(this.user, message.message, message.date);
},
send_message: function(e) {
+1
View File
@@ -32,6 +32,7 @@
<div class="oe_im_chatview_header">
<img t-att-src="_s +'/web_im/static/src/img/green.png'" class="oe_im_chatview_online"/>
<t t-esc="widget.user.get('name') || 'Anonymous'"/>
<scan class="oe_im_chatview_nbr_messages" />
<button class="oe_im_chatview_close">×</button>
</div>
<div class="oe_im_chatview_disconnected">