[MERGE] from chm

bzr revid: fva@openerp.com-20121030154406-fs1udytai37yuv0y
This commit is contained in:
Frédéric van der Essen 2012-10-30 16:44:06 +01:00
commit 2ade3c5b9c
3 changed files with 29 additions and 31 deletions

View File

@ -359,8 +359,13 @@ openerp.mail = function (session) {
this.parent_thread.context
]).then(function (record) {
var thread = self.parent_thread;
if (self.options.display_indented_thread < self.thread_level && thread.parent_message) {
thread = thread.parent_message.parent_thread;
}
// create object and attach to the thread object
thread.message_fetch(false, false, [record], function (arg, data) {
data[0].no_sorted = true;
var message = thread.create_message_object( data[0] );
// insert the message on dom
thread.insert_message( message, self.$el );
@ -536,6 +541,8 @@ openerp.mail = function (session) {
init: function (parent, datasets, context) {
this._super(parent);
// record options
this.options = datasets.options || {};
// record domain and context
this.domain = datasets.domain || [];
this.context = _.extend({
@ -543,30 +550,14 @@ openerp.mail = function (session) {
default_res_id: 0,
default_parent_id: false }, context || {});
// record options
this.options = datasets.options || {};
// data of this message
this.id = datasets.id || -1,
this.model = datasets.model || false,
this.parent_id = datasets.parent_id || false,
this.res_id = datasets.res_id || false,
this.type = datasets.type || false,
this.is_author = datasets.is_author || false,
this.is_private = datasets.is_private || false,
this.subject = datasets.subject || false,
this.name = datasets.name || false,
this.record_name = datasets.record_name || false,
this.body = datasets.body || false,
this.vote_nb = datasets.vote_nb || 0,
this.has_voted = datasets.has_voted || false,
this.is_favorite = datasets.is_favorite || false,
this.thread_level = datasets.thread_level || 0,
this.to_read = datasets.to_read || false,
this.author_id = datasets.author_id || [],
this.attachment_ids = datasets.attachment_ids || [],
for (var k in datasets) {
this[k] = datasets[k];
}
this._date = datasets.date;
this.show_record_name = this.record_name && !this.subject && !this.thread_level && this.model!='res.partner';
// record options and data
this.parent_thread= parent.messages!= undefined ? parent : this.options.root_thread;
this.thread = false;
@ -830,7 +821,7 @@ openerp.mail = function (session) {
event.stopPropagation();
var self=this;
var button = self.$('.oe_star:first');
return this.ds_message.call('favorite_toggle', [[self.id]])
this.ds_message.call('favorite_toggle', [[self.id]])
.then(function (star) {
self.is_favorite=star;
if (self.is_favorite) {
@ -948,19 +939,18 @@ openerp.mail = function (session) {
/* When the expandable object is visible on screen (with scrolling)
* then the on_expandable function is launch
*/
on_scroll: function (event) {
if (event)event.stopPropagation();
$last = this.$('> .oe_msg_expandable:last');
if ($last.hasClass('oe_max_limit')) {
var pos = $last.position();
on_scroll: function () {
var expandables =
_.each( _.filter(this.messages, function (val) {return val.id < 0;}), function (val) {
var pos = val.$el.position();
if (pos.top) {
/* bottom of the screen */
var bottom = $(window).scrollTop()+$(window).height()+200;
if (bottom > pos.top) {
$last.find('.oe_msg_more_message').click();
val.on_expandable();
}
}
}
});
},
/**
@ -979,6 +969,7 @@ openerp.mail = function (session) {
var p=$(this).parent();
p.find('.oe_more_hidden, .oe_hidden').show();
p.find('.oe_more').hide();
return false;
},
/**
@ -988,6 +979,7 @@ openerp.mail = function (session) {
var p=$(this).parent();
p.find('.oe_more_hidden, .oe_hidden').hide();
p.find('.oe_more').show();
return false;
},
/* get all child message/thread id linked.
@ -1077,6 +1069,7 @@ openerp.mail = function (session) {
on_compose_message: function () {
this.instantiate_compose_message();
this.compose_message.on_compose_expandable();
return false;
},
/**
@ -1182,6 +1175,9 @@ openerp.mail = function (session) {
var message_older = false;
if (message.id > 0) {
for (var i in self.messages) {
if (self.messages[i].no_sorted) {
continue;
}
if (self.messages[i].id > message.id) {
if (!message_newer || message_newer.id > self.messages[i].id) {
message_newer = self.messages[i];
@ -1262,6 +1258,7 @@ openerp.mail = function (session) {
on_message_detroy: function (message) {
this.messages = _.filter(this.messages, function (val) { return !val.isDestroyed(); });
return false;
},
@ -1484,6 +1481,7 @@ openerp.mail = function (session) {
}
if (this.root) {
$('<span class="oe_mail-placeholder"/>').insertAfter(this.root.$el);
this.root.destroy();
}
// create and render Thread widget

View File

@ -206,7 +206,7 @@
<t t-raw="widget.subject"/>
</h1>
<div class="oe_msg_body">
<t t-if="widget.options.show_record_name and widget.record_name and (!widget.subject) and !widget.options.thread_level and !widget.options.display_on_thread[0] and widget.model!='res.partner'">
<t t-if="widget.show_record_name">
<a class="oe_mail_action_model" t-attf-href="#model=#{widget.model}&amp;id=#{widget.res_id}"><t t-raw="widget.record_name"/></a>
</t>
<t t-raw="widget.body"/>

View File

@ -120,7 +120,7 @@
<field name="memo" widget="html" class="oe_memo" editor_height="450px" />
<div class="oe_chatter">
<field name="message_follower_ids" widget="mail_followers"/>
<field class="oe_chatter" name="message_ids" widget="mail_thread"/>
<field name="message_ids" widget="mail_thread"/>
</div>
</form>
</field>