[IMP] ThreadDisplay: now shows a "More button" (no action attached currently). Updated css for style. Emails are managed. Also refactored templates for cleaner architecture.

bzr revid: tde@openerp.com-20120227110754-9v207ey8m3k5rv9j
This commit is contained in:
Thibault Delavallée
2012-02-27 12:07:54 +01:00
parent 0c4099ba26
commit d3dd68e08e
4 changed files with 124 additions and 63 deletions
+1
View File
@@ -72,6 +72,7 @@ The main features are:
'images/customer_history.jpeg',
'images/messages_form.jpeg',
'images/messages_list.jpeg',
'static/src/img/email_icong.png',
],
'css': [
'static/src/css/mail.css',
+33 -8
View File
@@ -77,8 +77,26 @@
}
.oe_mail_thread_msg, .oe_mail_thread_act {
width: 80%;
white-space: normal;
margin-bottom: 5px;
border-bottom: 1px solid #D2D9E7;
}
.notification {
background: #E0E0E0;
}
.email {
background: #E0E0E0;
}
.oe_mail_thread_msg_more {
margin-left: 20%;
margin-right: 40%;
border: 1px solid #D2D9E7;
background: #E0E0E0;
text-align: center;
}
.oe_mail_thread_msg:after, .oe_mail_thread_act:after {
@@ -99,8 +117,8 @@
.oe_mail_msg_image {
float: left;
width: 60px;
height: 60px;
width: 45px;
height: 40px;
text-align: center;
overflow: hidden;
-moz-border-radius: 3px;
@@ -115,14 +133,13 @@
}
.oe_mail_msg_image img {
width: 60px;
width: 40px;
height: auto;
clip: rect(10px, 100px, 110px, 0px);
}
.oe_mail_msg_content {
width: 89%;
margin-left: 11%;
margin-left: 50px;
}
.oe_mail_msg_p {
@@ -130,10 +147,18 @@
margin: 0;
}
.oe_mail_msg_p_email_header {
border-bottom: 1px solid #D2D9E7;
}
.oe_mail_msg_body {
}
.oe_mail_msg_author, .oe_mail_msg_author a {
.oe_mail_msg_author {
color: #747474;
}
.oe_mail_msg_author a {
color: #4E43E7;
}
@@ -141,6 +166,6 @@
color: #C03000;
}
.oe_mail_msg_date, .oe_mail_msg_date a {
color: #4E43E7;
.oe_mail_msg_date {
color: #747474;
}
+37 -28
View File
@@ -20,6 +20,7 @@ openerp.mail = function(session) {
this.uid = params['uid'];
this.limit = params['limit'] || 10;
this.offset = params['offset'] || 0;
this.cur_limit = this.limit;
this.records = params['records'] || false;
// tmp
this.map_hash = {'res.users': []};
@@ -58,12 +59,6 @@ openerp.mail = function(session) {
return this.ds.call('message_load', [[this.res_id]]).then(this.proxy('display_comments'));
},
display_current_user: function () {
$('<div>').html(
'<img src="' + this.thread_get_avatar_mini('res.users', 'avatar_mini', this.uid) + '"/>'
).appendTo(this.$element.find('div.oe_mail_msg_image'));
},
display_comments: function (records) {
var self = this;
this.$element.find('div.oe_mail_thread_display').empty();
@@ -73,13 +68,23 @@ openerp.mail = function(session) {
});
//console.log(this.map_hash);
_(records).each(function (record) {
record.mini_url = self.thread_get_avatar_mini('res.users', 'avatar_mini', record.user_id[0]);
if (record.type == 'email') { record.mini_url = ('/mail/static/src/img/email_icon.png'); }
else { record.mini_url = self.thread_get_avatar_mini('res.users', 'avatar_mini', record.user_id[0]); }
record.body_text = self.do_replace_internal_links(record.body_text);
var render_res = session.web.qweb.render('ThreadMsg', {
'record': record,
});
$('<div class="oe_mail_thread_msg">').html(render_res).appendTo(self.$element.find('div.oe_mail_thread_display'));
$(render_res).appendTo(self.$element.find('div.oe_mail_thread_display'));
});
// add and bind "more button"
$(session.web.qweb.render('MoreButton', {})).appendTo(self.$element.find('div.oe_mail_thread_display'));
this.$element.find('button.oe_mail_button_more').bind('click', function () { self.do_more(); });
},
display_current_user: function () {
$('<div>').html(
'<img src="' + this.thread_get_avatar_mini('res.users', 'avatar_mini', this.uid) + '"/>'
).appendTo(this.$element.find('div.oe_mail_msg_image'));
},
do_comment: function () {
@@ -88,26 +93,8 @@ openerp.mail = function(session) {
this.proxy('fetch_comments'));
},
/* check for internal links, and map them to limitate number of queries -- WIP, probably not useful */
check_internal_links: function(string) {
/* shortcut to user: @login */
var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*\s)/g);
var regex_res = regex_login.exec(string);
while (regex_res != null) {
var login = regex_res[2];
this.map_hash['res.users'].push(login);
regex_res = regex_login.exec(string);
}
/* internal links: @res.model,name */
var regex_intlink = new RegExp(/(^|\s)@(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
regex_res = regex_intlink.exec(string);
while (regex_res != null) {
var res_model = regex_res[2] + '.' + regex_res[3];
var res_name = regex_res[4];
if (! (res_model in this.map_hash)) { this.map_hash[res_model] = []; }
this.map_hash[res_model].push(res_name);
regex_res = regex_intlink.exec(string);
}
do_more: function () {
console.log('do more !');
},
do_replace_internal_links: function (string) {
@@ -135,6 +122,28 @@ openerp.mail = function(session) {
return string;
},
/* check for internal links, and map them to limitate number of queries -- WIP, probably not useful */
check_internal_links: function(string) {
/* shortcut to user: @login */
var regex_login = new RegExp(/(^|\s)@(\w*[a-zA-Z_.]+\w*\s)/g);
var regex_res = regex_login.exec(string);
while (regex_res != null) {
var login = regex_res[2];
this.map_hash['res.users'].push(login);
regex_res = regex_login.exec(string);
}
/* internal links: @res.model,name */
var regex_intlink = new RegExp(/(^|\s)@(\w*[a-zA-Z_]+\w*)\.(\w+[a-zA-Z_]+\w*),(\w+)/g);
regex_res = regex_intlink.exec(string);
while (regex_res != null) {
var res_model = regex_res[2] + '.' + regex_res[3];
var res_name = regex_res[4];
if (! (res_model in this.map_hash)) { this.map_hash[res_model] = []; }
this.map_hash[res_model].push(res_name);
regex_res = regex_intlink.exec(string);
}
},
thread_get_avatar_mini: function(model, field, id) {
return this.session.prefix + '/web/binary/image?session_id=' + this.session.session_id + '&model=' + model + '&field=' + field + '&id=' + (id || '');
},
+53 -27
View File
@@ -25,6 +25,22 @@
</div>
</div>
<t t-name="WallHeader">
<div class="tmp_oe_mail_thread_header">
Discussion about document <t t-raw="record_model"/> (id: <t t-raw="record_id"/>)
</div>
<div class="tmp_oe_mail_thread_content">
</div>
</t>
<t t-name="MoreButton">
<div class="oe_mail_thread_msg_more">
<button class="oe_mail_button_more" type="button">More
<t t-if="msg_left"> (<t t-raw="msg_left"/> left)</t>
</button>
</div>
</t>
<t t-name="WallThreadContainer">
<div class="oe_mail_wall_thread_header">
Discussion about document <t t-raw="record_model"/> (id: <t t-raw="record_id"/>)
@@ -57,45 +73,55 @@
<div class="oe_mail_msg_image">
</div>
<div class="oe_mail_msg_content">
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
<button type="button" class="oe_mail_button_comment">Post comment</button>
<textarea class="oe_mail_action_textarea" onfocus="this.value='';">Enter your comment here...</textarea><br />
<button type="button" class="oe_mail_button_comment">Post comment</button>
</div>
</div>
<div class="oe_mail_thread_display">
</div>
</div>
<t t-name="ThreadMsg">
<div t-name="ThreadMsg" t-attf-class="{record.type} oe_mail_thread_msg">
<div class="oe_mail_msg_image">
<img t-att-src="record.mini_url"/>
</div>
<div class="oe_mail_msg_content">
<p class="oe_mail_msg_p">
<t t-if="record.type == 'notification'">
<span class="oe_mail_msg_author">OpenERP System Notification</span>
</t>
<t t-if="record.type == 'comment'">
<span class="oe_mail_msg_author"><a href="#"><t t-raw="record.user_id[1]"/></a></span>
</t>
<t t-if="record.type == 'email'">
<span class="oe_mail_msg_author"><t t-raw="record.user_id[1]"/></span>
</t>
<t t-if="record.need_action_user_id != false">
- <span class="oe_mail_msg_need_action">Need action by <a href="#"><t t-raw="record.need_action_user_id[1]"/></a></span>
</t>
<br />
<span class="oe_mail_msg_body"><t t-esc="record.body_text"/></span><br />
<span class="oe_mail_msg_date"><t t-raw="record.date"/></span>
</p>
<t t-if="record.type == 'email'">
<t t-call="EmailDisplay" />
</t>
<t t-if="record.type == 'notification' || record.type == 'comment'">
<t t-call="NotificationDisplay" />
</t>
</div>
</div>
<t t-name="NotificationDisplay">
<p class="oe_mail_msg_p">
<t t-if="record.type == 'notification'">
<span class="oe_mail_msg_author">OpenERP System Notification</span>
</t>
<t t-if="record.type == 'comment'">
<span class="oe_mail_msg_author">
<a href="#" data-res-model='res.users' t-attf-data-res-id='{record.user_id[0]}'><t t-raw="record.user_id[1]"/></a>
</span>
</t>
<t t-if="record.need_action_user_id != false">
- <span class="oe_mail_msg_need_action">Need action by <a href="#"><t t-raw="record.need_action_user_id[1]"/></a></span>
</t>
wrote on <span class="oe_mail_msg_date"><t t-raw="record.date"/></span>
<br />
<span class="oe_mail_msg_body"><t t-esc="record.body_text"/></span>
</p>
</t>
<t t-name="WallHeader">
<div class="tmp_oe_mail_thread_header">
Discussion about document <t t-raw="record_model"/> (id: <t t-raw="record_id"/>)
</div>
<div class="tmp_oe_mail_thread_content">
</div>
<t t-name="EmailDisplay">
<p class="oe_mail_msg_p oe_mail_msg_p_email_header">
From: <t t-esc="email_from"/> on <span class="oe_mail_msg_date"><t t-raw="record.date"/></span><br />
To: <t t-sec="mail_to"/><br />
</p>
<p class="oe_mail_msg_p">
<span class="oe_mail_msg_body"><t t-esc="record.body_text"/></span>
</p>
</t>
</template>