[IMP] mail layout simplications
authorAntony Lesuisse <al@openerp.com>
Fri, 22 Jun 2012 01:21:02 +0000 (03:21 +0200)
committerAntony Lesuisse <al@openerp.com>
Fri, 22 Jun 2012 01:21:02 +0000 (03:21 +0200)
bzr revid: al@openerp.com-20120622012102-ysfvjdj2jkhshuwq

addons/mail/static/src/css/mail.css
addons/mail/static/src/js/mail.js
addons/mail/static/src/xml/mail.xml

index 0f1ec8c..2421b28 100644 (file)
 .openerp .oe_mail_msg_comment, 
 .openerp .oe_mail_msg_email {
     padding: 8px;
-}
-
-.openerp .oe_mail_msg_comment, 
-.openerp .oe_mail_msg_email, 
-.openerp .oe_mail_msg_notification {
     background: white;
     border-top: 1px solid #ccc;
 }
     color: #888;
 }
 
-.openerp .oe_mail_msg_body, 
-.openerp .oe_mail_msg_body_short {
+.openerp .oe_mail_msg_body {
     margin-bottom: .5em;
     text-align: justify;
 }
 
+.openerp .oe_mail_msg_tail {
+    display: none;
+}
+
 /* Read more/less link */
 .openerp .oe_mail_msg_content .expand,
 .openerp .oe_mail_msg_content .reduce {
index cd0bc87..26c83f1 100644 (file)
@@ -57,8 +57,6 @@ openerp.mail = function(session) {
         return cs;
     }
 
-    /* Add ThreadDisplay widget to registry */
-    session.web.form.widgets.add( 'Thread', 'openerp.mail.Thread');
     /** 
      * ThreadDisplay widget: this widget handles the display of a thread of
      * messages. The [thread_level] parameter sets the thread level number:
@@ -206,6 +204,13 @@ openerp.mail = function(session) {
                 act_dom.toggle();
                 return false;
             });
+            // see more
+            this.$element.on('click','a.oe_mail_msg_more', function (event) {
+                console.log("sadf");
+                $(this).siblings('.oe_mail_msg_tail').show();
+                $(this).hide();
+                return false;
+            });
         },
         
         destroy: function () {
@@ -230,15 +235,6 @@ openerp.mail = function(session) {
                 else { self.display.show_more = true; records.pop(); }
                 
                 //build attachments download urls and compute time-relative from dates
-                for (var k in records) {
-                    records[k].timerelative = $.timeago(records[k].date);
-                    
-                    if (records[k].attachments) {
-                        for (var l in records[k].attachments) {
-                            records[k].attachments[l].url = self.session.origin + '/web/binary/saveas?session_id=' + self.session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id='+records[k].attachments[l].id;
-                        }
-                    }
-                }
                 
                 self.display_comments(records);
                 if (self.display.show_more == true) self.$element.find('div.oe_mail_thread_more:last').show();
@@ -259,13 +255,16 @@ openerp.mail = function(session) {
         
         display_comments: function (records) {
             var self = this;
+            for (var k in records) {
+                records[k].timerelative = $.timeago(records[k].date);
+                if (records[k].attachments) {
+                    for (var l in records[k].attachments) {
+                        var url = self.session.origin + '/web/binary/saveas?session_id=' + self.session.session_id + '&model=ir.attachment&field=datas&filename_field=datas_fname&id='+records[k].attachments[l].id;
+                        records[k].attachments[l].url = url;
+                    }
+                }
+            }
             this.cs = this.sort_comments_tmp(records);
-            
-            /* WIP: map matched regexp -> records to browse with name */
-            //_(records).each(function (record) {
-                //self.do_check_internal_links(record.body_text);
-            //});
-            
             _(records).each(function (record) {
                 var sub_msgs = [];
                 if ((record.parent_id == false || record.parent_id[0] == self.params.parent_id) && self.params.thread_level > 0 ) {
@@ -302,23 +301,19 @@ openerp.mail = function(session) {
             }
             // body text manipulation
             record.body = this.do_clean_text(record.body);
-            record.tr_body = this.do_truncate_string(record.body, this.params.msg_more_limit);
             record.body = this.do_replace_internal_links(record.body);
-            if (record.tr_body) record.tr_body = this.do_replace_internal_links(record.tr_body);
+
+            // split for see mode
+            var split = this.do_truncate_string(record.body, this.params.msg_more_limit);
+            record.body_head = split[0];
+            record.body_tail = split[1];
+
             // format date according to the user timezone
             record.date = session.web.format_value(record.date, {type:"datetime"});
-            // render
-            // OPTIONS
+
 
             var rendered = session.web.qweb.render('mail.Thread.message', {'record': record, 'thread': this, 'params': this.params, 'display': this.display});
             $( rendered).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
-            // truncated: hide full-text, show summary, add buttons
-            if (record.tr_body) {
-                var node_body = this.$element.find('.oe_mail_msg_body:last');
-                var node_body_short = this.$element.find('.oe_mail_msg_body_short:last').append('... <a href="#" class="expand">See more</a>');
-                node_body.hide();
-                node_body_short.find('a:last').click(function() { node_body_short.hide(); node_body.show(); return false; });
-            }
         },
        
         /**
@@ -461,9 +456,9 @@ openerp.mail = function(session) {
         do_truncate_string: function(string, max_length) {
             // multiply by 1.2: prevent truncating an just too little long string
             if (string.length <= (max_length * 1.2)) {
-                return false;
+                return [string, ""];
             } else {
-                return string.slice(0, max_length);
+                return [string.slice(0, max_length), string.slice(max_length)];
             }
         },
         
@@ -512,10 +507,9 @@ openerp.mail = function(session) {
         },
 
     });
+    session.web.form.widgets.add( 'Thread', 'openerp.mail.Thread');
 
-    /* Add ThreadView widget to registry */
-    session.web.form.widgets.add( 'ThreadView', 'openerp.mail.RecordThread');
-    /* ThreadView widget: thread of comments */
+    /** ThreadView widget: thread of comments */
     mail.RecordThread = session.web.form.AbstractField.extend({
         template: 'mail.RecordThread',
 
@@ -616,11 +610,9 @@ openerp.mail = function(session) {
             return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
         },
     });
+    session.web.form.widgets.add( 'ThreadView', 'openerp.mail.RecordThread');
 
-
-    /* Add WallView widget to registry */
-    session.web.client_actions.add('mail.all_feeds', 'session.mail.WallView');
-    /* WallView widget: a wall of messages */
+    /** WallView widget: a wall of messages */
     mail.WallView = session.web.Widget.extend({
         template: 'mail.Wall',
 
@@ -818,6 +810,7 @@ openerp.mail = function(session) {
             var call_done = this.ds_users.call('message_append_note', [[this.session.uid], 'Tweet', body_text, false, 'comment', 'html']).then(this.proxy('init_and_fetch_comments'));
         },
     });
+    session.web.client_actions.add('mail.all_feeds', 'session.mail.WallView');
 
 };
 
index 4b6898f..5ff8a99 100644 (file)
                         <t t-if="!thread._is_author(record.user_id[0]) &amp;&amp; display['show_hide']">
                             <li><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_hide">Hide</a></li>
                         </t>
+                        <li t-if="record.type == 'email'"><a href="#" class="oe_mail_msg_details">Details</a></li>
                     </ul>
                 </span>
-                
                 <div class="oe_mail_msg">
-                     <t t-if="record.subject">
-                        <h1 class="oe_mail_msg_title">
-                            <a href="#" class="oe_mail_internal_link"><t t-raw="record.subject"/></a>
-                        </h1>
-                    </t>
-                    
-                    <p class="oe_mail_msg_subtitle">
-                        <t t-if="params.thread_level > 0">
-                            <a href="#" t-attf-data-res-model='{params.res_model}' t-attf-data-res-id='{params.res_id}' class="oe_mail_internal_link"><t t-raw="record.record_name"/></a>
+                    <h1 t-if="record.subject &amp;&amp; record.subject != 'Reply'" class="oe_mail_msg_title">
+                        <t t-raw="record.subject"/>
+                    </h1>
+                    <div t-if="params.thread_level > 0" class="oe_mail_msg_subtitle">
+                        <a href="#" t-attf-data-res-model='{params.res_model}' t-attf-data-res-id='{params.res_id}' class="oe_mail_internal_link"><t t-raw="record.record_name"/></a>
+                    </div>
+                    <div class="oe_mail_msg_body">
+                        <a href="#" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}' class="oe_mail_internal_link"><t t-raw="record.user_id[1]"/></a>
+                        <t t-raw="record.body_head"/>
+                        <t t-if="record.body_tail"><a href="#" class="oe_mail_msg_more">... See more</a>
+                            <span class="oe_mail_msg_tail"><t t-raw="record.body_tail"/></span>
                         </t>
-                        <span class="oe_mail_msg_author"><a href="#" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}' class="oe_mail_internal_link"><t t-raw="record.user_id[1]"/></a></span>
-                        <span class="oe_mail_msg_date" t-att-title="record.date"><t t-raw="record.timerelative"/></span>
-                    </p>
-
-                    <div class="oe_mail_msg_body"><t t-raw="record.body"/></div>
-                    <t t-if="record.tr_body">
-                        <div class="oe_mail_msg_body_short"><t t-raw="record.tr_body"/></div>
-                    </t>
-
+                    </div>
                     <ul class="oe_mail_msg_footer">
-                      <t t-if="display['show_reply']">
-                        <li><a href="#" class="oe_mail_msg_reply">Reply</a></li>
-                      </t>
+                      <li><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>
-                      <t t-if="record.attachment_ids.length > 0">
-                        <li>
-                            <a href="#" class="oe_mail_msg_view_attachments">
-                                <t t-if="record.attachment_ids.length == 1">Attachment</t>
-                                <t t-if="record.attachment_ids.length > 1">Attachments (<t t-raw="record.attachment_ids.length"/>)</t>
-                            </a>
-                        </li>
-                      </t>
+                      -->
+                      <li t-if="record.attachment_ids.length > 0">
+                          <a href="#" class="oe_mail_msg_view_attachments">
+                              <t t-if="record.attachment_ids.length == 1">Attachment</t>
+                              <t t-if="record.attachment_ids.length > 1">Attachments (<t t-raw="record.attachment_ids.length"/>)</t>
+                          </a>
+                      </li>
                     </ul>
                     <t t-if="record.attachment_ids.length > 0">
                         <div class="oe_clear"></div>
             </div>
         </div>
     </div>
-
-
 </template>