Skip to content

Commit

Permalink
[FIX] mail: enable composer after message sent
Browse files Browse the repository at this point in the history
c5dc0b2 disabled send button on composer sent.

But this is only needed for chatter composer, other composers directly
send the message and are not refreshed asynchronously.

So for other composer, the send button worked one time but then was
disabled and the only way to sent was ENTER (on basic composer) or
CTRL+ENTER (on extended composer).

With this fix, disabling the button is done only for chatter composer.

11.0 backport of 12.0 odoo#28474

issue found when checking opw-1904029
closes odoo#28506
  • Loading branch information
nle-odoo committed Nov 8, 2018
1 parent 622eb6b commit fc70c35
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
15 changes: 15 additions & 0 deletions addons/mail/static/src/js/chatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,18 @@ var Chatter = Widget.extend(chat_mixin, {
this.composer.clear_composer();
}
},
/**
* @private
*/
_disableComposer: function () {
this.$(".o_composer_button_send").prop('disabled', true);
},
/**
* @private
*/
_enableComposer: function () {
this.$(".o_composer_button_send").prop('disabled', false);
},
_openComposer: function (options) {
var self = this;
var old_composer = this.composer;
Expand Down Expand Up @@ -156,11 +168,14 @@ var Chatter = Widget.extend(chat_mixin, {
self.composer.focus();
}
self.composer.on('post_message', self, function (message) {
self._disableComposer();
self.fields.thread.postMessage(message).then(function () {
self._closeComposer(true);
if (self.postRefresh === 'always' || (self.postRefresh === 'recipients' && message.partner_ids.length)) {
self.trigger_up('reload');
}
}).fail(function () {
self._enableComposer();
});
});
self.composer.on('need_refresh', self, self.trigger_up.bind(self, 'reload'));
Expand Down
3 changes: 0 additions & 3 deletions addons/mail/static/src/js/composer.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,13 +479,10 @@ var BasicComposer = Widget.extend(chat_mixin, {
},

send_message: function () {
var $button = this.$('.o_composer_button_send');

if (this.is_empty() || !this.do_check_attachment_upload()) {
return;
}

$button.prop('disabled', true);
clearTimeout(this.canned_timeout);
var self = this;
this.preprocess_message().then(function (message) {
Expand Down

0 comments on commit fc70c35

Please sign in to comment.