summaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorChristophe Matthieu <chm@openerp.com>2012-11-05 11:04:44 +0100
committerChristophe Matthieu <chm@openerp.com>2012-11-05 11:04:44 +0100
commit1db87cc080f79121dbb7bc6493f170fdd0c17f2b (patch)
treec09cb254f02a63cd2f62c631c42382df039a868e /addons
parent6ecbae42803033534b8b27fb818290c6b30c1e48 (diff)
[IMP] mail: change check_for_destroy method js into check_for_rerender with rerender option
bzr revid: chm@openerp.com-20121105100444-yozpfk4xagf8siau
Diffstat (limited to 'addons')
-rw-r--r--addons/mail/mail_thread_view.xml7
-rw-r--r--addons/mail/static/src/js/mail.js56
2 files changed, 39 insertions, 24 deletions
diff --git a/addons/mail/mail_thread_view.xml b/addons/mail/mail_thread_view.xml
index db33a06bd61..5e8cb69f146 100644
--- a/addons/mail/mail_thread_view.xml
+++ b/addons/mail/mail_thread_view.xml
@@ -15,12 +15,7 @@
'read_action': 'read', }&quot;"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
- Click to define a new sales tag.
- </p><p>
- Create specific tags that fit your company's activities
- to better classify and analyse your leads and opportunities.
- Such categories could for instance reflect your product
- structure or the different types of sales you do.
+ There are no message in your mailbox for this search.
</p>
</field>
</record>
diff --git a/addons/mail/static/src/js/mail.js b/addons/mail/static/src/js/mail.js
index cd01d7242ac..b4ae809d4ca 100644
--- a/addons/mail/static/src/js/mail.js
+++ b/addons/mail/static/src/js/mail.js
@@ -173,6 +173,8 @@ openerp.mail = function (session) {
else {
this.options.show_read = this.to_read;
this.options.show_unread = !this.to_read;
+ this.options.rerender = true;
+ this.options.toggle_read = true;
}
}
this.parent_thread = parent.messages != undefined ? parent : this.options.root_thread;
@@ -735,13 +737,26 @@ openerp.mail = function (session) {
return false;
},
- /* Check if the message must be destroy and detroy it
+ /* Check if the message must be destroy and detroy it or check for re render widget
* @param {callback} apply function
*/
- check_for_destroy: function () {
+ check_for_rerender: 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) );
+ return 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);
+
+ } else if (this.options.rerender) {
+
+ this.renderElement();
+ this.start();
+
+ }
+
+ }, this) );
},
on_message_read: function (event) {
@@ -759,15 +774,16 @@ openerp.mail = function (session) {
*/
on_message_read_unread: function (read_value) {
var self = this;
- // TDE note: this does not seem to work, try on demo data
var message_ids = [this.id].concat(this.get_child_ids());
this.ds_notification.call('set_message_read', [message_ids, read_value, this.context])
.then(function () {
- /* TDE note: not very understandable -> just toggle the buttons if necessary */
- // 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 = read_value;
- // check if the message must be display
- self.check_for_destroy();
+ self.to_read = !read_value;
+ if (self.options.toggle_read) {
+ self.options.show_read = self.to_read;
+ self.options.show_unread = !self.to_read;
+ }
+ // check if the message must be display, destroy or rerender
+ self.check_for_rerender();
});
return false;
},
@@ -808,12 +824,18 @@ openerp.mail = function (session) {
* @return array of id
*/
get_child_ids: function () {
- var res=[]
- if (arguments[0]) res.push(this.id);
+ return _.map(this.get_childs(), function (val) { return val.id; });
+ },
+
+ /* get all child message linked.
+ * @return array of message object
+ */
+ get_childs: function () {
if (this.thread) {
- res = res.concat( this.thread.get_child_ids(true) );
+ return _.map(this.thread.get_childs(), function (val) {return val.parent_message;});
+ } else {
+ return [];
}
- return res;
},
/**
@@ -855,7 +877,7 @@ openerp.mail = function (session) {
} else {
button.removeClass('oe_starred');
// check if the message must be display
- self.check_for_destroy();
+ self.check_for_rerender();
}
});
return false;
@@ -1005,9 +1027,7 @@ openerp.mail = function (session) {
* @return array of id
*/
get_child_ids: function () {
- var res=[];
- _(this.get_childs()).each(function (val, key) { res.push(val.id); });
- return res;
+ return _.map(this.get_childs(), function (val) { return val.id; });
},
/* get all child message/thread linked.