[MERGE] changes from chm

bzr revid: fva@openerp.com-20121030125308-5eqhp2h26a9fn19j
This commit is contained in:
Frédéric van der Essen 2012-10-30 13:53:08 +01:00
commit 6734d50637
4 changed files with 106 additions and 128 deletions

View File

@ -59,21 +59,24 @@
<field name="type"/>
<field name="author_id"/>
<field name="partner_ids"/>
<filter string="Read"
name="message_read" help="Show messages to read"
domain="[('to_read', '=', False)]"/>
<filter string="Unread"
name="message_unread" help="Show messages to read"
domain="[('to_read', '=', True)]"/>
<filter string="Comments"
name="comments" help="Comments"
domain="[('type', '=', 'comment')]"/>
<filter string="Has attachments"
name="attachments"
domain="[('attachment_ids', '!=', False)]"/>
<filter string="Notifications"
name="notifications" help="Notifications"
domain="[('type', '=', 'notification')]"/>
<filter string="Emails"
name="emails" help="Emails"
domain="[('type', '=', 'email')]"/>
<filter string="Has attachments"
name="attachments"
domain="[('attachment_ids', '!=', False)]"/>
</search>
</field>
</record>
@ -84,7 +87,6 @@
<field name="view_type">form</field>
<field name="view_mode">tree,form</field>
<field name="search_view_id" ref="view_message_search"/>
<field name="context">{'search_default_to_read_message':True}</field>
</record>
<!-- Add menu entry in Settings/Email -->

View File

@ -5,35 +5,35 @@
<field name="name">Inbox</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]), ('to_read', '=', True)],
'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'inbox'} }&quot;"/>
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<record id="action_mail_to_me_feeds" model="ir.actions.client">
<field name="name">To: me</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('partner_ids.user_ids', 'in', [uid]), ('to_read', '=', True), ('author_id.user_ids', 'in', [uid])],
'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'inbox'} }&quot;"/>
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<record id="action_mail_star_feeds" model="ir.actions.client">
<field name="name">Favorites</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('favorite_user_ids.user_ids', 'in', [uid])],
'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'stared'} }&quot;"/>
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<record id="action_mail_archives_feeds" model="ir.actions.client">
<field name="name">Archives</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('notification_ids.partner_id.user_ids', 'in', [uid]), ('to_read', '=', False)],
'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'archives'} }&quot;"/>
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<record id="action_mail_sent_feeds" model="ir.actions.client">
<field name="name">Sent</field>
<field name="tag">mail.wall</field>
<field name="params" eval="&quot;{'domain': [('author_id.user_ids', 'in', [uid])],
'context': {'default_model': 'res.users', 'default_res_id': uid, 'typeof_thread': 'send'} }&quot;"/>
'context': {'default_model': 'res.users', 'default_res_id': uid} }&quot;"/>
</record>
<!-- MENU -->

View File

@ -145,15 +145,16 @@ openerp.mail = function (session) {
this.show_compact_message = false;
// data of this compose message
this.attachment_ids = [];
this.id = datasets.id;
this.model = datasets.model;
this.res_model = datasets.res_model;
this.is_private = datasets.is_private || false;
this.partner_ids = datasets.partner_ids || [];
this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
this.thread_level = datasets.thread_level;
this.attachment_ids = [];
this.parent_thread= parent.messages!= undefined ? parent : false;
this.avatar = mail.ChatterUtils.get_image(this.session, 'res.users', 'image_small', this.session.uid);
this.ds_attachment = new session.web.DataSetSearch(this, 'ir.attachment');
this.show_delete_attachment = true;
@ -439,7 +440,7 @@ openerp.mail = function (session) {
this.type = 'expandable',
this.max_limit = this.id < 0 || false,
this.flag_used = false,
this.parent_thread= parent.messages!= undefined ? parent : this.options._parents[0];
this.parent_thread= parent.messages!= undefined ? parent : this.options.root_thread;
},
@ -529,8 +530,8 @@ openerp.mail = function (session) {
* display before having a "show more" link; note that the text
* will not be truncated if it does not have 110% of the parameter
* @param {Boolean} [show_record_name]
*... @param {int} [show_reply_button] number thread level to display the reply button
*... @param {int} [show_read_unread_button] number thread level to display the read/unread button
*... @param {boolean} [show_reply_button] display the reply button
*... @param {boolean} [show_read_unread_button] display the read/unread button
*/
init: function (parent, datasets, context) {
this._super(parent);
@ -543,7 +544,7 @@ openerp.mail = function (session) {
default_parent_id: false }, context || {});
// record options
this.options = datasets.options;
this.options = datasets.options || {};
// data of this message
this.id = datasets.id || -1,
@ -566,12 +567,8 @@ openerp.mail = function (session) {
this.attachment_ids = datasets.attachment_ids || [],
this._date = datasets.date;
this.show_reply_button = this.options.show_compose_message && this.options.show_reply_button > this.thread_level;
this.show_read_unread_button = this.options.show_read_unread_button > this.thread_level;
// record options and data
this.parent_thread= parent.messages!= undefined ? parent : this.options._parents[0];
this.parent_thread= parent.messages!= undefined ? parent : this.options.root_thread;
this.thread = false;
if ( this.id > 0 ) {
@ -731,6 +728,15 @@ openerp.mail = function (session) {
return false;
},
/* Check if the message must be destroy and detroy it
* @param {callback} apply function
*/
check_for_destroy: function () {
var domain = mail.ChatterUtils.expand_domain( this.options.root_thread.domain ).concat([["id", "=", this.id]]);
this.parent_thread.ds_message.call('message_read', [undefined, domain, [], 0, this.context, this.parent_thread.id])
.then( _.bind(function (record) { if (!record || !record.length) this.animated_destroy(150); }, this) );
},
/*The selected thread and all childs (messages/thread) became read
* @param {object} mouse envent
*/
@ -738,15 +744,12 @@ openerp.mail = function (session) {
event.stopPropagation();
var self=this;
if ( (this.to_read && this.options.typeof_thread == 'inbox') ||
(!this.to_read && this.options.typeof_thread == 'archives')) {
this.animated_destroy(150);
}
// if this message is read, all childs message display is read
this.ds_notification.call('set_message_read', [ [this.id].concat( this.get_child_ids() ) , this.to_read, this.context]).pipe(function () {
self.$el.removeClass(self.to_read ? 'oe_msg_unread':'oe_msg_read').addClass(self.to_read ? 'oe_msg_read':'oe_msg_unread');
self.to_read = !self.to_read;
// check if the message must be display
self.check_for_destroy();
});
return false;
},
@ -764,8 +767,8 @@ openerp.mail = function (session) {
// goto the wall thread for launch browse
if (!options._go_thread_wall) {
options._go_thread_wall = true;
for (var i in this.options._parents[0].messages) {
var res=this.options._parents[0].messages[i].browse_message(options);
for (var i in this.options.root_thread.messages) {
var res=this.options.root_thread.messages[i].browse_message(options);
if (res) return res;
}
}
@ -800,12 +803,12 @@ openerp.mail = function (session) {
*/
on_vote: function (event) {
event.stopPropagation();
var self=this;
return this.ds_message.call('vote_toggle', [[self.id]]).pipe(function (vote) {
self.has_voted = vote;
self.vote_nb += self.has_voted ? 1 : -1;
self.display_vote();
});
return this.ds_message.call('vote_toggle', [[this.id]]).pipe(
_.bind(function (vote) {
this.has_voted = vote;
this.vote_nb += this.has_voted ? 1 : -1;
this.display_vote();
}, this));
return false;
},
@ -813,10 +816,9 @@ openerp.mail = function (session) {
* Display the render of this message's vote
*/
display_vote: function () {
var self = this;
var vote_element = session.web.qweb.render('mail.thread.message.vote', {'widget': self});
self.$(".oe_msg_vote:first").remove();
self.$(".oe_mail_vote_count:first").replaceWith(vote_element);
var vote_element = session.web.qweb.render('mail.thread.message.vote', {'widget': this});
this.$(".oe_msg_footer:first .oe_mail_vote_count").remove();
this.$(".oe_msg_footer:first .oe_msg_vote").replaceWith(vote_element);
},
/**
@ -832,9 +834,8 @@ openerp.mail = function (session) {
button.addClass('oe_starred');
} else {
button.removeClass('oe_starred');
if ( self.options.typeof_thread == 'stared' ) {
self.animated_destroy(150);
}
// check if the message must be display
self.check_for_destroy();
}
});
return false;
@ -880,9 +881,6 @@ openerp.mail = function (session) {
* @param {Object} [thread]
* @param {int} [display_indented_thread] number thread level to indented threads.
* other are on flat mode
* @param {Select} [typeof_thread] inbox/archives/stared/sent
* type of thread and option for user application like animate
* destroy for read/unread
* @param {Array} [parents] liked with the parents thread
* use with browse, fetch... [O]= top parent
*/
@ -895,7 +893,7 @@ openerp.mail = function (session) {
default_parent_id: false }, options.context || {});
this.options = options.options;
this.options._parents = (options.options._parents != undefined ? options.options._parents : []).concat( [this] );
this.options.root_thread = (options.options.root_thread != undefined ? options.options.root_thread : this);
// record options and data
this.parent_message= parent.thread!= undefined ? parent : false ;
@ -949,16 +947,14 @@ openerp.mail = function (session) {
*/
on_scroll: function (event) {
if (event)event.stopPropagation();
this.$('.oe_msg_expandable:last');
var message = this.messages[this.messages.length-1];
if (message && message.type=="expandable" && message.max_limit) {
var pos = message.$el.position();
$last = this.$('> .oe_msg_expandable:last');
if ($last.hasClass('oe_max_limit')) {
var pos = $last.position();
if (pos.top) {
/* bottom of the screen */
var bottom = $(window).scrollTop()+$(window).height()+200;
if (bottom > pos.top) {
message.on_expandable();
$last.find('.oe_msg_fetch_more').click();
}
}
}
@ -1032,7 +1028,7 @@ openerp.mail = function (session) {
// goto the wall thread for launch browse
if (!options._go_thread_wall) {
options._go_thread_wall = true;
return this.options._parents[0].browse_thread(options);
return this.options.root_thread.browse_thread(options);
}
if (this.id==options.id) {
@ -1066,8 +1062,8 @@ openerp.mail = function (session) {
* @return message object
*/
browse_message: function (options) {
if (this.options._parents[0].messages[0])
return this.options._parents[0].messages[0].browse_message(options);
if (this.options.root_thread.messages[0])
return this.options.root_thread.messages[0].browse_message(options);
},
/**
@ -1367,15 +1363,13 @@ openerp.mail = function (session) {
* @param {Object} [context] context of the thread. It should
* contain at least default_model, default_res_id. Please refer to
* the compose_message widget for more information about it.
* ... @param {Select} [typeof_thread=(mail|stared|archives|send|other)]
* options for destroy message when the user click on a button
* @param {Object} [options]
*... @param {Number} [truncate_limit=250] number of character to
* display before having a "show more" link; note that the text
* will not be truncated if it does not have 110% of the parameter
*... @param {Boolean} [show_record_name] display the name and link for do action
*... @param {int} [show_reply_button] number thread level to display the reply button
*... @param {int} [show_read_unread_button] number thread level to display the read/unread button
*... @param {boolean} [show_reply_button] display the reply button
*... @param {boolean} [show_read_unread_button] display the read/unread button
*... @param {int} [display_indented_thread] number thread level to indented threads.
* other are on flat mode
*... @param {Boolean} [show_compose_message] allow to display the composer
@ -1392,10 +1386,9 @@ openerp.mail = function (session) {
this.search_results = {'domain': [], 'context': {}, 'groupby': {}};
this.options = _.extend({
'typeof_thread' : 'inbox',
'display_indented_thread' : -1,
'show_reply_button' : -1,
'show_read_unread_button' : -1,
'show_reply_button' : false,
'show_read_unread_button' : false,
'truncate_limit' : 250,
'show_record_name' : false,
'show_compose_message' : false,
@ -1407,12 +1400,6 @@ openerp.mail = function (session) {
if (this.display_indented_thread === false) {
this.display_indented_thread = -1;
}
if (this.show_reply_button === false) {
this.show_reply_button = -1;
}
if (this.show_read_unread_button === false) {
this.show_read_unread_button = -1;
}
},
@ -1451,11 +1438,10 @@ openerp.mail = function (session) {
},
bind_events: function () {
if (this.context['typeof_thread']!='other') {
$(document).scroll( this.thread.on_scroll );
$(window).resize( this.thread.on_scroll );
window.setTimeout( this.thread.on_scroll, 500 );
}
$(document).scroll( _.bind(this.thread.on_scroll, this.thread) );
$(window).resize( _.bind(this.thread.on_scroll, this.thread) );
this.$el.resize( _.bind(this.thread.on_scroll, this.thread) );
window.setTimeout( _.bind(this.thread.on_scroll, this.thread), 500 );
}
});
@ -1516,10 +1502,9 @@ openerp.mail = function (session) {
this.root = new mail.Widget(this, {
'domain' : domain,
'context' : this.options.context,
'typeof_thread': this.options.context['typeof_thread'] || 'other',
'display_indented_thread': -1,
'show_reply_button': 0,
'show_read_unread_button': -1,
'show_reply_button': false,
'show_read_unread_button': false,
'show_compose_message': show_compose_message,
'message_ids': message_ids,
'show_compact_message': true,
@ -1557,17 +1542,23 @@ openerp.mail = function (session) {
this.options = options || {};
this.options.domain = options.domain || [];
this.options.context = options.context || {};
this.search_results = {'domain': [], 'context': {}, 'groupby': {}}
this.ds_msg = new session.web.DataSetSearch(this, 'mail.message');
this.options.defaults = {};
for (var key in options.context) {
if(key.match(/^search_default_/)) {
this.options.defaults[key.replace(/^search_default_/, '')] = options.context[key];
}
}
},
start: function () {
this._super.apply(this, arguments);
var searchview_ready = this.load_searchview({}, false);
var thread_displayed = this.message_render();
this.options.domain = this.options.domain.concat(this.search_results['domain']);
this.load_searchview(this.options.defaults, false);
this.bind_events();
return $.when(searchview_ready, thread_displayed);
if(!this.searchview.has_defaults) {
this.message_render();
}
},
/**
@ -1577,10 +1568,14 @@ openerp.mail = function (session) {
*/
load_searchview: function (defaults, hidden) {
var self = this;
this.searchview = new session.web.SearchView(this, this.ds_msg, false, defaults || {}, hidden || false);
return this.searchview.appendTo(this.$('.oe_view_manager_view_search')).then(function () {
self.searchview.on('search_data', self, self.do_searchview_search);
});
var ds_msg = new session.web.DataSetSearch(self, 'mail.message');
self.searchview = new session.web.SearchView(self, ds_msg, false, defaults || {}, hidden || false);
self.searchview.appendTo(self.$('.oe_view_manager_view_search'))
.then(function () { self.searchview.on('search_data', self, self.do_searchview_search); });
if (this.searchview.has_defaults) {
this.searchview.ready.then(this.searchview.do_search);
}
return self.searchview
},
/**
@ -1597,10 +1592,11 @@ openerp.mail = function (session) {
contexts: contexts || [],
group_by_seq: groupbys || []
}).then(function (results) {
self.search_results['context'] = results.context;
self.search_results['domain'] = results.domain;
self.root.destroy();
return self.message_render();
if(self.root) {
$('<span class="oe_mail-placeholder"/>').insertAfter(self.root.$el);
self.root.destroy();
}
return self.message_render(results);
});
},
@ -1608,16 +1604,15 @@ openerp.mail = function (session) {
/**
*Create the root thread widget and display this object in the DOM
*/
message_render: function (search) {
var domain = this.options.domain.concat(this.search_results['domain']);
var context = _.extend(this.options.context, search&&search.search_results['context'] ? search.search_results['context'] : {});
message_render: function ( search ) {
var domain = this.options.domain.concat(search && search['domain'] ? search['domain'] : []);
var context = _.extend(this.options.context, search && search['context'] ? search['context'] : {});
this.root = new mail.Widget(this, {
'domain' : domain,
'context' : context,
'typeof_thread': context['typeof_thread'] || 'other',
'display_indented_thread': 1,
'show_reply_button': 10,
'show_read_unread_button': 11,
'show_reply_button': true,
'show_read_unread_button': true,
'show_compose_message': true,
'show_compact_message': false,
}
@ -1642,23 +1637,11 @@ openerp.mail = function (session) {
* Add a link on the top user bar for write a full mail
*/
session.web.ComposeMessageTopButton = session.web.Widget.extend({
template:'mail.compose_message.button_top_bar',
template:'mail.ComposeMessageTopButton',
init: function (parent, options) {
this._super.apply(this, options);
this.options = this.options || {};
this.options.domain = this.options.domain || [];
this.options.context = {
'default_model': false,
'default_res_id': 0,
'default_content_subtype': 'html',
};
},
start: function (parent, params) {
var self = this;
this.$el.on('click', 'button', self.on_compose_message );
this._super(parent, params);
start: function () {
this.$el.on('click', 'button', this.on_compose_message );
this._super();
},
on_compose_message: function (event) {
@ -1668,20 +1651,15 @@ openerp.mail = function (session) {
res_model: 'mail.compose.message',
view_mode: 'form',
view_type: 'form',
action_from: 'mail.ThreadComposeMessage',
views: [[false, 'form']],
target: 'new',
context: _.extend(this.options.context, {
'default_model': this.context.default_model,
'default_res_id': this.context.default_res_id,
'default_content_subtype': 'html',
}),
context: { 'default_content_subtype': 'html' },
};
session.client.action_manager.do_action(action);
},
});
session.web.UserMenu.include({
do_update: function(){
var self = this;

View File

@ -140,9 +140,7 @@
<td colspan="2">
<h2 class="oe_view_title">
<span class="oe_view_title_text">
News Feed
<t t-if="widget.options.res_model"> / </t>
<t t-if="widget.options.res_model" t-esc="widget.options.res_model"/>
Email box
</span>
</h2>
</td>
@ -197,9 +195,9 @@
<div class="oe_msg_center">
<div class='oe_msg_icons'>
<span class='oe_read' t-if="widget.show_read_unread_button"><a title="Read" class="oe_e">X</a></span>
<span class='oe_unread' t-if="widget.show_read_unread_button"><a title="Set back to unread" class="oe_e">v</a></span>
<span class='oe_reply' t-if="widget.show_reply_button"><a title="Reply" class="oe_e">(</a></span>
<span class='oe_read' t-if="widget.options.show_read_unread_button"><a title="Read" class="oe_e">X</a></span>
<span class='oe_unread' t-if="widget.options.show_read_unread_button"><a title="Set back to unread" class="oe_e">v</a></span>
<span class='oe_reply' t-if="widget.options.show_reply_button"><a title="Reply" class="oe_e">(</a></span>
<span t-attf-class="oe_star #{widget.is_favorite?'oe_starred':''}"><a title="Add To Favorites" class="oe_e">7</a></span>
</div>
<!-- message itself -->
@ -234,11 +232,12 @@
<!-- expandable message layout -->
<t t-name="mail.thread.expandable">
<div t-attf-class="oe_msg oe_msg_#{widget.type} #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} oe_msg_unread">
<div t-attf-class="oe_msg oe_msg_#{widget.type} #{widget.max_limit ? 'oe_max_limit' : ''} #{widget.thread_level and widget.options.display_indented_thread > -1 ? 'oe_msg_indented' : ''} oe_msg_unread">
<div class="oe_msg_content oe_msg_more_message">
<div class='oe_separator'></div>
<a t-if="widget.nb_messages &lt;= 0" class="oe_msg_fetch_more">show more message</a>
<a t-if="widget.nb_messages === 1" class="oe_msg_fetch_more">show one more message</a>
<a t-if="widget.nb_messages !== 1" class="oe_msg_fetch_more">show <t t-raw="widget.nb_messages" /> more messages</a>
<a t-if="widget.nb_messages &gt; 1" class="oe_msg_fetch_more">show <t t-raw="widget.nb_messages" /> more messages</a>
</div>
</div>
</t>
@ -247,7 +246,7 @@
mail.compose_message.button_top_bar
render of the button on the user bar for open wizard compose message
-->
<t t-name="mail.compose_message.button_top_bar">
<t t-name="mail.ComposeMessageTopButton">
<div title='Compose new Message' class="oe_topbar_item oe_topbar_compose_full_email">
<button class="oe_e">%</button>
</div>
@ -257,12 +256,11 @@
Template used to display Like/Unlike in a mail.message
-->
<span t-name="mail.thread.message.vote">
<span class="oe_mail_vote_count" t-if='widget.vote_nb > 0'>
<t t-raw='widget.vote_nb' />
<span class='oe_e'>8</span>
</span>
<a href='#' t-attf-class="oe_msg_vote">
<a href='#' class="oe_msg_vote">
<t t-if="!widget.has_voted">like</t>
<t t-if="widget.has_voted">unlike</t>
</a>