Atul Patel(OpenERP) has proposed merging
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp into
lp:openobject-addons.
Requested reviews:
Thibault Delavallée (OpenERP) (tde-openerp)
Atul Patel(OpenERP) (atp-openerp)
For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp/+merge/114378
Hello,
we have made all changes .
kindly check it..
Thanks.
--
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp/+merge/114378
Your team OpenERP R&D Team is subscribed to branch
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.
=== modified file 'mail/static/src/css/mail.css'
--- mail/static/src/css/mail.css 2012-07-02 14:31:53 +0000
+++ mail/static/src/css/mail.css 2012-07-11 10:41:28 +0000
@@ -149,6 +149,29 @@
padding: 5px;
}
+.openerp .oe_mail_wall_action_post_all{
+ margin-top:10px;
+ margin-left: 50px;
+ height: 25px;
+}
+.openerp .oe_mail_thread_action_post_all{
+ padding:5px;
+ padding-top: 10px;
+ height: 20px;
+}
+.openerp .oe_attach{
+ cursor:pointer;
+ padding: 5px;
+ margin-top: 2px;
+}
+.openerp .oe_attach_icon{
+ height: 15px;
+ width: 20px;
+}
+.openerp div.oe_mail_thread_subthread .oe_attach_icon{
+ width: 18px;
+ height: 18px;
+}
/* ------------------------------ */
/* ThreadDisplay */
/* ------------------------------ */
=== added file 'mail/static/src/img/attach.png'
Binary files mail/static/src/img/attach.png 1970-01-01 00:00:00 +0000 and mail/static/src/img/attach.png 2012-07-11 10:41:28 +0000 differ
=== modified file 'mail/static/src/js/mail.js'
--- mail/static/src/js/mail.js 2012-07-10 14:50:23 +0000
+++ mail/static/src/js/mail.js 2012-07-11 10:41:28 +0000
@@ -140,12 +140,15 @@
this.$element.find('button.oe_mail_button_more').click(function () {
self.do_more();
});
- // event: writing in textarea
- this.$element.find('textarea.oe_mail_action_textarea').keyup(function (event) {
- var charCode = (event.which) ? event.which : window.event.keyCode;
- if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; }
- else if (charCode == 13) { return self.do_comment(); }
- });
+ // event: writing in textarea : Disable the on enter event.
+ // this.$element.find('textarea.oe_mail_action_textarea').keyup(function (event) {
+ // var charCode = (event.which) ? event.which : window.event.keyCode;
+ // if (event.shiftKey && charCode == 13) { this.value = this.value+"\n"; }
+ // else if (charCode == 13) { return self.do_comment(); }
+ // });
+
+ // Add button click event to post the comment.
+ this.$element.find('button.oe_mail_wall_button_comment').click(function () { return self.do_comment(); });
// event: click on 'reply' in msg
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
var act_dom = $(this).parents('div.oe_mail_thread_display').find('div.oe_mail_thread_action:first');
=== modified file 'mail/static/src/xml/mail.xml'
--- mail/static/src/xml/mail.xml 2012-07-05 12:18:18 +0000
+++ mail/static/src/xml/mail.xml 2012-07-11 10:41:28 +0000
@@ -23,7 +23,13 @@
<div class="oe_mail_wall_action">
<img class="oe_mail_msg_image oe_left" alt="User img"/>
<textarea class="oe_mail oe_mail_wall_action_textarea" placeholder="What are you working on?"/>
- <button class="oe_right oe_mail_wall_button_comment" type="button">Post comment</button>
+ <div class="oe_mail_wall_action_post_all">
+ <button class="oe_left oe_mail_wall_button_comment" type="button">Post comment</button>
+ <a class="oe_attach oe_right" title="Add Attachments">
+ <img t-att-src='_s + "/mail/static/src/img/attach.png"' class="oe_attach_icon"/>
+ <span>Attachment</span>
+ </a>
+ </div>
</div>
<div class="oe_clear"></div>
<ul class="oe_mail_wall_threads">
@@ -56,7 +62,16 @@
<div t-name="mail.Thread" class="oe_mail oe_mail_thread">
<div class="oe_mail_thread_action">
<img class="oe_mail_msg_image oe_left" alt="User img"/>
- <textarea class="oe_mail oe_mail_action_textarea" placeholder="Add your comment here..." onfocus="this.value = '';"/>
+ <div class="oe_mail_msg_content">
+ <textarea class="oe_mail oe_mail_action_textarea" placeholder="Add your comment here..." onfocus="this.value = '';"/>
+ <div class="oe_mail_thread_action_post_all">
+ <button class="oe_left oe_mail_wall_button_comment" type="button">Post comment</button>
+ <a class="oe_attach oe_right" >
+ <img t-att-src='_s + "/mail/static/src/img/attach.png"' class="oe_attach_icon"/>
+ <span title="Add Attachments">Attachment</span>
+ </a>
+ </div>
+ </div>
</div>
<div class="oe_mail_thread_display"></div>
<div class="oe_mail_thread_more">
@@ -92,7 +107,7 @@
<t t-raw="record.body"/>
</div>
<ul class="oe_mail_msg_footer">
- <li><span t-att-title="record.date"><t t-raw="record.timerelative"/></span></li>
+ <li class="oe_comment_time_info"><span t-att-title="record.date"><t t-raw="record.timerelative"/></span></li>
<li t-if="display['show_reply']"><a href="#" class="oe_mail_msg_reply">Reply</a></li>
<!-- uncomment when merging vote
<li><a href="#">Like</a></li>
=== added directory 'mail_extra'
=== added file 'mail_extra/__init__.py'
--- mail_extra/__init__.py 1970-01-01 00:00:00 +0000
+++ mail_extra/__init__.py 2012-07-11 10:41:28 +0000
@@ -0,0 +1,25 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+import mail_vote
+import mail_checklist
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
+
=== added file 'mail_extra/__openerp__.py'
--- mail_extra/__openerp__.py 1970-01-01 00:00:00 +0000
+++ mail_extra/__openerp__.py 2012-07-11 10:41:28 +0000
@@ -0,0 +1,52 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+##############################################################################
+
+{
+ 'name': 'Votes & Checklist Management',
+ 'version': '1.0',
+ 'category': 'Hidden/Dependency',
+ 'complexity': "easy",
+ 'description': """
+ """,
+ 'author': 'OpenERP SA',
+ 'website': 'http://www.openerp.com',
+ 'depends': ['base', 'mail'],
+ 'data': [
+ ],
+ 'installable': True,
+ 'auto_install': False,
+ 'certificate': '',
+ 'images': [
+ ],
+ 'data': [
+ 'security/ir.model.access.csv',
+ ],
+ 'css': [
+ "static/src/css/mail_extra.css",
+ ],
+ 'js': [
+ "static/src/js/mail_extra.js",
+ ],
+ 'qweb': [
+ "static/src/xml/mail_extra.xml",
+ ],
+}
+# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
=== added file 'mail_extra/mail_checklist.py'
--- mail_extra/mail_checklist.py 1970-01-01 00:00:00 +0000
+++ mail_extra/mail_checklist.py 2012-07-11 10:41:28 +0000
@@ -0,0 +1,122 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv, fields
+
+class mail_checklist_item(osv.Model):
+ _name = 'mail.checklist.item'
+ _description = 'Mail Checklist Item'
+ '''
+ Mail Checklist Item is a new feature checklist in messages.
+ It add number of checklist Items with comments.
+ It allows to strike and unstrike Item with progress Bar in particular messages.
+ msg_id : Message id on which the Items will be added.
+ name : Item name
+ done : True If Item checked otherwise False.
+ '''
+ _columns = {
+ 'msg_id': fields.many2one('mail.message', 'Message'),
+ 'name': fields.char('Item Name', size=128, required=True, help='Checklist Item Name.'),
+ 'done': fields.boolean('Done', help="When Item is done then check it."),
+ 'user_id': fields.many2one('res.users', 'Related user', readonly=1),
+ }
+
+ def action_done(self, cr, uid, check_item_ids, check_value, context=None):
+ """
+ Update checklist Item value(True or False).
+ Return Checklist Item Details.(name, id, done)
+ """
+ self.write(cr, uid, check_item_ids , {'done': check_value}, context=context)
+ msg_id = self.browse(cr, uid, check_item_ids[0], context=context).msg_id.id
+ return self.pool.get("mail.message").read_checklist_items(cr, uid, [msg_id], context=context)
+
+mail_checklist_item()
+
+class mail_message(osv.Model):
+
+ def read_checklist_items(self, cr, uid, ids, context=None):
+ """
+ Find Checklist Item of particular Message Id.
+ Return Checklist Item Details.(name, id, done)
+ """
+ checklist = self.pool.get("mail.checklist.item")
+ checklist_ids = checklist.search(cr, uid, [('msg_id','in' ,ids)])
+ return checklist.read(cr, uid, checklist_ids, ['id','name','done'])
+
+ _inherit = 'mail.message'
+ _columns= {
+ 'checklist_item_ids': fields.one2many('mail.checklist.item', 'msg_id', 'CheckItems'),
+ }
+mail_message()
+
+class mail_thread(osv.Model):
+ _inherit = 'mail.thread'
+
+ def message_append_note_checklist(self, cr, uid, ids, subject=None, body=None, parent_id=False, type='notification', subtype='html', items=[], context=None):
+ '''For Creating Checklist Items, will work for any model at the Creation of thread.'''
+
+ new_msg_ids = self.message_append_note(cr, uid, ids, subject=subject, body=body, parent_id=parent_id, type=type, subtype=subtype, context=context)
+ check_items = []
+ mail_message = self.pool.get('mail.message')
+ mail_item = self.pool.get('mail.checklist.item')
+ for item in items:
+ item_id = mail_item.create(cr, uid, {'msg_id':new_msg_ids[0], 'user_id':uid, 'name' : item}, context=context)
+ check_items.append(item_id)
+ return mail_message.write(cr, uid, new_msg_ids[0], {'checklist_item_ids': [(6,0,check_items)]}, context)
+
+ def _get_message_ids(self, cr, uid, ids, name, args, context=None):
+ """
+ Overriding _get_message_ids method of mail thread.
+ """
+ res = super(mail_thread, self)._get_message_ids(cr, uid, ids, name, args, context=context)
+ msg_obj = self.pool.get('mail.message')
+ for key in res.keys():
+ vote_list = []
+ total_items = 0
+ total_done_items = 0
+ for msg_id in res[key]['message_ids']:
+ msg = msg_obj.browse(cr, uid, msg_id, context=context)
+ # for count the number of done checklist items.
+ if msg.checklist_item_ids:
+ for item in filter(lambda x:x.done == True , msg.checklist_item_ids):
+ total_done_items += 1
+ total_items += len(msg.checklist_item_ids)
+ # Count the number of votes.
+ if msg.vote_ids:
+ vote_list.append(msg.vote_ids)
+ img_vote = "<img height='12px' width='16px' src='/mail_extra/static/src/img/vote.gif'/>"
+ img_checklist = "<img height='12px' width='16px' src='/mail_extra/static/src/img/checklist.png'/>"
+ res[key]['message_summary'] += " <span> %s %d</span> . <span> %s %d/%d</span>"% (img_vote,len(vote_list),img_checklist,total_done_items,total_items)
+ return res
+
+ _columns = {
+ 'message_summary': fields.function(_get_message_ids, method=True,
+ type='text', string='Summary', multi="_get_message_ids",
+ help="Holds the Chatter summary (number of messages, items, votes...). "\
+ "This summary is directly in html format in order to "\
+ "be inserted in kanban views."),
+ }
+
+mail_thread()
+
+class res_users(osv.Model):
+ _name = 'res.users'
+ _inherit = ['res.users', 'mail.thread']
=== added file 'mail_extra/mail_vote.py'
--- mail_extra/mail_vote.py 1970-01-01 00:00:00 +0000
+++ mail_extra/mail_vote.py 2012-07-11 10:41:28 +0000
@@ -0,0 +1,75 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# OpenERP, Open Source Management Solution
+# Copyright (C) 2012-Today OpenERP SA (<http://www.openerp.com>).
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>
+#
+##############################################################################
+
+from osv import osv, fields
+from tools.translate import _
+
+class mail_vote(osv.Model):
+ '''
+ Mail vote feature allow users to like and unlike particular message or Document's message comment.
+ It counts the number of votes per document.
+ '''
+ _name = 'mail.vote'
+ _description = 'Mail Vote'
+ _columns = {
+ 'msg_id': fields.many2one('mail.message', 'Message', required=True),
+ 'user_id': fields.many2one('res.users', 'User', required=True),
+ }
+
+class mail_message(osv.Model):
+ _inherit = 'mail.message'
+ _columns= {
+ 'vote_ids': fields.one2many('mail.vote', 'msg_id', 'Votes'),
+ }
+ def get_vote_summary(self, cr, uid, ids, context=None):
+ '''
+ Return message ,count vote of message id given by .particular user with True or False.
+ '''
+ for message in self.browse(cr, uid, ids, context):
+ is_vote_liked = False
+ vote_count = len(message.vote_ids)
+ for vote in message.vote_ids:
+ if vote.user_id.id == uid:
+ is_vote_liked = True
+ break
+ res = {
+ 'msg_id': message.id,
+ 'vote_count': vote_count,
+ 'is_vote_liked': is_vote_liked
+ }
+ return res
+
+ def vote_toggle(self, cr, uid, ids, context=None):
+ '''
+ Toggles when Comment is liked or unlike.
+ Return the number of votes of particular message.
+ '''
+ vote_pool = self.pool.get('mail.vote')
+ vote_count = 0
+ for message in self.browse(cr, uid, ids, context):
+ voters_id = vote_pool.search(cr, uid, [('msg_id', '=', message.id), ('user_id', '=', uid)], context=context)
+ if not voters_id:
+ new_vote_id = vote_pool.create(cr, uid, {'msg_id': message.id, 'user_id': uid}, context=context)
+ else:
+ vote_pool.unlink(cr, uid, voters_id, context=context)
+ if message.vote_ids:
+ vote_count = len(message.vote_ids)
+ return vote_count
=== added directory 'mail_extra/security'
=== added file 'mail_extra/security/ir.model.access.csv'
--- mail_extra/security/ir.model.access.csv 1970-01-01 00:00:00 +0000
+++ mail_extra/security/ir.model.access.csv 2012-07-11 10:41:28 +0000
@@ -0,0 +1,3 @@
+id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
+access_mail_vote,mail.vote,model_mail_vote,base.group_user,1,1,1,1
+access_mail_checklist_item,mail.checklist.item,model_mail_checklist_item,base.group_user,1,1,1,0
=== added directory 'mail_extra/static'
=== added directory 'mail_extra/static/src'
=== added directory 'mail_extra/static/src/css'
=== added file 'mail_extra/static/src/css/mail_extra.css'
--- mail_extra/static/src/css/mail_extra.css 1970-01-01 00:00:00 +0000
+++ mail_extra/static/src/css/mail_extra.css 2012-07-11 10:41:28 +0000
@@ -0,0 +1,68 @@
+.openerp .oe_wall_checklist_item{
+ margin-top:10px;
+ padding-left: 50px;
+}
+.openerp .oe_checklist_item{
+ padding : 8px;
+ cursor:pointer;
+ display: none;
+ height:2px;
+ width : 95px
+}
+.openerp .oe_checklist_wall{
+ cursor:pointer;
+ padding: 5px;
+ margin-left:100px;
+ margin-top: 2px;
+}
+.openerp .oe_checklist_thread{
+ cursor:pointer;
+ padding: 5px;
+ padding-left:20px;
+ margin-top: 2px;
+}
+
+.openerp .oe_checklist_icon{
+ height: 15px;
+ width: 20px;
+}
+.openerp div.oe_mail_thread_subthread .oe_checklist_icon {
+ width: 18px;
+ height: 16px;
+}
+.openerp div.oe_mail_thread_subthread a.oe_checklist_item
+{
+ padding : 12px;
+ cursor:pointer;
+}
+
+.openerp .oe_strike_checkbox {
+ color:#666362;
+ text-decoration:line-through;
+}
+
+.openerp .oe_progressbar {
+ background-color:white;
+ width:220px;
+ height:4px;
+}
+
+button.oe_mail_msg_vote_like{
+ height:21px;
+ width: 30px;
+ padding: 1px;
+ background: #8A89BA;
+ margin-top: -4px;
+}
+
+button.oe_mail_msg_vote_like:hover{
+ background: #8A89BA;
+}
+
+button.oe_mail_msg_vote_like span {
+ color: white;
+}
+
+span.oe_mail_vote_string{
+ color: #807FB4;
+}
=== added directory 'mail_extra/static/src/img'
=== added file 'mail_extra/static/src/img/checklist.png'
Binary files mail_extra/static/src/img/checklist.png 1970-01-01 00:00:00 +0000 and mail_extra/static/src/img/checklist.png 2012-07-11 10:41:28 +0000 differ
=== added file 'mail_extra/static/src/img/vote.gif'
Binary files mail_extra/static/src/img/vote.gif 1970-01-01 00:00:00 +0000 and mail_extra/static/src/img/vote.gif 2012-07-11 10:41:28 +0000 differ
=== added directory 'mail_extra/static/src/js'
=== added file 'mail_extra/static/src/js/mail_extra.js'
--- mail_extra/static/src/js/mail_extra.js 1970-01-01 00:00:00 +0000
+++ mail_extra/static/src/js/mail_extra.js 2012-07-11 10:41:28 +0000
@@ -0,0 +1,237 @@
+openerp.mail_extra = function(session){
+ var QWeb = session.web.qweb;
+ var _t = session.web._t;
+
+ session.mail_extra.CheckListItem = session.web.Widget.extend({
+ render_new_checklist_item: function(element){
+ var parent_element = $(element).find('.oe_checklist_item');
+ var new_item = $(QWeb.render("AddChecklist", {}));
+ $(parent_element).before(new_item);
+ this.focus_on_checklist(element);
+ $(element).find('input[type=text]:visible:last').focus();
+
+ },
+ render_default_checklist_item: function(element){
+ for(i=0; i<3; i++){
+ this.render_new_checklist_item(element);
+ }
+ },
+
+ focus_on_checklist: function(mail_element){
+ // set focus on first textbox
+ $(mail_element).find('input[type=text]:visible:first').focus();
+ // On enter focus on next textbox.
+ $(mail_element).find('input[type=text]').keyup(function (event) {
+ var charCode = (event.which) ? event.which : window.event.keyCode;
+ if (charCode == 13)
+ {
+ var nextIndex = $('input[type=text]').index(this) + 1;
+ $(":input[type=text]:eq(" + nextIndex + ")").focus();
+ }
+ });
+ },
+
+ add_checklist_items_list: function(checklist_items){
+ check_items = []
+ text_items = $(checklist_items).find('input[type=text]');
+ _(text_items).each(function(item){
+ item_value = $(item).val();
+ if (item_value != ""){
+ check_items.push(item_value);
+ }
+ $(item).val('');
+ });
+ return check_items
+ },
+ remove_check_list: function(checklist_items){
+ items_to_remove = $(checklist_items).find('input');
+ _(items_to_remove).each(function(item){
+ $(item).remove();
+ })
+ },
+
+ });
+ session.mail.WallView.include({
+ add_event_handlers: function () {
+ res = this._super();
+ var self = this;
+ var main_wall = this.$element.find('.oe_mail_wall_action');
+ //Call CheckListItem widgets
+ var chklst_item= new session.mail_extra.CheckListItem();
+ chklst_item.render_default_checklist_item(main_wall)
+ // Set focus on checklist item.
+ $(main_wall).find(".oe_checklist_item").click(function(){
+ // to do add more items.
+ chklst_item.render_new_checklist_item(main_wall);
+ });
+ $(main_wall).find(".oe_checklist_wall").click(function(){
+ //toggle the checklist items
+ $(main_wall).find(".oe_wall_checklist_item").toggle();
+ });
+ $(main_wall).find("input[type=text]:last").focus(function(){
+ $('.oe_checklist_item').css({'display':'block'})
+ });
+ },
+ do_comment: function () {
+ self = this;
+ check_items = false;
+ var comment_node = this.$element.find('textarea.oe_mail_wall_action_textarea');
+ var body_text = comment_node.val();
+ var chklst_item= new session.mail_extra.CheckListItem();
+ comment_node.val('');
+ var wall_checklist_items = this.$element.find('.oe_mail_wall_action');
+ check_items = chklst_item.add_checklist_items_list(wall_checklist_items);
+ var call_done = this.ds_users.call('message_append_note_checklist', [[this.session.uid], 'Tweet', body_text, false, 'comment', 'html', check_items]).then(this.proxy('init_and_fetch_comments'));
+ // after posting comment this will remove the items added by the Add more item link
+ // and render the defalt 3 items in the wall
+ chklst_item.remove_check_list(wall_checklist_items);
+ chklst_item.render_default_checklist_item(wall_checklist_items);
+ },
+ });
+
+ session.mail.Thread.include({
+
+ add_events: function() {
+ res = this._super();
+ var self = this;
+ var main_thread = this.$element.find('.oe_mail_thread_action');
+ var chklst_item = new session.mail_extra.CheckListItem();
+ chklst_item.render_default_checklist_item(main_thread);
+ $(main_thread).find(".oe_checklist_item").click(function(){
+ // to do add more items.
+ chklst_item.render_new_checklist_item(main_thread);
+ });
+ $(main_thread).find(".oe_checklist_thread").click(function(){
+ //toggle the check items
+ $(main_thread).find(".oe_thread_checklist_item").toggle();
+ });
+ $(main_thread).find("input[type=text]:last").focus(function(){
+ $('.oe_checklist_item').css({'display':'block'})
+ });
+ },
+ add_vote_event: function(element){
+ vote_img = element.find('.oe_mail_msg_vote_like');
+ self = this;
+ if (vote_img)
+ vote_img.click(function(){
+ self.subscribe_vote($(this).attr('data-id'));
+ });
+ return
+ },
+
+ render_vote: function(message_id){
+ var self = this;
+ this.mail_message = new session.web.DataSet(this, 'mail.message');
+ this.mail_message.call('get_vote_summary',[[parseInt(message_id)]]).then(function(result){
+ if (result){
+ parent_element = self.find_parent_element(".oe_mail_msg_vote", message_id);
+ vote_element = QWeb.render('VoteDisplay', result);
+ $(parent_element).html(vote_element);
+ self.add_vote_event($(parent_element));
+ }
+ });
+ },
+
+ subscribe_vote: function(message_id){
+ var self = this;
+ this.mail_message = new session.web.DataSet(this, 'mail.message');
+ return this.mail_message.call('vote_toggle', [[parseInt(message_id)]]).then(function(result){
+ self.render_vote(message_id);
+ });
+ },
+
+ display_comments: function(records){
+ res = this._super(records);
+ var self = this;
+ var main_thread = this.$element.find('.oe_mail_thread_action');
+ var chklst_item = new session.mail_extra.CheckListItem();
+ // set focus on checklist item
+ _.each(records, function(record){
+ self.render_vote(record.id);
+ self.render_checklist_items(record.id);
+ });
+ },
+
+ do_comment: function () {
+ var comment_node = this.$element.find('textarea');
+ var body_text = comment_node.val();
+ check_items = false;
+ comment_node.val('');
+ var thread_checklist_items = this.$element.find('.oe_mail_thread_action');
+
+ var chklst_item= new session.mail_extra.CheckListItem();
+ check_items = chklst_item.add_checklist_items_list(thread_checklist_items);
+ // after posting comment this will remove the items added by the Add more item link
+ // and render the defalt 3 items in the wall
+ chklst_item.remove_check_list(thread_checklist_items);
+ chklst_item.render_default_checklist_item(thread_checklist_items);
+ return this.ds.call('message_append_note_checklist', [[this.params.res_id], 'Reply', body_text, this.params.parent_id, 'comment', 'html', check_items]).then(
+ this.proxy('init_comments'));
+ },
+
+ do_display_checklist: function (message_id) {
+ var self=this;
+ parent_element = self.find_parent_element(".oe_mail_msg_checklist", message_id);
+ var new_item = $(QWeb.render("AddChecklist", {}));
+ $(parent_element).after(new_item);
+ },
+
+ find_parent_element: function(name, message_id){
+ parent_element = false;
+ _.each($(name), function(element){
+ if ($(element).attr("data-id") == message_id){
+ parent_element = element;
+ }
+ });
+ return parent_element;
+ },
+
+ calculate_checklist_progress: function(items){
+ if (items.length == 0) return 0;
+ total_checklist_items = items.length;
+ done_checklist_items = 0;
+ checklist_progress = 0;
+ _.each(items, function(record){
+ if (record.done == true)
+ done_checklist_items+=1;
+ });
+ checklist_progress = Math.round((done_checklist_items *100)/total_checklist_items);
+ return checklist_progress;
+ },
+
+ render_checklist_items: function(message_id){
+ var self = this;
+ this.mail_message = new session.web.DataSet(this, 'mail.message');
+ this.mail_message.call('read_checklist_items',[[parseInt(message_id)]]).then(function(result){
+ if (result.length){
+ checklist_progress = self.calculate_checklist_progress(result);
+ parent_element = self.find_parent_element(".oe_mail_msg_checklist", message_id);
+ checklist_element = QWeb.render('ChecklistItem', {'msg_id': message_id, 'checklist_progress':checklist_progress, 'checklist_items': result});
+ $(parent_element).html(checklist_element);
+ $(parent_element).find(".oe_mail_msg_checklist_item").click(function(){
+ self.do_strike_checkbox_item(message_id, $(this));
+ });
+ }
+ });
+ },
+
+ // Strike and unstrike the checklist item.
+ do_strike_checkbox_item: function(message_id, item){
+ check_item_id = item.attr("data-id");
+ parent = item.parent();
+ checked = item.attr("checked");
+ self = this;
+ mail_checklist_item = new session.web.DataSet(this, 'mail.checklist.item');
+ mail_checklist_item.call('action_done', [[parseInt(check_item_id)], checked]).then(function (result) {
+ checklist_progress = self.calculate_checklist_progress(result);
+ progresselement = $(self.find_parent_element(".oe_mail_msg_checklist_progress", message_id));
+ progresselement.find('.oe_mail_msg_checklist_progress_value').html(checklist_progress + "%");
+ progresselement.find('.oe_progressbar').attr("value", checklist_progress);
+ if (checked == "checked"){
+ parent.addClass('oe_strike_checkbox');
+ }else
+ parent.removeClass('oe_strike_checkbox');
+ });
+ },
+ });
+}
=== added directory 'mail_extra/static/src/xml'
=== added file 'mail_extra/static/src/xml/mail_extra.xml'
--- mail_extra/static/src/xml/mail_extra.xml 1970-01-01 00:00:00 +0000
+++ mail_extra/static/src/xml/mail_extra.xml 2012-07-11 10:41:28 +0000
@@ -0,0 +1,98 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<templates id="template" xml:space="preserve">
+
+ <!-- FOR ADD CHECKLIST ITEMS IN FEEDS(WALL) -->
+ <t t-extend="mail.Wall">
+ <t t-jquery="textarea.oe_mail_wall_action_textarea" t-operation="after">
+ <t t-name = "AddChecklist_wall">
+ <div class="oe_wall_checklist_item">
+ <a class="oe_checklist_item" title="Add one more item.">Add More Items</a>
+ </div>
+ </t>
+ </t>
+ <t t-jquery="a.oe_attach" t-operation="append">
+ <a class="oe_checklist_wall oe_right">
+ <img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+ <span title="Hide and show checklist Items">Checklist</span>
+ </a>
+ </t>
+ </t>
+
+ <!-- FOR ADD CHECKLIST ITEMS IN DOCUMENTS(THREAD) -->
+
+ <t t-extend="mail.Thread">
+ <t t-jquery=".oe_mail_action_textarea" t-operation="after">
+ <t t-name = "AddChecklist_thread">
+ <div class="oe_thread_checklist_item">
+ <a class="oe_checklist_item" title="Add one more item.">Add More Items</a>
+ </div>
+ </t>
+ </t>
+ <t t-jquery="a.oe_attach" t-operation="append">
+ <a class="oe_checklist_thread oe_right">
+ <img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+ <span title="Hide and show checklist Items">Checklist</span>
+ </a>
+ </t>
+ </t>
+
+ <t t-extend="mail.Thread.message">
+ <t t-jquery=".oe_comment_time_info" t-operation="after">
+ <t t-if="record.type == 'comment'">
+ <span t-att-data-id="record.id" class="oe_mail_msg_vote"></span>
+ </t>
+ </t>
+ <t t-jquery=".oe_mail_msg_body" t-operation="append">
+ <div t-att-data-id="record.id" class="oe_mail_msg_checklist">
+ </div>
+ </t>
+ </t>
+
+ <t t-name="VoteDisplay">
+ <t t-if='vote_count'>
+ <span class="oe_left oe_mail_vote_string">Votes :<t t-esc="vote_count"/></span>
+ </t>
+ <li>
+ <t t-if="!is_vote_liked">
+ <button class="oe_mail_msg_vote_like" t-att-data-id="msg_id" title="Click to Vote.">
+ <span>+1</span>
+ </button>
+ </t>
+ <t t-if="is_vote_liked">
+ <button class="oe_mail_msg_vote_like" t-att-data-id="msg_id" title="Click to Unvote." style="background:#DC5F59; padding:2px">
+ <span>-1</span>
+ </button>
+ </t>
+ </li>
+ </t>
+
+ <div t-name = "AddChecklist" class="oe_mail_msg_checklist_new">
+ <input type="checkbox" class="oe_mail_msg_checklist_item"/>
+ <input type="text" id = "txt_name" size = "20" placeholder="todo item.."></input>
+ </div>
+
+ <t t-name="ChecklistItem">
+ <t t-if="checklist_items.length != 0">
+ <span class="oe_mail_msg_checklist_progress" t-att-data-id="msg_id">
+ <progress t-att-value='checklist_progress' class="oe_progressbar" max="100"/>
+ <span class="oe_mail_msg_checklist_progress_value"><t t-esc = "checklist_progress"/>%</span> <br/>
+ </span>
+
+ <t t-foreach="checklist_items" t-as="checklist_item">
+ <t t-if="checklist_item.done == true">
+ <span class="oe_strike_checkbox">
+ <input t-att-data-id='checklist_item.id' class="oe_mail_msg_checklist_item" type="checkbox" checked="checked" t-att-value="checklist_item.done" /><t t-esc="checklist_item.name" />
+ </span>
+ </t>
+
+ <t t-if="checklist_item.done == false">
+ <span>
+ <input t-att-data-id='checklist_item.id' type="checkbox" class="oe_mail_msg_checklist_item" t-att-value="checklist_item.done"/><t t-esc="checklist_item.name" />
+ </span>
+ </t>
+ <br/>
+ </t>
+ </t>
+ </t>
+</templates>
_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help : https://help.launchpad.net/ListHelp