Skip to content

Commit

Permalink
[NEW] Livechat setting to customize ended conversation message (#10108)
Browse files Browse the repository at this point in the history
* Message of the conversation finished has been added.

* New setting added to display a message when the Livechat conversation has ended.

* Fix PR review.
  • Loading branch information
renatobecker authored and sampaiodiego committed Apr 17, 2018
1 parent 1f85615 commit cf6e741
Show file tree
Hide file tree
Showing 13 changed files with 50 additions and 12 deletions.
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@
"Content": "Content",
"Conversation": "Conversation",
"Conversation_closed": "Conversation closed: __comment__.",
"Conversation_finished_message": "Conversation Finished Message",
"Convert_Ascii_Emojis": "Convert ASCII to Emoji",
"Copied": "Copied",
"Copy": "Copy",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@
"Content": "Conteúdo",
"Conversation": "Conversa",
"Conversation_closed": "Chat encerrado: __comment__.",
"Conversation_finished_message": "Mensagem ao encerrar chat",
"Convert_Ascii_Emojis": "Converter ASCII para Emoji",
"Copied": "Copiado",
"Copy": "Cópia",
Expand Down
7 changes: 7 additions & 0 deletions packages/rocketchat-livechat/.app/client/lib/_livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ this.Livechat = new (class Livechat {
this._offlineSuccessMessage = new ReactiveVar(TAPi18n.__('Thanks_We_ll_get_back_to_you_soon'));
this._videoCall = new ReactiveVar(false);
this._transcriptMessage = new ReactiveVar('');
this._conversationFinishedMessage = new ReactiveVar('');
this._connecting = new ReactiveVar(false);
this._room = new ReactiveVar(null);
this._department = new ReactiveVar(null);
Expand Down Expand Up @@ -100,6 +101,9 @@ this.Livechat = new (class Livechat {
get transcriptMessage() {
return this._transcriptMessage.get();
}
get conversationFinishedMessage() {
return this._conversationFinishedMessage.get();
}
get department() {
return this._department.get();
}
Expand Down Expand Up @@ -161,6 +165,9 @@ this.Livechat = new (class Livechat {
set transcriptMessage(value) {
this._transcriptMessage.set(value);
}
set conversationFinishedMessage(value) {
this._conversationFinishedMessage.set(value);
}
set connecting(value) {
this._connecting.set(value);
}
Expand Down
7 changes: 0 additions & 7 deletions packages/rocketchat-livechat/.app/client/lib/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,6 @@ this.Commands = {
}
}
});
} else {
swal({
title: t('Chat_ended'),
type: 'success',
timer: 1000,
showConfirmButton: false
});
}
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ Template.livechatWindow.onCreated(function() {
Livechat.online = true;
Livechat.transcript = result.transcript;
Livechat.transcriptMessage = result.transcriptMessage;
Livechat.conversationFinishedMessage = result.conversationFinishedMessage;
}
Livechat.videoCall = result.videoCall;
Livechat.registrationForm = result.registrationForm;
Expand Down
2 changes: 1 addition & 1 deletion packages/rocketchat-livechat/.app/client/views/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Template.message.helpers({
case 'wm':
return t('Welcome', { user: this.u.username });
case 'livechat-close':
return t('Conversation_finished');
return (Livechat.conversationFinishedMessage) ? Livechat.conversationFinishedMessage : t('Conversation_finished');
// case 'rtc': return RocketChat.callbacks.run('renderRtcMessage', this);
default:
this.html = this.msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ <h2>{{_ "Settings"}}</h2>
<textarea class="preview-settings rc-input__element" name="offlineSuccessMessage" id="offlineSuccessMessage">{{offlineSuccessMessage}}</textarea>
</div>
</fieldset>
<fieldset>
<legend>{{_ "Conversation_finished"}}</legend>
<div class="input-line">
<label for="conversationFinishedMessage">{{_ "Conversation_finished_message"}}</label>
<textarea class="preview-settings rc-input__element" name="conversationFinishedMessage" id="conversationFinishedMessage">{{conversationFinishedMessage}}</textarea>
</div>
</fieldset>
<div class="submit">
<button class="button secondary reset-settings"><i class="icon-ccw"></i>{{_ "Reset"}}</button>
<button class="button primary save"><i class="icon-floppy"></i>{{_ "Save"}}</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ Template.livechatAppearance.helpers({
emailOffline() {
return Template.instance().offlineEmail.get();
},
conversationFinishedMessage() {
return Template.instance().conversationFinishedMessage.get();
},
sampleColor() {
if (Template.instance().previewState.get().indexOf('offline') !== -1) {
return Template.instance().colorOffline.get();
Expand Down Expand Up @@ -177,6 +180,7 @@ Template.livechatAppearance.onCreated(function() {
this.titleOffline = new ReactiveVar(null);
this.colorOffline = new ReactiveVar(null);
this.offlineEmail = new ReactiveVar(null);
this.conversationFinishedMessage = new ReactiveVar(null);

this.autorun(() => {
const setting = LivechatAppearance.findOne('Livechat_title');
Expand Down Expand Up @@ -218,6 +222,10 @@ Template.livechatAppearance.onCreated(function() {
const setting = LivechatAppearance.findOne('Livechat_offline_email');
this.offlineEmail.set(setting && setting.value);
});
this.autorun(() => {
const setting = LivechatAppearance.findOne('Livechat_conversation_finished_message');
this.conversationFinishedMessage.set(setting && setting.value);
});
});

Template.livechatAppearance.events({
Expand Down Expand Up @@ -260,6 +268,9 @@ Template.livechatAppearance.events({

const settingOfflineTitleColor = LivechatAppearance.findOne('Livechat_offline_title_color');
instance.colorOffline.set(settingOfflineTitleColor && settingOfflineTitleColor.value);

const settingConversationFinishedMessage = LivechatAppearance.findOne('Livechat_conversation_finished_message');
instance.conversationFinishedMessage.set(settingConversationFinishedMessage && settingConversationFinishedMessage.value);
},
'submit .rocket-form'(e, instance) {
e.preventDefault();
Expand Down Expand Up @@ -304,6 +315,10 @@ Template.livechatAppearance.events({
{
_id: 'Livechat_offline_email',
value: instance.$('#emailOffline').val()
},
{
_id: 'Livechat_conversation_finished_message',
value: s.trim(instance.conversationFinishedMessage.get())
}
];

Expand Down
8 changes: 8 additions & 0 deletions packages/rocketchat-livechat/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ Meteor.startup(function() {
RocketChat.settings.add('Livechat_registration_form', true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Show_preregistration_form' });
RocketChat.settings.add('Livechat_allow_switching_departments', true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Allow_switching_departments' });
RocketChat.settings.add('Livechat_show_agent_email', true, { type: 'boolean', group: 'Livechat', public: true, i18nLabel: 'Show_agent_email' });

RocketChat.settings.add('Livechat_conversation_finished_message', '', {
type: 'string',
group: 'Livechat',
public: true,
i18nLabel: 'Conversation_finished_message'
});

RocketChat.settings.add('Livechat_guest_count', 1, { type: 'int', group: 'Livechat' });

RocketChat.settings.add('Livechat_Room_Count', 1, {
Expand Down
3 changes: 2 additions & 1 deletion packages/rocketchat-livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ RocketChat.Livechat = {
'Jitsi_Enabled',
'Language',
'Livechat_enable_transcript',
'Livechat_transcript_message'
'Livechat_transcript_message',
'Livechat_conversation_finished_message'
]).forEach((setting) => {
settings[setting._id] = setting.value;
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Meteor.methods({
offlineSuccessMessage: null,
offlineUnavailableMessage: null,
displayOfflineForm: null,
videoCall: null
videoCall: null,
conversationFinishedMessage: null
};

const room = RocketChat.models.Rooms.findOpenByVisitorToken(visitorToken, {
Expand Down Expand Up @@ -67,6 +68,7 @@ Meteor.methods({
info.videoCall = initSettings.Livechat_videocall_enabled === true && initSettings.Jitsi_Enabled === true;
info.transcript = initSettings.Livechat_enable_transcript;
info.transcriptMessage = initSettings.Livechat_transcript_message;
info.conversationFinishedMessage = initSettings.Livechat_conversation_finished_message;

info.agentData = room && room[0] && room[0].servedBy && RocketChat.models.Users.getAgentInfo(room[0].servedBy._id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Meteor.methods({
'Livechat_offline_success_message',
'Livechat_offline_title',
'Livechat_offline_title_color',
'Livechat_offline_email'
'Livechat_offline_email',
'Livechat_conversation_finished_message'
];

const valid = settings.every((setting) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Meteor.publish('livechat:appearance', function() {
'Livechat_offline_success_message',
'Livechat_offline_title',
'Livechat_offline_title_color',
'Livechat_offline_email'
'Livechat_offline_email',
'Livechat_conversation_finished_message'
]
}
};
Expand Down

0 comments on commit cf6e741

Please sign in to comment.