diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js index 604f93af2cb..5b83020fdc4 100644 --- a/addons/mail/static/src/js/mail.js +++ b/addons/mail/static/src/js/mail.js @@ -31,9 +31,8 @@ openerp.mail = function(session) { this.params.offset = this.params.offset || 0; this.params.records = this.params.records || null; this.params.char_show_more = this.params.char_show_more || 100; - // tmp - this.map_hash = {'res.users': []}; - /* DataSets */ + this.map_hash = {'res.users': {'login': [] }}; + /* define DataSets */ this.ds = new session.web.DataSet(this, this.params.res_model); this.ds_users = new session.web.DataSet(this, 'res.users'); }, @@ -45,12 +44,10 @@ openerp.mail = function(session) { this.$element.find('button.oe_mail_button_comment').bind('click', function () { self.do_comment(); }); /* delegate links */ self.$element.find('div.oe_mail_thread_display').delegate('a.intlink', 'click', function (event) { - var res_model = event.srcElement.dataset.resModel; - var res_id = event.srcElement.dataset.resId; self.do_action({ type: 'ir.actions.act_window', - res_model: res_model, - res_id: parseInt(res_id), + res_model: event.srcElement.dataset.resModel, + res_id: parseInt(event.srcElement.dataset.resId), views: [[false, 'form']] }); }); @@ -81,32 +78,30 @@ openerp.mail = function(session) { display_comments: function (records) { var self = this; /* WIP: map matched regexp -> records to browse with name */ - _(records).each(function (record) { - //self.check_internal_links(record.body_text); - }); - //console.log(this.map_hash); + //_(records).each(function (record) { + //self.do_check_internal_links(record.body_text); + //}); _(records).each(function (record) { 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]); } + // body text manipulation record.body_text = self.do_clean_text(record.body_text); - record.tr_body_text = self.truncate_string(record.body_text, self.params.char_show_more); + record.tr_body_text = self.do_truncate_string(record.body_text, self.params.char_show_more); record.body_text = self.do_replace_internal_links(record.body_text); if (record.tr_body_text) record.tr_body_text = self.do_replace_internal_links(record.tr_body_text); + // render $(session.web.qweb.render('ThreadMsg', {'record': record})).appendTo(self.$element.find('div.oe_mail_thread_display')); + // truncated: hide full-text, show summary, add buttons if (record.tr_body_text) { var node = self.$element.find('span.oe_mail_msg_body:last').append(' [ ... Show less]'); self.$element.find('p.oe_mail_msg_p:last').append($('' + record.tr_body_text + ' [ ... Show more]')); var new_node = self.$element.find('span.oe_mail_msg_body_short:last'); node.hide(); - node.find('a:last').click(function() { - node.hide(); new_node.show(); return false; - }); - new_node.find('a:last').click(function() { - new_node.hide(); node.show(); return false; - }); + node.find('a:last').click(function() { node.hide(); new_node.show(); return false; }); + new_node.find('a:last').click(function() { new_node.hide(); node.show(); return false; }); } }); // update offset for "More" buttons @@ -115,7 +110,7 @@ openerp.mail = function(session) { display_current_user: function () { $('