[IMP] mail follower: hide subtype list if they are only one subtype. Unfollow if the user unfollow all subtype.

bzr revid: chm@openerp.com-20121116160128-ffga2ffy3ldmps4b
This commit is contained in:
Christophe Matthieu
2012-11-16 17:01:28 +01:00
parent 8ccbab8254
commit a4f119b3a2
+10 -3
View File
@@ -184,7 +184,6 @@ openerp_mail_followers = function(session, mail) {
/** Fetch subtypes, only if current user is follower */
fetch_subtypes: function () {
var subtype_list_ul = this.$('.oe_subtype_list').empty();
if (! this.message_is_follower) return;
var context = new session.web.CompoundContext(this.build_context(), {});
this.ds_model.call('message_get_subscription_data', [[this.view.datarecord.id], context]).then(this.proxy('display_subtypes'));
@@ -195,11 +194,17 @@ openerp_mail_followers = function(session, mail) {
var self = this;
var subtype_list_ul = this.$('.oe_subtype_list');
var records = data[this.view.datarecord.id || this.view.dataset.ids[0]].message_subtype_data;
var count = 0;
subtype_list_ul.empty().hide();
_(records).each(function (record, record_name) {
count++;
record.name = record_name;
record.followed = record.followed || undefined;
$(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( self.$('.oe_subtype_list') );
$(session.web.qweb.render('mail.followers.subtype', {'record': record})).appendTo( subtype_list_ul );
});
if (count > 1) {
subtype_list_ul.show();
}
},
do_follow: function () {
@@ -227,7 +232,9 @@ openerp_mail_followers = function(session, mail) {
checklist.push(parseInt($(record).data('id')));
}
});
if (!checklist.length) {
return self.do_unfollow();
}
var context = new session.web.CompoundContext(this.build_context(), {});
return this.ds_model.call('message_subscribe_users', [[this.view.datarecord.id], [this.session.uid], this.message_is_follower ? checklist : undefined, context])
.then(this.proxy('read_value'));