[IMP] mail: update js with filtering id (read & star). No ID return by py for the expandable message

bzr revid: chm@openerp.com-20121105115852-10t2izyauqxamlhh
This commit is contained in:
Christophe Matthieu 2012-11-05 12:58:52 +01:00
parent 356fc45fac
commit f4bf65f723
2 changed files with 11 additions and 12 deletions

View File

@ -317,13 +317,13 @@ class mail_message(osv.Model):
to load
:return bool: True
"""
def _get_expandable(domain, message_nb, parent_id, id):
def _get_expandable(domain, message_nb, parent_id, max_limit):
return {
'domain': domain,
'nb_messages': message_nb,
'type': 'expandable',
'parent_id': parent_id,
'id': id,
'max_limit': max_limit,
}
if not messages:
@ -339,10 +339,10 @@ class mail_message(osv.Model):
if ids:
# inside a thread: prepend
if parent_id:
messages.insert(0, _get_expandable(exp_domain, -1, parent_id, -1))
messages.insert(0, _get_expandable(exp_domain, -1, parent_id, True))
# new threads: append
else:
messages.append(_get_expandable(exp_domain, -1, parent_id, -1))
messages.append(_get_expandable(exp_domain, -1, parent_id, True))
# 2. get the expandables for new messages inside threads if display is not flat
if thread_level == 0:
@ -371,7 +371,7 @@ class mail_message(osv.Model):
id_max = child_id
elif nb > 0:
exp_domain = [('id', '>=', id_min), ('id', '<=', id_max), ('id', 'child_of', message_id)]
messages.append(_get_expandable(exp_domain, nb, message_id, id_min))
messages.append(_get_expandable(exp_domain, nb, message_id, False))
id_min, id_max, nb = max(child_ids), 0, 0
else:
id_min, id_max, nb = max(child_ids), 0, 0
@ -379,7 +379,7 @@ class mail_message(osv.Model):
exp_domain = [('id', '>=', id_min), ('id', '<=', id_max), ('id', 'child_of', message_id)]
idx = [msg.get('id') for msg in messages].index(message_id) + 1
# messages.append(_get_expandable(exp_domain, nb, message_id, id_min))
messages.insert(idx, _get_expandable(exp_domain, nb, message_id, id_min))
messages.insert(idx, _get_expandable(exp_domain, nb, message_id, False))
return True

View File

@ -158,7 +158,6 @@ openerp.mail = function (session) {
this.author_id = datasets.author_id || [this.session.uid],
this.attachment_ids = datasets.attachment_ids || [],
this.partner_ids = datasets.partner_ids || [];
this.nb_messages = datasets.nb_messages || false;
this._date = datasets.date;
this.format_data();
@ -218,7 +217,7 @@ openerp.mail = function (session) {
*/
get_childs: function (nb_thread_level) {
var res=[];
if (arguments[1]) res.push(this);
if (arguments[1] && this.id) res.push(this);
if ((isNaN(nb_thread_level) || nb_thread_level>0) && this.thread) {
_(this.thread.messages).each(function (val, key) {
res = res.concat( val.get_childs((isNaN(nb_thread_level) ? undefined : nb_thread_level-1), true) );
@ -539,7 +538,8 @@ openerp.mail = function (session) {
init: function (parent, datasets, options) {
this._super(parent, datasets, options);
this.type = 'expandable';
this.max_limit = this.id < 0 || false;
this.max_limit = datasets.max_limit;
this.nb_messages = datasets.nb_messages;
this.flag_used = false;
},
@ -802,13 +802,12 @@ openerp.mail = function (session) {
// inside the inbox, when the user mark a message as read/done, don't apply this value
// for the stared/favorite message
if (this.options.view_inbox && read_value) {
var messages = _.filter(messages, function (val) { return !val.is_favorite; });
var messages = _.filter(messages, function (val) { return !val.is_favorite && val.id; });
if (!messages.length) {
this.check_for_rerender();
return false;
}
}
var message_ids = _.map(messages, function (val) { return val.id; });
this.ds_notification.call('set_message_read', [message_ids, read_value, this.context])
@ -1602,7 +1601,7 @@ openerp.mail = function (session) {
'show_read_unread_button': true,
'show_compose_message': true,
'show_compact_message': this.context.view_mailbox ? false : 1,
'view_inbox': this.context.view_inbox ? false : true,
'view_inbox': !!this.context.view_inbox,
})
);
return this.root.replace(this.$('.oe_mail-placeholder'));