[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
This commit is contained in:
David Beguin
2019-09-30 08:07:41 +00:00
parent 8de9ce5f7a
commit f15a4a31cf
+10 -12
View File
@@ -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