[IMP] mail_followers widget: removed white spaces, removed a debugger statement, made the title generic.
bzr revid: tde@openerp.com-20120815232649-8e8ehqhchxh2kypk
This commit is contained in:
parent
df6a7026d8
commit
2051bd9fda
|
@ -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'); }
|
||||
|
|
|
@ -12,7 +12,9 @@
|
|||
<button type="button" class="oe_mail_button_followers">Show followers</button>
|
||||
</div>
|
||||
<div class="oe_mail_recthread_followers">
|
||||
<h4>Followers</h4>
|
||||
<t t-if="widget.params.title">
|
||||
<h4><t t-raw="widget.params.title"/></h4>
|
||||
</t>
|
||||
<ul class="oe_mail_followers_display"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue