From 2051bd9fda8d3453c0d6223c1f95bc9ae597bc01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?= Date: Thu, 16 Aug 2012 01:26:49 +0200 Subject: [PATCH] [IMP] mail_followers widget: removed white spaces, removed a debugger statement, made the title generic. bzr revid: tde@openerp.com-20120815232649-8e8ehqhchxh2kypk --- addons/mail/static/src/js/mail_followers.js | 39 ++++++++++--------- addons/mail/static/src/xml/mail_followers.xml | 4 +- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/addons/mail/static/src/js/mail_followers.js b/addons/mail/static/src/js/mail_followers.js index 30d83667165..1a8c68e803a 100644 --- a/addons/mail/static/src/js/mail_followers.js +++ b/addons/mail/static/src/js/mail_followers.js @@ -6,32 +6,34 @@ openerp_mail_followers = function(session, mail) { /** * ------------------------------------------------------------ - * mail_thread Widget + * mail_followers Widget * ------------------------------------------------------------ * - * This widget handles the display of the Chatter on documents. + * This widget handles the display of a list of records as a vetical + * list, with an image on the left. The widget itself is a floatting + * right-sided box. + * This widget is mainly used to display the followers of records + * in OpenChatter. */ - /* Add mail_thread widget to registry */ + /* Add the widget to registry */ session.web.form.widgets.add('mail_followers', 'openerp.mail_followers.Followers'); - /** mail_thread widget: thread of comments */ mail_followers.Followers = session.web.form.AbstractField.extend({ - // QWeb template to use when rendering the object template: 'mail.followers', - init: function() { + init: function() { this._super.apply(this, arguments); - debugger this.params = {}; this.params.image = this.node.attrs.image || 'image_small'; + this.params.title = this.node.attrs.title || 'Followers'; this.params.display_followers = true; this.params.display_control = this.node.attrs.display_control || false; this.params.display_actions = this.node.attrs.display_actions || false; this.ds_model = new session.web.DataSetSearch(this, this.view.model); this.ds_follow = new session.web.DataSetSearch(this, this.field.relation); }, - + start: function() { var self = this; // NB: all the widget should be modified to check the actual_mode property on view, not use @@ -49,15 +51,15 @@ openerp_mail_followers = function(session, mail) { .mouseleave(function () { $(this).html('Following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); }); this.reinit(); }, - + _check_visibility: function() { this.$element.toggle(this.view.get("actual_mode") !== "create"); }, - + destroy: function () { this._super.apply(this, arguments); }, - + reinit: function() { this.params.display_followers = true; this.params.display_control = this.node.attrs.display_control || false; @@ -66,7 +68,7 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_follow').hide(); this.$element.find('button.oe_mail_button_unfollow').hide(); }, - + set_value: function(value_) { this.reinit(); if (! this.view.datarecord.id || @@ -76,16 +78,16 @@ openerp_mail_followers = function(session, mail) { } return this.fetch_subscribers(value_); }, - + fetch_subscribers: function (value_) { return this.ds_follow.call('read', [value_ || this.get_value(), ['name', this.params.image]]).then(this.proxy('display_subscribers')); }, - + display_subscribers: function (records) { var self = this; this.is_subscriber = false; var user_list = this.$element.find('ul.oe_mail_followers_display').empty(); - this.$element.find('div.oe_mail_recthread_followers h4').html('Followers (' + records.length + ')'); + this.$element.find('div.oe_mail_recthread_followers h4').html(this.params.title + ' (' + records.length + ')'); _(records).each(function (record) { if (record.id == self.session.uid) { self.is_subscriber = true; } record.avatar_url = mail.ChatterUtils.get_image(self.session.prefix, self.session.session_id, 'res.users', 'image_small', record.id); @@ -98,16 +100,15 @@ openerp_mail_followers = function(session, mail) { this.$element.find('button.oe_mail_button_follow').show(); this.$element.find('button.oe_mail_button_unfollow').hide(); } }, - + do_follow: function () { return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - + do_unfollow: function () { - var self = this; return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value')); }, - + do_toggle_followers: function () { this.params.see_subscribers = ! this.params.see_subscribers; if (this.params.see_subscribers) { this.$element.find('button.oe_mail_button_followers').html('Hide followers'); } diff --git a/addons/mail/static/src/xml/mail_followers.xml b/addons/mail/static/src/xml/mail_followers.xml index ad7bc71e4e4..53c899b9569 100644 --- a/addons/mail/static/src/xml/mail_followers.xml +++ b/addons/mail/static/src/xml/mail_followers.xml @@ -12,7 +12,9 @@
-

Followers

+ +

+