From f15a4a31cf499688405828e2a46cf7fdc3d98020 Mon Sep 17 00:00:00 2001 From: David Beguin Date: Fri, 27 Sep 2019 15:05:18 +0000 Subject: [PATCH] [FIX] livechat : do not close livechat after feedback-rating, positive or negative Since there is now a possibility for the user to ask a copy of the conversation, livechat window should not be closed after feedback, to let the user choose to receive a copy. The behaviour was no aligned between positive and neutral/negative feedback. Before, when sending a positive rating, the rating was not sent as a message on the channel and the window didn't close. But for neutral/negative feedback, the window was sending the rating as a message on the channel but the chatter closed immediately. Now, the rating is sent as a message for any type of rating. If this is a neutral / negative rating, the reason field appears. After sending the reason, the window stays opened. Task ID: 2076656 PR #37511 --- .../im_livechat/static/src/js/im_livechat.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/addons/im_livechat/static/src/js/im_livechat.js b/addons/im_livechat/static/src/js/im_livechat.js index 182dd403954..cc22507b457 100644 --- a/addons/im_livechat/static/src/js/im_livechat.js +++ b/addons/im_livechat/static/src/js/im_livechat.js @@ -449,23 +449,20 @@ var Feedback = Widget.extend({ * @private * @param {Object} options */ - _sendFeedback: function (options) { + _sendFeedback: function (reason) { var self = this; var args = { uuid: this._livechat.getUUID(), rate: this.rating, - reason : options.reason + reason: reason, }; this.dp.add(session.rpc('/im_livechat/feedback', args)).then(function () { - if (options.close) { - var emoji = RATING_TO_EMOJI[self.rating] || "??" ; - var content = _.str.sprintf(_t("Rating: %s"), emoji); - if (options.reason) { - content += " \n" + options.reason; - } - self.trigger('send_message', { content: content }); - self.trigger('feedback_sent'); // will close the chat + var emoji = RATING_TO_EMOJI[self.rating] || "??" ; + var content = _.str.sprintf(_t("Rating: %s"), emoji); + if (reason) { + content += " \n" + reason; } + self.trigger('send_message', { content: content }); }); }, /** @@ -492,9 +489,10 @@ var Feedback = Widget.extend({ * @private */ _onClickSend: function () { + this.$('.o_livechat_rating_reason').hide(); this._showThanksMessage(); if (_.isNumber(this.rating)) { - this._sendFeedback({ reason: this.$('textarea').val(), close: true }); + this._sendFeedback(this.$('textarea').val()); } }, /** @@ -512,8 +510,8 @@ var Feedback = Widget.extend({ } else { this.$('.o_livechat_rating_reason').hide(); this._showThanksMessage(); + this._sendFeedback(); } - this._sendFeedback({ close: false }); }, /** * @private