[IMP] Added a 'get followers' button on ThreadWidget. Basic displaying of results added.
bzr revid: tde@openerp.com-20120210124348-8s73xmswnfypqhx6
This commit is contained in:
parent
628989451d
commit
a123480d2c
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
// <div class="oe_mail_followers_vignette" title="Raoul Grobedon"><img src="people.png"/></div>
|
||||
$('<div class="oe_mail_followers_vignette">').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 */
|
||||
|
|
|
@ -18,13 +18,13 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="oe_mail_main_right">
|
||||
<button type="button" class="oe_mail_button_getfollowers">See followers</button>
|
||||
<button type="button" class="oe_mail_button_hidefollowers">Hide followers</button>
|
||||
<br />
|
||||
<div class="oe_mail_followers_vignette" title="Raoul Grobedon"><img src="people.png"/></div>
|
||||
<div class="oe_mail_followers_actions">
|
||||
<button type="button" class="oe_mail_button_followers">See followers</button>
|
||||
</div>
|
||||
<div class="oe_mail_followers">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<t t-name="ThreadMsgView">
|
||||
<div class="oe_mail_msg_image">Image</div>
|
||||
|
|
Loading…
Reference in New Issue