From 4f9c9adf3715d25d766736179282ee3dccbea402 Mon Sep 17 00:00:00 2001 From: Aaron Bohy Date: Wed, 7 Oct 2015 10:43:38 +0200 Subject: [PATCH] [FIX] mail: chatter: various fixes - Add recipients as followers, and automatically refresh the follower's list (before this rev., one needed to reload the record to see the followes' list updated) - Don't display needactions on chatter's messages - Simplify buttons of suggested partner's dialog, as it should only offer two possibilities: Save or Cancel - Replace unnecessary t-raw's by t-esc's --- addons/mail/static/src/js/chat_manager.js | 1 + addons/mail/static/src/js/chatter.js | 19 ++++++++++++++----- addons/mail/static/src/xml/chatter.xml | 6 +++--- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/addons/mail/static/src/js/chat_manager.js b/addons/mail/static/src/js/chat_manager.js index 81a5275de94..6b42ddc9234 100644 --- a/addons/mail/static/src/js/chat_manager.js +++ b/addons/mail/static/src/js/chat_manager.js @@ -140,6 +140,7 @@ function post_document_message (model_name, res_id, data) { attachment_ids: data.attachment_ids, body: _.str.trim(data.content), content_subtype: data.content_subtype, + context: data.context, message_type: data.message_type, partner_ids: data.partner_ids, subtype: data.subtype, diff --git a/addons/mail/static/src/js/chatter.js b/addons/mail/static/src/js/chatter.js index c0d7d8afba6..8e256377d40 100644 --- a/addons/mail/static/src/js/chatter.js +++ b/addons/mail/static/src/js/chatter.js @@ -505,7 +505,6 @@ var ChatterComposer = ChatComposer.extend({ // update context message.context = _.defaults(self.context, { mail_post_autofollow: true, - mail_post_autofollow_partner_ids: partner_ids, }); def.resolve(message); }); @@ -617,6 +616,7 @@ var ChatterComposer = ChatComposer.extend({ default_email: parsed_email[1], }, title: _t("Please complete partner's informations"), + disable_multiple_selection: true, }).open(); dialog.on('closed', self, function () { deferred.resolve(); @@ -672,7 +672,6 @@ var ChatterComposer = ChatComposer.extend({ default_partner_ids: partner_ids, default_is_log: self.options.is_log, mail_post_autofollow: true, - mail_post_autofollow_partner_ids: partner_ids, }; if (self.context.default_model && self.context.default_res_id) { @@ -723,14 +722,15 @@ var Chatter = form_common.AbstractField.extend({ var self = this; // Move the follower's widget (if any) inside the chatter - var followers = this.field_manager.fields.message_follower_ids; - if (followers) { - this.$('.o_chatter_topbar').append(followers.$el); + this.followers = this.field_manager.fields.message_follower_ids; + if (this.followers) { + this.$('.o_chatter_topbar').append(this.followers.$el); } this.thread = new ChatThread(this, { display_order: ChatThread.ORDER.DESC, display_document_link: false, + display_needactions: false, }); this.thread.on('load_more_messages', this, this.load_more_messages); this.thread.on('toggle_star_status', this, function (message_id) { @@ -759,6 +759,9 @@ var Chatter = form_common.AbstractField.extend({ .post_message_in_document(this.model, this.res_id, message) .then(function () { self.close_composer(); + if (message.partner_ids.length) { + self.refresh_followers(); // refresh followers' list + } }) .fail(function () { // todo: display notification @@ -823,6 +826,11 @@ var Chatter = form_common.AbstractField.extend({ // fetch and render messages of current document return this.fetch_and_render_thread(this.msg_ids); }, + refresh_followers: function () { + if (this.followers) { + this.followers.read_value(); + } + }, // composer toggle on_open_composer_new_message: function () { this.open_composer(); @@ -846,6 +854,7 @@ var Chatter = form_common.AbstractField.extend({ old_composer.destroy(); } self.composer.on('post_message', self, self.on_post_message); + self.composer.on('need_refresh', self, self.refresh_followers); }); }, diff --git a/addons/mail/static/src/xml/chatter.xml b/addons/mail/static/src/xml/chatter.xml index 51b0fc78eed..72a1c7aaeae 100644 --- a/addons/mail/static/src/xml/chatter.xml +++ b/addons/mail/static/src/xml/chatter.xml @@ -19,7 +19,7 @@ @@ -30,7 +30,7 @@ To: Followers of - + "" this document @@ -157,7 +157,7 @@ t-att-id="'input_mail_followers_subtype_'+record.id+(dialog ? '_in_dialog': '')" t-att-data-id="record.id" t-att-name="record.name" class="o_subtype_checkbox"/> - +