[IMP]add name and checkbox on click of follow and make it work as add in subtype_ids in followers
bzr revid: sgo@tinyerp.com-20120822062722-ru93dme523lnuko7
This commit is contained in:
@@ -1192,10 +1192,10 @@ class mail_thread(osv.Model):
|
||||
""" Set as read. """
|
||||
return self.write(cr, uid, ids, {'message_state': True}, context=context)
|
||||
|
||||
def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids):
|
||||
def message_subscribe_udpate_subtypes(self, cr, uid, ids, user_id, subtype_ids,context=None):
|
||||
subscription_obj = self.pool.get('mail.followers')
|
||||
subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids)])
|
||||
return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [6, 0 , subtype_ids]}, context = context) #overright or add new one
|
||||
subscription_ids = subscription_obj.search(cr, uid, [('res_model', '=', self._name), ('res_id', 'in', ids),('user_id','=',user_id)])
|
||||
return subscription_obj.write(cr, uid, subscription_ids, {'subtype_ids': [(6, 0 , subtype_ids)]}, context = context) #overright or add new one
|
||||
|
||||
def message_subscription_remove_subtype(self, cr, uid, ids, user_id, subtype_id):
|
||||
subscription_obj = self.pool.get('mail.followers')
|
||||
|
||||
@@ -31,6 +31,7 @@ openerp_mail_followers = function(session, mail) {
|
||||
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.sub_model = new session.web.DataSetSearch(this,'mail.message.subtype')
|
||||
this.ds_follow = new session.web.DataSetSearch(this, this.field.relation);
|
||||
},
|
||||
|
||||
@@ -42,8 +43,21 @@ openerp_mail_followers = function(session, mail) {
|
||||
this._check_visibility();
|
||||
this.$element.find('button.oe_mail_button_followers').click(function () { self.do_toggle_followers(); });
|
||||
if (! this.params.display_control) {
|
||||
this.$element.find('button.oe_mail_button_followers').hide(); }
|
||||
this.$element.find('button.oe_mail_button_follow').click(function () { self.do_follow(); })
|
||||
this.$element.find('button.oe_mail_button_followers').hide();
|
||||
}
|
||||
this.$element.find('ul.oe_mail_recthread_subtype').click(function () {
|
||||
var sublist = new Array();
|
||||
_($(this).find('.oe_msg_subtype_check')).each(function (record){
|
||||
if($(record).is(':checked')) {
|
||||
sublist.push(parseInt($(record).attr('id')))
|
||||
}
|
||||
});
|
||||
self.ds_model.call('message_subscribe_udpate_subtypes',[[self.view.datarecord.id],self.session.uid,sublist])
|
||||
})
|
||||
this.$element.find('button.oe_mail_button_follow').click(function () {
|
||||
self.add_subtype();
|
||||
self.do_follow();
|
||||
})
|
||||
.mouseover(function () { $(this).html('Follow').removeClass('oe_mail_button_mouseout').addClass('oe_mail_button_mouseover'); })
|
||||
.mouseleave(function () { $(this).html('Not following').removeClass('oe_mail_button_mouseover').addClass('oe_mail_button_mouseout'); });
|
||||
this.$element.find('button.oe_mail_button_unfollow').click(function () { self.do_unfollow(); })
|
||||
@@ -103,10 +117,25 @@ openerp_mail_followers = function(session, mail) {
|
||||
this.$element.find('button.oe_mail_button_follow').show();
|
||||
this.$element.find('button.oe_mail_button_unfollow').hide(); }
|
||||
},
|
||||
|
||||
|
||||
subtype_value: function(value_) {
|
||||
return this.sub_model.call('read', [value_ || this.get_value(),['name', 'default']]).then(this.proxy('read_subtype'));
|
||||
},
|
||||
|
||||
read_subtype: function(records) {
|
||||
this.reinit()
|
||||
var subtype_list = this.$element.find('ul.oe_mail_recthread_subtype').empty();
|
||||
_(records).each(function (record) {
|
||||
$(session.web.qweb.render('mail.subtype.ids', {'record': record})).appendTo(subtype_list);
|
||||
});
|
||||
},
|
||||
|
||||
do_follow: function () {
|
||||
return this.ds_model.call('message_subscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
|
||||
},
|
||||
add_subtype: function () {
|
||||
return this.sub_model.call('search', [[['model_ids.model','=',this.view.model]]]).pipe(this.proxy('subtype_value'));
|
||||
},
|
||||
|
||||
do_unfollow: function () {
|
||||
return this.ds_model.call('message_unsubscribe', [[this.view.datarecord.id]]).pipe(this.proxy('set_value'));
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<h4><t t-raw="widget.params.title"/></h4>
|
||||
</t>
|
||||
<ul class="oe_mail_followers_display"></ul>
|
||||
<ul class="oe_mail_recthread_subtype"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -27,5 +28,9 @@
|
||||
<img class="oe_mail_thumbnail oe_mail_frame" t-attf-src="{record.avatar_url}"/>
|
||||
<a t-attf-href="#model=res.users&id=#{record.id}"><t t-raw="record.name"/></a>
|
||||
</li>
|
||||
<li t-name="mail.subtype.ids">
|
||||
<a t-attf-href="#model=mail.message.subtype&id=#{record.id}"><t t-raw="record.name"/></a>
|
||||
<input type="checkbox" t-att-id="record.id" t-att-name="record.name" class="oe_msg_subtype_check"/>
|
||||
</li>
|
||||
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user