diff options
| author | Christophe Simonis <chs@odoo.com> | 2015-12-10 13:05:58 +0100 |
|---|---|---|
| committer | Christophe Simonis <chs@odoo.com> | 2015-12-10 13:05:58 +0100 |
| commit | 82a495eed52a9f42e5b88caa52c20a85f8d81ce3 (patch) | |
| tree | 6c5e8cc0247d5fe08d24e9abae38fe353fbebc56 /addons/mail/static/src/js/chatter.js | |
| parent | 0bc2ddae784bf80c4c809d8b7f6d642d576f92a1 (diff) | |
| parent | 4022493c0b85f966e499b6c03ac7cce5556f15e6 (diff) | |
[MERGE] forward port of branch saas-7 up to 4022493
Diffstat (limited to 'addons/mail/static/src/js/chatter.js')
| -rw-r--r-- | addons/mail/static/src/js/chatter.js | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index d29312cf6f6..c99e958929e 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -189,14 +189,9 @@ var Followers = form_common.AbstractField.extend({ }, fetch_followers: function (value_) { - var self = this; this.value = value_ || []; return ajax.jsonRpc('/mail/read_followers', 'call', {'follower_ids': this.value}) - .then(function (followers) { - self.trigger('followers_update', followers); - self.display_followers(followers); - self.fetch_generic(); - }) + .then(this.proxy('display_followers'), this.proxy('fetch_generic')) .then(this.proxy('display_buttons')) .then(this.proxy('fetch_subtypes')); }, @@ -237,6 +232,7 @@ var Followers = form_common.AbstractField.extend({ display_followers: function (records) { var self = this; this.followers = records || this.followers; + this.trigger('followers_update', this.followers); // clean and display title var $followers_list = this.$('.o_followers_list').empty(); @@ -272,25 +268,25 @@ var Followers = form_common.AbstractField.extend({ } }, - /** Fetch subtypes, only if current user is follower */ + /** Fetch subtypes, only if current user is follower or if follower_id is given, i.e. if + * the current user is editing the subtypes of another follower + */ fetch_subtypes: function (follower_id) { var self = this; var dialog = false; if (follower_id) { dialog = true; - } - else { + } else { this.$('.o_subtypes_list ul').empty(); - if (! this.message_is_follower) { + if (!this.message_is_follower) { this.$('.o_subtypes_list > .dropdown-toggle').attr('disabled', true); return; - } - else { + } else { this.$('.o_subtypes_list > .dropdown-toggle').attr('disabled', false); } } - if (this.follower_id) { + if (this.follower_id || follower_id) { return ajax.jsonRpc('/mail/read_subscription_data', 'call', { res_model: this.view.model, res_id: this.view.datarecord.id, @@ -305,7 +301,6 @@ var Followers = form_common.AbstractField.extend({ /** Display subtypes: {'name': default, followed} */ display_subtypes:function (data, dialog) { - var self = this; var old_parent_model; var $list; if (dialog) { @@ -316,10 +311,10 @@ var Followers = form_common.AbstractField.extend({ $list.empty(); this.data_subtype = data; - this.records_length = $.map(data, function(value, index) { return index; }).length; + this.records_length = _.map(data, function(value, index) { return index; }).length; if (this.records_length > 1) { - self.display_followers(); + this.display_followers(); } _.each(data, function (record) { @@ -674,6 +669,8 @@ var ChatterComposer = ChatComposer.extend({ }, { on_close: function() { self.trigger('need_refresh'); + var parent = self.getParent(); + chat_manager.get_messages({model: parent.model, res_id: parent.res_id}); }, }); }); @@ -719,6 +716,7 @@ var Chatter = form_common.AbstractField.extend({ display_order: ChatThread.ORDER.DESC, display_document_link: false, display_needactions: false, + squash_close_messages: false, }); this.thread.on('load_more_messages', this, this.load_more_messages); this.thread.on('toggle_star_status', this, function (message_id) { @@ -741,15 +739,18 @@ var Chatter = form_common.AbstractField.extend({ fetch_and_render_thread: function (ids, options) { var self = this; - return chat_manager.fetch_messages(ids, options).then(function (raw_messages) { + options = options || {}; + options.ids = ids; + return chat_manager.get_messages(options).then(function (raw_messages) { self.thread.render(raw_messages, {display_load_more: raw_messages.length < ids.length}); }); }, on_post_message: function (message) { var self = this; + var options = {model: this.model, res_id: this.res_id}; chat_manager - .post_message_in_document(this.model, this.res_id, message) + .post_message(message, options) .then(function () { self.close_composer(); if (message.partner_ids.length) { @@ -781,12 +782,7 @@ var Chatter = form_common.AbstractField.extend({ on_channel_redirect: function (channel_id) { var self = this; - var def; - var channel = chat_manager.get_channel(channel_id); - // If not registered to 'channel' yet, do it - if (!channel) { - def = chat_manager.join_channel(channel_id); - } + var def = chat_manager.join_channel(channel_id); $.when(def).then(function () { // Execute Discuss client action with 'channel' as default channel var discuss_ids = chat_manager.get_discuss_ids(); |
