Skip to content

Commit

Permalink
[NEW] - Add setting to request a comment when closing Livechat room (#…
Browse files Browse the repository at this point in the history
…13983)

* Fixed #12428

* Refactor code

* Updated translation string
  • Loading branch information
knrt10 authored and renatobecker committed Apr 3, 2019
1 parent ab3faad commit f2129a7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
34 changes: 22 additions & 12 deletions app/livechat/client/views/app/tabbar/visitorInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ReactiveVar } from 'meteor/reactive-var';
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Session } from 'meteor/session';
import { Template } from 'meteor/templating';
import { TAPi18n } from 'meteor/tap:i18n';
import { modal } from '../../../../../ui-utils';
import { ChatRoom, Rooms, Subscriptions } from '../../../../../models';
import { settings } from '../../../../../settings';
Expand Down Expand Up @@ -171,6 +172,25 @@ Template.visitorInfo.events({
'click .close-livechat'(event) {
event.preventDefault();

const closeRoom = (comment) => Meteor.call('livechat:closeRoom', this.rid, comment, function(error/* , result*/) {
if (error) {
return handleError(error);
}
modal.open({
title: t('Chat_closed'),
text: t('Chat_closed_successfully'),
type: 'success',
timer: 1000,
showConfirmButton: false,
});
});

if (!settings.get('Livechat_request_comment_when_closing_conversation')) {
const comment = TAPi18n.__('Chat_closed_by_agent');
return closeRoom(comment);
}

// Setting for Ask_for_conversation_finished_message is set to true
modal.open({
title: t('Closing_chat'),
type: 'input',
Expand All @@ -188,18 +208,8 @@ Template.visitorInfo.events({
return false;
}

Meteor.call('livechat:closeRoom', this.rid, inputValue, function(error/* , result*/) {
if (error) {
return handleError(error);
}
modal.open({
title: t('Chat_closed'),
text: t('Chat_closed_successfully'),
type: 'success',
timer: 1000,
showConfirmButton: false,
});
});
return closeRoom(inputValue);

});
},

Expand Down
7 changes: 7 additions & 0 deletions app/livechat/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ Meteor.startup(function() {
settings.add('Livechat_allow_switching_departments', true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Allow_switching_departments' });
settings.add('Livechat_show_agent_email', true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Show_agent_email' });

settings.add('Livechat_request_comment_when_closing_conversation', true, {
type: 'boolean',
group: 'Livechat',
public: true,
i18nLabel: 'Request_comment_when_closing_conversation',
});

settings.add('Livechat_conversation_finished_message', '', {
type: 'string',
group: 'Livechat',
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,7 @@
"Channels_list": "List of public channels",
"Chat_button": "Chat button",
"Chat_closed": "Chat closed",
"Chat_closed_by_agent": "Chat closed by agent",
"Chat_closed_successfully": "Chat closed successfully",
"Chat_Now": "Chat Now",
"Chat_window": "Chat window",
Expand Down Expand Up @@ -2394,6 +2395,7 @@
"Report_sent": "Report sent",
"Report_this_message_question_mark": "Report this message?",
"Reporting": "Reporting",
"Request_comment_when_closing_conversation": "Request comment when closing conversation",
"Require_all_tokens": "Require all tokens",
"Require_any_token": "Require any token",
"Require_password_change": "Require password change",
Expand Down

0 comments on commit f2129a7

Please sign in to comment.