Nimesh Contractor(Open ERP) has proposed merging 
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-checklist_toggle-nco
 into lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.

Requested reviews:
  Atul Patel(OpenERP) (atp-openerp)

For more details, see:
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-checklist_toggle-nco/+merge/111369

Hello sir,

         I have done following changes for chatter.

         1) add the 3 default check-items to enter with comment.
         2) Done the same functionality for the document comment.
         3) On enter text item focus will pass to the next item.
         4) Toggle the check-list items.
         5) put the vote button in note display(after delete) area.
         6) Instead of On enter event - I have put the post button to post 
comment for the document.

Thanks,
 NCO.
-- 
https://code.launchpad.net/~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp-checklist_toggle-nco/+merge/111369
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-open-chatter-part-4-atp.
=== modified file 'mail/mail_thread.py'
--- mail/mail_thread.py	2012-06-18 04:47:33 +0000
+++ mail/mail_thread.py	2012-06-21 09:42:34 +0000
@@ -732,7 +732,19 @@
             body_html = body
             body_text = body
         return self.message_append(cr, uid, ids, subject, body_html=body_html, body_text=body_text, parent_id=parent_id, type=type, subtype=subtype, context=context)
-
+    
+    def message_append_note_checklist(self, cr, uid, ids, subject=None, body=None, parent_id=False, type='notification', subtype='html', items=[], context=None):
+        new_msg_ids =  self.message_append_note(cr, uid, ids, subject, body, parent_id, type, subtype, context)
+        check_items = []
+        mail_message = self.pool.get('mail.message')
+        for msg in mail_message.browse(cr, uid, new_msg_ids, context):
+            mail_item = self.pool.get('mail.checklist.item')
+            for item in items:
+                item_id = mail_item.create(cr, uid, {'msg_id':msg.id, 'user_id':uid, 'name' : item}, context=context)
+                check_items.append(item_id)
+            mail_message.write(cr, uid, msg.id, {'checklist_item_ids': [(6,0,check_items)]}, context)
+        return True
+    
     #------------------------------------------------------
     # Subscription mechanism
     #------------------------------------------------------

=== modified file 'mail/static/src/js/mail.js'
--- mail/static/src/js/mail.js	2012-06-12 10:23:11 +0000
+++ mail/static/src/js/mail.js	2012-06-21 09:42:34 +0000
@@ -135,12 +135,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_act:first');

=== modified file 'mail/static/src/xml/mail.xml'
--- mail/static/src/xml/mail.xml	2012-06-07 17:53:28 +0000
+++ mail/static/src/xml/mail.xml	2012-06-21 09:42:34 +0000
@@ -49,6 +49,7 @@
             <img class="oe_mail_msg_image oe_left" alt="User img"/>
             <div class="oe_mail_msg_content">
                 <textarea class="oe_mail oe_mail_action_textarea" placeholder="Add your comment here..." onfocus="this.value = '';"/>
+                <button class="oe_right oe_mail_wall_button_comment" type="button">Post comment</button>
             </div>
         </div>
         <div class="oe_mail_thread_display"></div>

=== modified file 'mail_extra/static/src/css/mail_extra.css'
--- mail_extra/static/src/css/mail_extra.css	2012-06-18 06:18:21 +0000
+++ mail_extra/static/src/css/mail_extra.css	2012-06-21 09:42:34 +0000
@@ -1,15 +1,31 @@
-span.oe_mail_vote_span
-{
-    position: relative;
-    left: 2px;
-    bottom: -5px;
+.openerp .oe_wall_checklist_item{
+    margin-top:10px;
+    padding-left: 50px;
+}
+.openerp .oe_button_position{
+	padding-left: 5px;
+}
+.openerp .oe_checklist_item{
+	padding : 9px;
+	cursor:pointer;
+}
+.openerp .oe_checklist_wall{
+	cursor:pointer;
+	padding-left: 55px;
 }
 
 .openerp .oe_checklist{
-	padding : 9px;
-	cursor:pointer;
-}
-.openerp div.oe_mail_thread_subthread a.oe_checklist
+	padding: 9px;
+	cursor:pointer;
+}
+.openerp .oe_checklist_icon{
+	height: 15px;
+	width: 20px;	
+}
+.openerp .oe_checklist_thread{
+	cursor:pointer;
+}
+.openerp div.oe_mail_thread_subthread a.oe_checklist_item
 {
     padding : 9px;
     width: 18px;
@@ -24,22 +40,15 @@
 }
 
 .openerp .oe_progressbar {
-
 	background-color:white;
 	width:220px;
 	height:4px;
-	
 }
 
 button.oe_mail_msg_vote_like{
-    height:25px;
-    width: 30px;
+    height:20px;
+    width: 20px;
     background: #8A89BA;
-    position: relative;
-    bottom: -5px;
-    left: 10px;
-    border-radius: 2px;
-    -moz-border-radius: 2px;
 }
 
 button.oe_mail_msg_vote_like:hover{
@@ -48,12 +57,8 @@
 
 button.oe_mail_msg_vote_like span {
     color: white;
-    position: relative;
-    right: 5px;
 }
 
 span.oe_mail_vote_string{
-    position: relative;
     bottom: -5px;
-
 }

=== 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-06-21 09:42:34 +0000 differ
=== modified file 'mail_extra/static/src/js/mail_extra.js'
--- mail_extra/static/src/js/mail_extra.js	2012-06-12 12:21:50 +0000
+++ mail_extra/static/src/js/mail_extra.js	2012-06-21 09:42:34 +0000
@@ -1,13 +1,77 @@
 openerp.mail_extra = function(session){
     var QWeb = session.web.qweb;
     var _t = session.web._t;
+    session.mail.WallView.include({
+    	
+    	render_checklist_item: function(){
+    		var main_wall = this.$element.find('.oe_mail_wall_act');
+    		var parent_element = $(main_wall).find('.oe_checklist_item');
+     		var new_item = $(QWeb.render("AddChecklist", {}));
+     		$(parent_element).before(new_item);
+    	},
+    	
+        render_defalt_checklist_item: function(){
+        	for(i=0; i<3; i++){
+    			this.render_checklist_item();
+    		}
+        },
+        
+		add_event_handlers: function () {
+    		res = this._super();
+    		var self = this;
+    		var main_wall = this.$element.find('.oe_mail_wall_act');
+    		self.render_defalt_checklist_item();
+    		// set focus on first textbox
+    		$(main_wall).find('input[type=text]:visible:first').focus();
+    		// On enter focus on next textbox.
+    		$(main_wall).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();
+	    		}
+	    	});
+    		$(main_wall).find(".oe_checklist_item").click(function(){
+        		// to do add more items.
+         		self.render_checklist_item();
+        	});
+        	$(main_wall).find(".oe_checklist_wall").click(function(){
+        		//toggle the check items
+        		$(main_wall).find(".oe_wall_checklist_item").toggle();
+        	});
+        },
+        
+        do_comment: function () {
+        	self = this;
+        	check_items = []
+        	var comment_node = this.$element.find('textarea.oe_mail_wall_action_textarea');
+            var body_text = comment_node.val();
+            comment_node.val('');
+            
+        	var wall_checklist_items = this.$element.find('.oe_mail_wall_act');
+        	text_items = $(wall_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('');
+     		})
+     		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
+     		items_to_remove = $(wall_checklist_items).find('input');
+     		_(items_to_remove).each(function(item){
+     			$(item).remove();
+     		})
+     		this.render_defalt_checklist_item();
+        },
+    });
+    
     session.mail.Thread.include({
-        add_checklist_event: function(){
-        	var self = this;
-            this.$element.find('a.oe_checklist').click(function(){
-             	self.do_display_checklist($(this).attr('data-id'));
-             });
-        },
+    	
         add_vote_event: function(element){
             vote_img = element.find('.oe_mail_msg_vote_like');
             self = this;
@@ -36,42 +100,95 @@
             this.mail_message = new session.web.DataSet(this, 'mail.message');
             return this.mail_message.call('vote_subscribe', [parseInt(message_id)]).then(function(result){
                     self.render_vote(message_id);
-                  });
-        },
+            });
+        },
+        
+        render_checklist_item: function(){
+    		var main_thread = this.$element.find('.oe_mail_thread_act');
+    		var parent_element = $(main_thread).find('.oe_checklist_item');
+     		var new_item = $(QWeb.render("AddChecklist", {}));
+     		$(parent_element).before(new_item);
+    	},
+    	
+        render_defalt_checklist_item: function(){
+        	for(i=0; i<3; i++){
+    			this.render_checklist_item();
+    		}
+        },
+        
+        add_events: function() {
+        	res = this._super();
+    		var self = this;
+    		var main_thread = this.$element.find('.oe_mail_thread_act');
+    		
+    		self.render_defalt_checklist_item();
+    		$(main_thread).find(".oe_checklist_item").click(function(){
+        		// to do add more items.
+         		self.render_checklist_item();
+        	});
+        	$(main_thread).find(".oe_checklist_thread").click(function(){
+        		//toggle the check items
+        		$(main_thread).find(".oe_thread_checklist_item").toggle();
+        	});
+        },
+        
         display_comments: function(records){
             res = this._super(records);
             var self = this;
+            var main_thread = this.$element.find('.oe_mail_thread_act');
+    		
+    		// set focus on first textbox
+    		$(main_thread).find('input[type=text]:visible:first').focus();
+    		// On enter focus on next textbox.
+    		$(main_thread).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();
+	    		}
+	    	});
         	_.each(records, function(record){
         		self.render_vote(record.id);
         		self.render_checklist_items(record.id);
         	});
-        	self.add_checklist_event();
-        },
+        },
+        
+        do_comment: function () {
+            var comment_node = this.$element.find('textarea');
+            var body_text = comment_node.val();
+            check_items = [];
+            comment_node.val('');
+            var thread_checklist_items = this.$element.find('.oe_mail_thread_act');
+        	text_items = $(thread_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('');
+     		})
+
+     		// after posting comment this will remove the items added by the Add more item link 
+			// and render the defalt 3 items in the wall
+     		items_to_remove = $(thread_checklist_items).find('input');
+     		_(items_to_remove).each(function(item){
+     			$(item).remove();
+     		})
+     		this.render_defalt_checklist_item();
+     		
+            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);
-            new_item.find('input[type=text]').keyup(function (event) {
-                var charCode = (event.which) ? event.which : window.event.keyCode;
-                if (charCode == 13) {
-                	value = $(this).val();
-                	(value != "") ? self.add_checkitem(value, message_id, new_item) : new_item.remove();
-                }
-            });
-         },
-         
-         add_checkitem: function(value, message_id, item_element){
-			this.mail_message = new session.web.DataSet(this, 'mail.message');
-        	if(!_.isEmpty(value)){
-		        this.mail_message.call('add_checklist_item', [message_id,value]).done(function(result){
-			        self.render_checklist_items(message_id);
-			        item_element.remove();
-		        });
-		    }
-         },
-         
-         find_parent_element: function(name, message_id){
+        },
+         
+        find_parent_element: function(name, message_id){
         	 parent_element = false;
           	_.each($(name), function(element){
      			if ($(element).attr("data-id") == message_id){
@@ -80,6 +197,7 @@
      		});
           	return parent_element;
          },
+         
          calculate_checklist_progress: function(items){
         	if (items.length == 0) return 0;
         	total_checklist_items = items.length;
@@ -92,6 +210,7 @@
         	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');
@@ -125,8 +244,6 @@
 				}else
 					parent.removeClass('oe_strike_checkbox');
 			});
- 		    	
          },
-        
     });
 }

=== modified file 'mail_extra/static/src/xml/mail_extra.xml'
--- mail_extra/static/src/xml/mail_extra.xml	2012-06-18 06:18:21 +0000
+++ mail_extra/static/src/xml/mail_extra.xml	2012-06-21 09:42:34 +0000
@@ -2,21 +2,56 @@
 
 <templates id="template" xml:space="preserve">
     
-    <t t-extend="ThreadMsg">
-        <t t-jquery=".oe_mail_msg_content" t-operation="append">
-            <t t-if="record.type == 'comment'">
-            	<br/>
-            	<span t-att-data-id="record.id" class="oe_mail_msg_vote"></span>
-            	<a class="oe_checklist" t-att-data-id="record.id" title="Add items in the checklist and track work progress.">Add Checklist</a>
+    <t t-extend="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>
+				<div class="oe_checklist_wall" title="Hide and show checklist Items">
+					<a>
+						<img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+						Checklist
+					</a>
+				</div>
+			</t>
+        </t>
+    </t>
+    
+    <t t-extend="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>
+				
+				<div class="oe_checklist_thread" title="Hide and show checklist Items">
+					<a>
+						<img t-att-src='_s + "/mail_extra/static/src/img/checklist.png"' class="oe_checklist_icon"/>
+						Checklist
+					</a>
+				</div>
+			</t>
+        </t>
+    </t>
+    
+    <t t-extend="NoteDisplay">
+    	<t t-jquery=".oe_mail_oe_intlink" t-operation="before">
+        	<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_mail_vote_string">Votes :</span>
-             <span class="oe_mail_vote_span"><t t-esc="vote_count"/></span>
+             <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="Give Vote on a comment.">
                 <span>+1</span>
@@ -27,18 +62,12 @@
                 <span>-1</span>
             </button>
         </t>
-    </t>
-    
-	<t t-extend="NoteDisplay">
-        <t t-jquery=".oe_mail_msg_body" t-operation="append">
-        	<div t-att-data-id="record.id" class="oe_mail_msg_checklist">
-        	</div>
-        </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 = "10"></input>
+		<input type="text" id = "txt_name" size = "20" placeholder="todo item.."></input>
     </div>
     
     <t t-name="ChecklistItem">

_______________________________________________
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

Reply via email to