[IMP] messages display
bzr revid: abo@openerp.com-20120619182810-k4m1w8gkntdw5weq
This commit is contained in:
parent
04289e6ef1
commit
7e67442833
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -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(' <a href="#" class="reduce">[ ... Show less]</a>');
|
||||
var node_body_short = this.$element.find('span.oe_mail_msg_body_short:last').append(' <a href="#" class="expand">[ ... Show more]</a>');
|
||||
var node_body = this.$element.find('.oe_mail_msg_body:last').append('<br/><br/><a href="#" class="reduce">See less</a>');
|
||||
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.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] + '<a href="#" class="intlink oe_mail_oe_intlink" data-res-model="res.users" data-res-login = ' + login + '>@' + login + '</a>');
|
||||
string = string.replace(regex_res[0], regex_res[1] + '<a href="#" class="oe_mail_internal_link" data-res-model="res.users" data-res-login = ' + login + '>@' + login + '</a>');
|
||||
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);
|
||||
$('<li><img class="oe_mail_oe_left oe_mail_msg_image" src="' + mini_url + '"/>' +
|
||||
'<a href="#" class="intlink oe_mail_oe_intlink" data-res-model="res.users" data-res-id="' + record.id + '">' + record.name + '</a></li>').appendTo(user_list);
|
||||
'<a href="#" class="oe_mail_internal_link" data-res-model="res.users" data-res-id="' + record.id + '">' + record.name + '</a></li>').appendTo(user_list);
|
||||
});
|
||||
if (self.is_subscriber) {
|
||||
self.$element.find('button.oe_mail_button_follow').hide();
|
||||
|
|
|
@ -147,44 +147,68 @@
|
|||
<t t-name="mail.Thread.new.NoteDisplay">
|
||||
<a class="oe_gear_menuaction oe_i">B</a>
|
||||
<ul class="oe_gear_menu">
|
||||
<li><a href="#">Delete</a></li>
|
||||
<li><a href="#">Hide</a></li>
|
||||
</ul>
|
||||
<div class="oe_mail_msg">
|
||||
<!--
|
||||
<t t-if="params.thread_level > 0">
|
||||
<a href="#" class="intlink oe_mail_oe_intlink" t-attf-data-res-model='{params.res_model}' t-attf-data-res-id='{params.res_id}'><t t-raw="record.record_name"/></a>
|
||||
<t t-if="display['show_delete']">
|
||||
<t t-if="thread._is_author(record.user_id[0])">
|
||||
<li><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_delete">Delete</a></li>
|
||||
</t>
|
||||
</t>
|
||||
-->
|
||||
<t t-if="record.subject">
|
||||
<t t-if="display['show_hide']">
|
||||
<t t-if="!(thread._is_author(record.user_id[0]))">
|
||||
<li><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_hide">Hide</a></li>
|
||||
</t>
|
||||
</t>
|
||||
</ul>
|
||||
|
||||
<div class="oe_mail_msg">
|
||||
<t t-if="record.subject">
|
||||
<h1 class="oe_mail_msg_title">
|
||||
<a href="#permalink"><t t-raw="record.subject"/></a>
|
||||
<a href="#" class="oe_mail_internal_link"><t t-raw="record.subject"/></a>
|
||||
</h1>
|
||||
</t>
|
||||
|
||||
<p class="oe_mail_msg_subtitle">
|
||||
<a href="#" class="intlink" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}'><t t-raw="record.user_id[1]"/></a>
|
||||
<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>
|
||||
·
|
||||
</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>
|
||||
·
|
||||
<t t-raw="record.date"/>
|
||||
<span class="oe_mail_msg_date"><t t-raw="record.date"/></span>
|
||||
</p>
|
||||
<span class="oe_mail_msg_body"><t t-raw="record.body"/></span>
|
||||
|
||||
<div class="oe_mail_msg_body"><t t-raw="record.body"/></div>
|
||||
<t t-if="record.tr_body">
|
||||
<span class="oe_mail_msg_body_short"><t t-raw="record.tr_body"/></span>
|
||||
</t><br/>
|
||||
<ul class="oe_mail_msg_intlinks">
|
||||
<div class="oe_mail_msg_body_short"><t t-raw="record.tr_body"/></div>
|
||||
</t>
|
||||
|
||||
<ul class="oe_mail_msg_footer">
|
||||
<t t-if="display['show_reply']">
|
||||
<li><a href="#" class="oe_mail_msg_reply oe_mail_oe_intlink">Reply</a><span class="oe_mail_oe_space oe_fade"> · </span></li>
|
||||
<li><a href="#" class="oe_mail_msg_reply">Reply</a> · </li>
|
||||
</t>
|
||||
<t t-if="display['show_delete']">
|
||||
<t t-if="thread._is_author(record.user_id[0])">
|
||||
<li><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_delete oe_mail_oe_intlink">Delete</a><span class="oe_mail_oe_space oe_fade"> · </span></li>
|
||||
</t>
|
||||
</t>
|
||||
<t t-if="display['show_hide']">
|
||||
<t t-if="!(thread._is_author(record.user_id[0]))">
|
||||
<li><a href="#" t-attf-data-id='{record.id}' class="oe_mail_msg_hide oe_mail_oe_intlink">Hide</a><span class="oe_mail_oe_space oe_fade"> · </span></li>
|
||||
</t>
|
||||
<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>
|
||||
</ul>
|
||||
|
||||
<t t-if="record.attachment_ids.length > 0">
|
||||
<div class="oe_clear"></div>
|
||||
|
||||
<ul class="oe_mail_msg_attachments">
|
||||
<t t-foreach="record.attachments" t-as="attachment">
|
||||
<li>
|
||||
<a href="#" data-res-model='ir.attachment' t-attf-data-res-id='{attachment.id}' class="oe_mail_internal_link">
|
||||
<t t-raw="attachment.name"/>
|
||||
</a>
|
||||
</li>
|
||||
</t>
|
||||
</ul>
|
||||
</t>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
|
|
Loading…
Reference in New Issue