From 7e674428333b9e8b9496be9c2c75f0cc67f7632e Mon Sep 17 00:00:00 2001 From: Antonin Bourguignon Date: Tue, 19 Jun 2012 20:28:10 +0200 Subject: [PATCH] [IMP] messages display bzr revid: abo@openerp.com-20120619182810-k4m1w8gkntdw5weq --- addons/mail/static/src/css/mail.css | 58 ++++++++++++++-------- addons/mail/static/src/js/mail.js | 67 ++++++++++++++++++++----- addons/mail/static/src/xml/mail.xml | 76 +++++++++++++++++++---------- 3 files changed, 142 insertions(+), 59 deletions(-) diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css index 55efc7ff42c..2f2daa4692a 100644 --- a/addons/mail/static/src/css/mail.css +++ b/addons/mail/static/src/css/mail.css @@ -60,10 +60,6 @@ width: 486px; } -.openerp div.oe_mail_msg_content p { - margin: 4px 0; -} - .openerp div.oe_mail_msg_content li{ float: left; margin-right: 3px; @@ -299,6 +295,7 @@ /* ------------------------------ */ .openerp .oe_mail_msg .oe_mail_msg_title { + margin: 0; font-size: 1.3em; font-weight: bold; } @@ -308,16 +305,28 @@ text-decoration: none; } -.openerp .oe_mail_msg_intlinks, +.openerp .oe_mail_msg_subtitle { + margin: 0 0 .5em 0; +} +.openerp .oe_mail_msg_footer, .openerp .oe_mail_msg_subtitle { color: #888; } -.openerp .oe_mail_msg_intlinks a:link { - color: #8786b7; + +.openerp .oe_mail_msg_body, +.openerp .oe_mail_msg_body_short { + margin-bottom: .5em; + text-align: justify; +} + +/* Read more/less link */ +.openerp .oe_mail_msg_content .expand, +.openerp .oe_mail_msg_content .reduce { + font-weight: bold; } /* Gear menu */ -.openerp .oe_mail_msg_comment a.oe_gear_menuaction { +.openerp .oe_mail_msg_content a.oe_gear_menuaction { position: absolute; top: 0px; right: 3px; @@ -325,16 +334,13 @@ color: #4c4c4c; cursor: pointer; } -.openerp .oe_mail_msg_comment:hover .oe_gear_menuaction { +.openerp .oe_mail_msg_content:hover .oe_gear_menuaction { display: block; } -.openerp .oe_mail_msg_comment a.oe_gear_menuaction:hover { +.openerp .oe_mail_msg_content a.oe_gear_menuaction:hover { text-decoration: none; } -.openerp .oe_mail_msg_comment a.oe_gear_menuaction:hover { - text-decoration: none; -} -.openerp .oe_mail_msg_comment ul.oe_gear_menu { +.openerp .oe_mail_msg_content ul.oe_gear_menu { list-style-type: none; display: none; position: absolute; @@ -353,20 +359,17 @@ -webkit-box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); -box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3); } -.openerp .oe_mail_msg_comment a.oe_gear_menuaction:hover ~ .oe_gear_menu { - display: block; -} -.openerp .oe_mail_msg_comment ul.oe_gear_menu > li { +.openerp .oe_mail_msg_content ul.oe_gear_menu > li { float: none; } -.openerp .oe_mail_msg_comment .oe_gear_menu > li > a { +.openerp .oe_mail_msg_content .oe_gear_menu > li > a { display: block; padding: 3px 6px; line-height: 14px; color: #4c4c4c; text-decoration: none; } -.openerp .oe_mail_msg_comment .oe_gear_menu > li > a:hover { +.openerp .oe_mail_msg_content .oe_gear_menu > li > a:hover { background: #f0f0fa; background: -moz-linear-gradient(#f0f0fa, #eeeef6); background: -webkit-gradient(linear, left top, left bottom, from(#f0f0fa), to(#eeeef6)); @@ -375,8 +378,21 @@ -webkit-box-shadow: none; -box-shadow: none; } -.openerp .oe_mail_msg_comment .oe_gear_menu p { +.openerp .oe_mail_msg_content .oe_gear_menu p { margin-left: 12px; } +/* Attachments */ +.openerp ul.oe_mail_msg_attachments { + display: none; + width: 100%; + border-top: 1px solid #CCC; + margin-top: .5em; + padding: .5em 0; +} +.openerp ul.oe_mail_msg_attachments li { + float: none; +} + + diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 1d0c659b669..0abd48f098f 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -117,15 +117,43 @@ openerp.mail = function(session) { }, start: function() { + var self = this; + this._super.apply(this, arguments); // customize display - if (! this.display.show_post_comment) this.$element.find('div.oe_mail_thread_act').hide(); + if (! this.display.show_post_comment) { + this.$element.find('div.oe_mail_thread_act').hide(); + } // add events this.add_events(); - /* display user, fetch comments */ + + // display user, fetch comments this.display_current_user(); - if (this.params.records) var display_done = this.display_comments_from_parameters(this.params.records); - else var display_done = this.init_comments(); + + if (this.params.records) { + var display_done = this.display_comments_from_parameters(this.params.records); + } else { + var display_done = this.init_comments(); + } + + // handle the dropdown menu + var dropdown_menu_trigger = '.oe_gear_menuaction'; // css class name + var dropdown_menu_elts = '.oe_gear_menu'; // css class name + + this.$element.on('click', dropdown_menu_trigger, function (ev) { + $gear_menu = $(this).siblings(dropdown_menu_elts); + + if ($gear_menu.is(':visible')) { + $gear_menu.hide(); + } else { + $gear_menu.show(); + } + + // hide others menus if opened + $(dropdown_menu_trigger).not(this).siblings(dropdown_menu_elts).hide(); + return false; + }); + return display_done }, @@ -175,7 +203,7 @@ openerp.mail = function(session) { return false; }); // event: click on an internal link - this.$element.find('div.oe_mail_thread_display').delegate('a.intlink', 'click', function (event) { + this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_internal_link', 'click', function (event) { // lazy implementation: fetch data and try to redirect if (! event.srcElement.dataset.resModel) return false; else var res_model = event.srcElement.dataset.resModel; @@ -193,6 +221,12 @@ openerp.mail = function(session) { } else self.do_action({ type: 'ir.actions.act_window', res_model: res_model, res_id: parseInt(res_id), views: [[false, 'form']]}); }); + // event: click on 'attachment(s)' in msg + this.$element.delegate('a.oe_mail_msg_view_attachments', 'click', function (event) { + var act_dom = $(this).parent().parent().parent().find('.oe_mail_msg_attachments'); + act_dom.toggle(); + return false; + }); }, destroy: function () { @@ -270,7 +304,7 @@ openerp.mail = function(session) { display_comment: function (record) { record.body = this.do_text_nl2br(record.body, true); if (record.type == 'email') { record.mini_url = ('/mail/static/src/img/email_icon.png'); } - else { record.mini_url = this.thread_get_avatar('res.users', 'avatar', record.user_id[0]); } + else { record.mini_url = this.thread_get_avatar('res.users', 'avatar', record.user_id[0]); } // 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); @@ -284,8 +318,8 @@ openerp.mail = function(session) { ).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('span.oe_mail_msg_body:last').append(' [ ... Show less]'); - var node_body_short = this.$element.find('span.oe_mail_msg_body_short:last').append(' [ ... Show more]'); + var node_body = this.$element.find('.oe_mail_msg_body:last').append('

See less'); + var node_body_short = this.$element.find('.oe_mail_msg_body_short:last').append('... See more'); node_body.hide(); node_body.find('a:last').click(function() { node_body.hide(); node_body_short.show(); return false; }); node_body_short.find('a:last').click(function() { node_body_short.hide(); node_body.show(); return false; }); @@ -405,7 +439,7 @@ openerp.mail = function(session) { var regex_res = regex_login.exec(string); while (regex_res != null) { var login = regex_res[2]; - string = string.replace(regex_res[0], regex_res[1] + '@' + login + ''); + string = string.replace(regex_res[0], regex_res[1] + '@' + login + ''); regex_res = regex_login.exec(string); } /* special shortcut: :name, try to find an icon if in list */ @@ -424,9 +458,18 @@ openerp.mail = function(session) { return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || ''); }, + /** + * @param {String} string to truncate + * @param {Number} max number of chars to display + * @returns {String} truncated string + */ do_truncate_string: function(string, max_length) { - if (string.length <= (max_length * 1.2)) return false; - else return string.slice(0, max_length); + // multiply by 1.2: prevent truncating an just too little long string + if (string.length <= (max_length * 1.2)) { + return false; + } else { + return string.slice(0, max_length); + } }, /** Removes html tags, except b, em, br */ @@ -550,7 +593,7 @@ openerp.mail = function(session) { if (record.id == self.session.uid) { self.is_subscriber = true; } var mini_url = self.thread_get_avatar('res.users', 'avatar', record.id); $('
  • ' + - '' + record.name + '
  • ').appendTo(user_list); + '' + record.name + '').appendTo(user_list); }); if (self.is_subscriber) { self.$element.find('button.oe_mail_button_follow').hide(); diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml index 7458f972fa2..adedb8e6bc3 100644 --- a/addons/mail/static/src/xml/mail.xml +++ b/addons/mail/static/src/xml/mail.xml @@ -147,44 +147,68 @@ B -
    - - + + +
  • Hide
  • +
    +
    + + +
    +

    - +

    +

    - + + + · + + · - +

    - + +
    - -
    -