[IMP] mail: change the counter of the need action menu when a message is read. Actually reload all the widget menu but we can upgrade and change the number only (less request)

bzr revid: chm@openerp.com-20121112095941-yitxdd3dpjox4das
This commit is contained in:
Christophe Matthieu 2012-11-12 10:59:41 +01:00
parent 75903aec86
commit 3fd509b634
1 changed files with 32 additions and 4 deletions

View File

@ -748,7 +748,13 @@ openerp.mail = function (session) {
this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).then(function () {
self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
self.to_read = !self.to_read;
// CHM note: put this function inside a check of display message after star/read...
// we can make a function for manualy set the counter (menu.needaction_counter) and don't reload all the widget menu
if( self.options._parents[0].__parentedParent.__parentedParent.get_menu_emails ) {
self.options._parents[0].__parentedParent.__parentedParent.get_menu_emails().widget.do_reload();
}
});
return false;
},
@ -1556,10 +1562,10 @@ openerp.mail = function (session) {
*/
init: function (parent, action) {
this._super(parent);
var options = action.params || {};
this.options = options;
this.options.domain = options.domain || [];
this.options.context = options.context || {};
this.action = action;
this.options = action.params;
this.options.domain = action.params.domain || [];
this.options.context = action.params.context || {};
this.search_results = {'domain': [], 'context': {}, 'groupby': {}}
this.ds_msg = new session.web.DataSetSearch(this, 'mail.message');
},
@ -1573,6 +1579,28 @@ openerp.mail = function (session) {
return $.when(searchview_ready, thread_displayed);
},
/**
* crete an object "related_menu"
* contain the menu widget and the the sub menu related of this wall
*/
get_menu_emails: function () {
var self = this;
if (!this.related_menu) {
var menu = this.__parentedParent.__parentedParent.menu;
var sub_menu = _.filter(menu.data.data.children, function (val) {return val.id == 100;})[0];
var menu_active = false;
_.find(sub_menu.children, function (sub_menu) {
return _.find(sub_menu.children, function (sub_sub_menu) {
menu_active = sub_sub_menu;
return sub_sub_menu.id == self.action.menu_id;
});
});
this.related_menu = {'widget': menu, 'menu': menu_active};
}
return this.related_menu;
},
/**
* Load the mail.message search view
* @param {Object} defaults ??