From 4f220ff718de78e65716d4b0f782887dc7e06218 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 11:52:17 +0100
Subject: [PATCH 1/7] [IMP] Thread widget: use name_get to display the record
name between the avatar and the message body. Updated comment display.
bzr revid: tde@openerp.com-20120312105217-sjm1lrminn70i6h4
---
addons/mail/static/src/js/mail.js | 21 +++++++++++++--------
addons/mail/static/src/xml/mail.xml | 16 ++++++----------
2 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index d9f6c3472c4..2dcf59a6081 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -23,7 +23,6 @@ openerp.mail = function(session) {
template: 'Thread',
/**
- *
* @param {Object} parent parent
* @param {Object} [params]
* @param {String} [params.res_model] res_model of mail.thread object
@@ -49,6 +48,7 @@ openerp.mail = function(session) {
this.params.offset = this.params.offset || 0;
this.params.records = this.params.records || null;
/* DataSets and internal vars */
+ this.name = 'Unknown'
this.map_hash = {};
this.sorted_comments = {'root_ids': [], 'root_id_msg_list': {}};
this.display_show_more = true;
@@ -83,10 +83,15 @@ 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']]});
});
- /* display user, fetch comments */
- this.display_current_user();
- if (this.params.records) return this.display_comments(this.params.records);
- else return this.init_comments();
+ /* get record name */
+ var name_get_done = self.ds.name_get([this.params.res_id]).then(function (records) { self.name = records[0][1]; });
+ var display_done = $.when(name_get_done).then(function () {
+ /* display user, fetch comments */
+ self.display_current_user();
+ if (self.params.records) return self.display_comments(self.params.records);
+ else return self.init_comments();
+ });
+ return display_done
},
stop: function () {
@@ -164,7 +169,8 @@ openerp.mail = function(session) {
record.body_text = this.do_replace_internal_links(record.body_text);
if (record.tr_body_text) record.tr_body_text = this.do_replace_internal_links(record.tr_body_text);
// render
- $(session.web.qweb.render('ThreadMsg', {'record': record})).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
+ $(session.web.qweb.render('ThreadMsg', {'record': record, 'res_model': this.params.res_model, 'res_id': this.params.res_id, 'name': this.name})).appendTo(
+ this.$element.children('div.oe_mail_thread_display:first'));
// truncated: hide full-text, show summary, add buttons
if (record.tr_body_text) {
var node_body = this.$element.find('span.oe_mail_msg_body:last').append(' [ ... Show less]');
@@ -530,7 +536,6 @@ openerp.mail = function(session) {
* @param {Number} limit number of messages to fetch
*/
init_comments: function(domain, context, offset, limit) {
- var self = this;
this.params.domain = [];
this.display_show_more = true;
this.sorted_comments = {'models': {}};
@@ -576,7 +581,7 @@ openerp.mail = function(session) {
'res_model': model_name, 'res_id': records[0]['res_id'], 'uid': self.session.uid, 'records': records,
'parent_id': false, 'thread_level': self.params.thread_level}
);
- thread.appendTo(self.$element.find('div.oe_mail_wall_thread:last'));
+ var thread_displayed = thread.appendTo(self.$element.find('div.oe_mail_wall_thread:last'));
});
});
},
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 1a04d4e44c0..7f5fb7c5814 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -69,18 +69,14 @@
-
-
- via OpenERP System Notification
-
- on
-
+
+
+
+
+ on
+
From 532607843715119ebede77eb590f230eb604eaf1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 12:46:39 +0100
Subject: [PATCH 2/7] [FIX] mail_thread: fixed a bug when sending a
notification coming from an action: the message user_id was reset, therefore
not displaying the user name and avatar next to the message.
bzr revid: tde@openerp.com-20120312114639-fb5sggvvw1egnnzn
---
addons/mail/mail_thread.py | 4 ----
1 file changed, 4 deletions(-)
diff --git a/addons/mail/mail_thread.py b/addons/mail/mail_thread.py
index 336505c4b18..6ea9d806c7b 100644
--- a/addons/mail/mail_thread.py
+++ b/addons/mail/mail_thread.py
@@ -101,10 +101,6 @@ class mail_thread(osv.osv):
subscription_obj = self.pool.get('mail.subscription')
notification_obj = self.pool.get('mail.notification')
- # notifications do not come from any user, but from system
- if vals.get('type') == 'notification': vals['user_id'] = False
- if not 'model' in vals: vals['model'] = False
- if not 'res_id' in vals: vals['res_id'] = 0
need_action_pushed = False
# create message
From 86b72a1f802da633b732cc045a1e2fed0692deff Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 12:50:05 +0100
Subject: [PATCH 3/7] [IMP] hr_holidays: improved messages (removed record
name, as it appears in the message header)
bzr revid: tde@openerp.com-20120312115005-k9p5hhxubpi3vtfh
---
addons/hr_holidays/hr_holidays.py | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index d5331624350..ea2deed51cc 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -377,38 +377,38 @@ class hr_holidays(osv.osv):
def create_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids, context=context):
self.message_append_note(cr, uid, ids, _('System notification'),
- _("The %s request '%s' has been created and is waiting confirmation")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context)
+ _("The %s request has been created and is waiting confirmation")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
return True
def holidays_confirm_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request '%s' has been confirmed and is waiting for validation by the manager.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification')
+ _("The %s request has been confirmed and is waiting for validation by the manager.")
+ % ('leave' if obj.type == 'remove' else 'allocation',,), type='notification')
def holidays_validate_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
if obj.holiday_status_id.double_validation:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request '%s' has been validated. A second validation is necessary and is now pending.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context)
+ _("The %s request has been validated. A second validation is necessary and is now pending.")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
else:
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request '%s' has been validated. The validation process is now over.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name), type='notification', context=context)
+ _("The %s request has been validated. The validation process is now over.")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
def holidays_valid2_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request '%s' has been double validated. The validation process is now over.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', context=context)
+ _("The %s request has been double validated. The validation process is now over.")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
def holidays_refuse_notificate(self, cr, uid, ids, approval, context=None):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
- _("The %s request '%s' has been refused. The validation process is now over.")
- % ('leave' if obj.type == 'remove' else 'allocation', obj.name,), type='notification', context=context)
+ _("The %s request has been refused. The validation process is now over.")
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification', context=context)
hr_holidays()
From cbc9654b832007e2990265c7748a684b2923a316 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 12:52:43 +0100
Subject: [PATCH 4/7] [FIX] hr_holidays: unnecessary ',' causing crash removed
bzr revid: tde@openerp.com-20120312115243-f6tos2qqna3li7z0
---
addons/hr_holidays/hr_holidays.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/addons/hr_holidays/hr_holidays.py b/addons/hr_holidays/hr_holidays.py
index ea2deed51cc..b9453ae908f 100644
--- a/addons/hr_holidays/hr_holidays.py
+++ b/addons/hr_holidays/hr_holidays.py
@@ -385,7 +385,7 @@ class hr_holidays(osv.osv):
for obj in self.browse(cr, uid, ids):
self.message_append_note(cr, uid, [obj.id], _('System notification'),
_("The %s request has been confirmed and is waiting for validation by the manager.")
- % ('leave' if obj.type == 'remove' else 'allocation',,), type='notification')
+ % ('leave' if obj.type == 'remove' else 'allocation',), type='notification')
def holidays_validate_notificate(self, cr, uid, ids, context=None):
for obj in self.browse(cr, uid, ids):
From ff171895d238a5ccc13c4b846294b1567accaf42 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 16:25:29 +0100
Subject: [PATCH 5/7] [IMP] Thread widget: improved usability: added a reply
link toggling comment textarea; commenting can be done via the enter key
bzr revid: tde@openerp.com-20120312152529-lbcz0byljetpeezj
---
addons/mail/static/src/css/mail.css | 8 +++---
addons/mail/static/src/js/mail.js | 44 +++++++++++++++++++++--------
addons/mail/static/src/xml/mail.xml | 6 ++--
3 files changed, 40 insertions(+), 18 deletions(-)
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 526ee7ceb42..8085d17856c 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -127,10 +127,6 @@ div.oe_mail_thread_msg:after, div.oe_mail_thread_act:after {
margin-left: 60px;
}
-.oe_mail_button_comment {
- width: 150px;
-}
-
.oe_mail_action_textarea {
height: 50px;
padding: 5px;
@@ -228,3 +224,7 @@ a.oe_mail_oe_intlink {
.oe_mail_oe_warning, .oe_mail_oe_warning a {
color: #C03000;
}
+
+.oe_mail_oe_space {
+ margin-left: 15px;
+}
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 2dcf59a6081..24e5acc5250 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -48,12 +48,19 @@ openerp.mail = function(session) {
this.params.offset = this.params.offset || 0;
this.params.records = this.params.records || null;
/* DataSets and internal vars */
- this.name = 'Unknown'
- this.map_hash = {};
- this.sorted_comments = {'root_ids': [], 'root_id_msg_list': {}};
- this.display_show_more = true;
this.ds = new session.web.DataSet(this, this.params.res_model);
this.ds_users = new session.web.DataSet(this, 'res.users');
+ this.name = 'Unknown record'
+ this.sorted_comments = {'root_ids': [], 'root_id_msg_list': {}};
+ /* Display vars */
+ this.display = {};
+ this.display.show_post_comment = (this.params.thread_level > 0);
+ this.display.show_reply = true;
+ this.display.show_delete = true;
+ this.display.show_hide = true;
+ this.display.show_more = (this.params.thread_level > 0);
+ // not used currently
+ this.intlinks_mapping = {};
},
start: function() {
@@ -61,10 +68,24 @@ openerp.mail = function(session) {
this._super.apply(this, arguments);
/* display customization and events */
this.$element.find('p.oe_mail_p_nomore').hide();
- if (this.params.thread_level > 0) this.$element.find('div.oe_mail_thread_act').hide();
- if (this.params.thread_level > 0) this.$element.find('div.oe_mail_thread_more').hide();
- this.$element.find('button.oe_mail_button_comment').bind('click', function () { self.do_comment(); });
+ if (this.display.show_post_comment) this.$element.find('div.oe_mail_thread_act').hide();
+ if (this.display.show_more) this.$element.find('div.oe_mail_thread_more').hide();
this.$element.find('button.oe_mail_button_more').bind('click', function () { self.do_more(); });
+ this.$element.find('textarea.oe_mail_action_textarea').bind('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) { self.do_comment(); }
+ });
+ this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
+ console.log(event);
+ console.log(this);
+ console.log($(this));
+ var node = $(this).parents('div.oe_mail_thread_display');
+ console.log(node);
+ var node2 = node.find('div.oe_mail_thread_act:first');
+ console.log(node2);
+ node2.toggle();
+ });
this.$element.find('div.oe_mail_thread_display').delegate('a.intlink', 'click', function (event) {
// lazy implementation: fetch data and try to redirect
if (! event.srcElement.dataset.resModel) return false;
@@ -104,7 +125,6 @@ openerp.mail = function(session) {
this.sorted_comments = {'root_ids': [], 'root_id_msg_list': {}};
this.$element.find('div.oe_mail_thread_display').empty();
domain = this.get_fetch_domain(this.sorted_comments);
- console.log(domain);
return this.fetch_comments(this.params.limit, this.params.offset, domain).then();
},
@@ -113,9 +133,9 @@ openerp.mail = function(session) {
var self = this;
var defer = this.ds.call('message_load', [[this.params.res_id], (limit||this.params.limit), (offset||this.params.offset), (domain||[]), (this.params.thread_level > 0), (this.sorted_comments['root_ids'])]);
$.when(defer).then(function (records) {
- if (records.length < self.params.limit) self.display_show_more = false;
+ if (records.length < self.params.limit) self.display.show_more = false;
self.display_comments(records);
- if (self.display_show_more == false) {
+ if (self.display.show_more == false) {
self.$element.find('button.oe_mail_button_more:last').hide();
self.$element.find('p.oe_mail_p_nomore:last').show(); }
});
@@ -169,8 +189,8 @@ openerp.mail = function(session) {
record.body_text = this.do_replace_internal_links(record.body_text);
if (record.tr_body_text) record.tr_body_text = this.do_replace_internal_links(record.tr_body_text);
// render
- $(session.web.qweb.render('ThreadMsg', {'record': record, 'res_model': this.params.res_model, 'res_id': this.params.res_id, 'name': this.name})).appendTo(
- this.$element.children('div.oe_mail_thread_display:first'));
+ $(session.web.qweb.render('ThreadMsg', {'record': record, 'res_model': this.params.res_model, 'res_id': this.params.res_id, 'name': this.name,
+ 'display': this.display})).appendTo(this.$element.children('div.oe_mail_thread_display:first'));
// truncated: hide full-text, show summary, add buttons
if (record.tr_body_text) {
var node_body = this.$element.find('span.oe_mail_msg_body:last').append(' [ ... Show less]');
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 7f5fb7c5814..1873d9352b8 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -47,8 +47,7 @@
-
-
+
@@ -77,6 +76,9 @@
on
+ Reply
+ Delete
+ Hide
From d3af101c681cf2fda643704ffe3ea8bdaf5e9483 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 16:58:38 +0100
Subject: [PATCH 6/7] [IMP] Thread widget: comments now have smaller images
bzr revid: tde@openerp.com-20120312155838-srvzfmjvt783e6kr
---
addons/mail/static/src/css/mail.css | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/addons/mail/static/src/css/mail.css b/addons/mail/static/src/css/mail.css
index 8085d17856c..9c4fc416123 100644
--- a/addons/mail/static/src/css/mail.css
+++ b/addons/mail/static/src/css/mail.css
@@ -27,6 +27,15 @@
padding: 2px;
}
+.oe_mail_thread_subthread div.oe_mail_thread_act .oe_mail_msg_image, .oe_mail_thread_subthread div.oe_mail_thread_display .oe_mail_msg_image {
+ width: 30px;
+ height: 30px;
+}
+
+.oe_mail_thread_subthread .oe_mail_msg_content, .oe_mail_thread_subthread .oe_mail_msg_content {
+ margin-left: 40px;
+}
+
.oe_mail_wall_more {
text-align: center;
}
From 543d76dca3638c664b19cdd3943eec476c3ca061 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Thibault=20Delavall=C3=A9e?=
Date: Mon, 12 Mar 2012 18:33:23 +0100
Subject: [PATCH 7/7] [IMP] Thread widget: small user experience improvements
(reply comment hidden by default; comment textarea is cleaned after posting
the comment; em tag not escaped in mesages; fixed class name of links delete
and hide.
bzr revid: tde@openerp.com-20120312173323-z1xnabsjzxj3vyxa
---
addons/mail/static/src/js/mail.js | 27 +++++++++++----------------
addons/mail/static/src/xml/mail.xml | 4 ++--
2 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index 24e5acc5250..57c01a77b8c 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -54,11 +54,11 @@ openerp.mail = function(session) {
this.sorted_comments = {'root_ids': [], 'root_id_msg_list': {}};
/* Display vars */
this.display = {};
- this.display.show_post_comment = (this.params.thread_level > 0);
- this.display.show_reply = true;
+ this.display.show_post_comment = false;
+ this.display.show_reply = (this.params.thread_level > 0);
this.display.show_delete = true;
this.display.show_hide = true;
- this.display.show_more = (this.params.thread_level > 0);
+ this.display.show_more = (this.params.thread_level == 0);
// not used currently
this.intlinks_mapping = {};
},
@@ -68,8 +68,8 @@ openerp.mail = function(session) {
this._super.apply(this, arguments);
/* display customization and events */
this.$element.find('p.oe_mail_p_nomore').hide();
- if (this.display.show_post_comment) this.$element.find('div.oe_mail_thread_act').hide();
- if (this.display.show_more) this.$element.find('div.oe_mail_thread_more').hide();
+ if (! this.display.show_post_comment) this.$element.find('div.oe_mail_thread_act').hide();
+ if (! this.display.show_more) this.$element.find('div.oe_mail_thread_more').hide();
this.$element.find('button.oe_mail_button_more').bind('click', function () { self.do_more(); });
this.$element.find('textarea.oe_mail_action_textarea').bind('keyup', function (event) {
var charCode = (event.which) ? event.which : window.event.keyCode;
@@ -77,14 +77,8 @@ openerp.mail = function(session) {
else if (charCode == 13) { self.do_comment(); }
});
this.$element.find('div.oe_mail_thread_display').delegate('a.oe_mail_msg_reply', 'click', function (event) {
- console.log(event);
- console.log(this);
- console.log($(this));
- var node = $(this).parents('div.oe_mail_thread_display');
- console.log(node);
- var node2 = node.find('div.oe_mail_thread_act:first');
- console.log(node2);
- node2.toggle();
+ var act_dom = $(this).parents('div.oe_mail_thread_display').find('div.oe_mail_thread_act:first');
+ act_dom.toggle();
});
this.$element.find('div.oe_mail_thread_display').delegate('a.intlink', 'click', function (event) {
// lazy implementation: fetch data and try to redirect
@@ -251,8 +245,9 @@ openerp.mail = function(session) {
},
do_comment: function () {
- var body_text = this.$element.find('textarea').val();
- //console.log(body_text + '-' + this.params.parent_id + '-' + this.params.res_id);
+ var comment_node = this.$element.find('textarea');
+ var body_text = comment_node.val();
+ comment_node.val('');
return this.ds.call('message_append_note', [[this.params.res_id], 'Reply comment', body_text, this.params.parent_id, 'comment']).then(
this.proxy('init_comments'));
},
@@ -322,7 +317,7 @@ openerp.mail = function(session) {
},
do_clean_text: function (string) {
- var html = $('').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('<(/)?b\\s*>', 'gi'), '<$1b>');
+ var html = $('').text(string.replace(/\s+/g, ' ')).html().replace(new RegExp('<(/)?(b|em)\\s*>', 'gi'), '<$1$2>');
return html;
},
diff --git a/addons/mail/static/src/xml/mail.xml b/addons/mail/static/src/xml/mail.xml
index 1873d9352b8..724241e70b3 100644
--- a/addons/mail/static/src/xml/mail.xml
+++ b/addons/mail/static/src/xml/mail.xml
@@ -77,8 +77,8 @@
on
Reply
- Delete
- Hide
+ Delete
+ Hide