diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py index f582bc50062..68bf4429d18 100644 --- a/addons/mail/mail_thread.py +++ b/addons/mail/mail_thread.py @@ -543,6 +543,13 @@ class mail_thread(osv.osv): subs = subscription_obj.browse(cr, uid, sub_ids, context=context) return subs + def message_get_subscribers_web(self, cr, uid, ids, context=None): + subscription_obj = self.pool.get('mail.subscription') + for id in ids: + sub_ids = subscription_obj.search(cr, uid, ['&', ('res_model', '=', self._name), ('res_id', '=', id)], context=context) + subs = subscription_obj.read(cr, uid, sub_ids, context=context) + return subs + def message_is_subscriber(self, cr, uid, ids, context=None): for subscription in self.message_get_subscribers(cr, uid, ids, context=context): if subscription.user_id == uid: return True diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index baf7a98d71f..0d153ce0c06 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -25,7 +25,7 @@ margin-bottom: 10px; } -.oe_mail_button_follow, .oe_mail_button_unfollow, .oe_mail_button_getfollowers, .oe_mail_button_hidefollowers { +.oe_mail_button_follow, .oe_mail_button_unfollow, .oe_mail_button_followers { width: 100px; } diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 93a333335a8..fa7037bcacb 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -32,6 +32,7 @@ openerp.mail = function(session) { self.$element.find('button.oe_mail_button_unfollow').bind('click', function () { self.do_unfollow(); }); self.$element.find('button.oe_mail_button_unfollow').hide(); self.$element.find('button.oe_mail_button_comment').bind('click', function () { self.do_comment(); }); + self.$element.find('button.oe_mail_button_followers').bind('click', function () { self.do_toggle_followers(); }); /* find wich (un)follow buttons to show */ var call_res = this.ds.call('message_is_subscriber', [[this.session.uid]]).then(function (records) { if (records == true) { self.follow_state = 1; self.$element.find('button.oe_mail_button_unfollow').show(); } @@ -47,15 +48,18 @@ openerp.mail = function(session) { set_value: function() { this._super.apply(this, arguments); if (! this.view.datarecord.id) { return; } - return this.fetch_messages(); + return this.fetch_data(); }, - fetch_messages: function () { - return this.ds.call('message_load', [[this.view.datarecord.id]]).then( - this.proxy('display_records')); + fetch_data: function () { + var load_res = this.ds.call('message_load', [[this.view.datarecord.id]]).then( + this.proxy('display_comments')); + var follow_res = this.ds.call('message_get_subscribers_web', [[this.view.datarecord.id]]).then( + this.proxy('display_followers')); + return follow_res; }, - display_records: function (records) { + display_comments: function (records) { this.$element.find('div.oe_mail_msg').empty(); var self = this; _(records).each(function (record) { @@ -68,6 +72,16 @@ openerp.mail = function(session) { // this.timeout = setTimeout(this.proxy('fetch_messages'), 5000); }, + display_followers: function (records) { + this.$element.find('div.oe_mail_followers').empty(); + var self = this; + _(records).each(function (record) { + console.log(record); +//
+ $('
').text(record.user_id[1]).appendTo(self.$element.find('div.oe_mail_followers')); + }); + }, + do_follow: function () { this.$element.find('button.oe_mail_button_unfollow').show(); this.$element.find('button.oe_mail_button_follow').hide(); @@ -85,6 +99,10 @@ openerp.mail = function(session) { return this.ds.call('message_append_note', [[this.view.datarecord.id], 'Reply comment', body_text, type='comment']).then( this.proxy('fetch_messages')); }, + + do_toggle_followers: function () { + this.$element.find('div.oe_mail_followers').toggle(); + }, }); /* Add WallView widget to registry */ diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 72fbf8d0f88..ff8386f32b9 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -18,13 +18,13 @@
- - -
-
+
+ +
+
+
-
Image