From a4f119b3a234dfbd589bfad62cae72aeaf21922a Mon Sep 17 00:00:00 2001 From: Christophe Matthieu Date: Fri, 16 Nov 2012 17:01:28 +0100 Subject: [PATCH] [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 --- addons/mail/static/src/js/mail_followers.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 7bb019cde4f..4b82a3a920a 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -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'));