[NEW] Livechat setting to customize ended conversation message (#10108)

* Message of the conversation finished has been added.

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

* Fix PR review.
pull/10485/head
Renato Becker 8 years ago committed by Diego Sampaio
parent 1f85615677
commit cf6e741d32
  1. 1
      packages/rocketchat-i18n/i18n/en.i18n.json
  2. 1
      packages/rocketchat-i18n/i18n/pt.i18n.json
  3. 7
      packages/rocketchat-livechat/.app/client/lib/_livechat.js
  4. 7
      packages/rocketchat-livechat/.app/client/lib/commands.js
  5. 1
      packages/rocketchat-livechat/.app/client/views/livechatWindow.js
  6. 2
      packages/rocketchat-livechat/.app/client/views/message.js
  7. 7
      packages/rocketchat-livechat/client/views/app/livechatAppearance.html
  8. 15
      packages/rocketchat-livechat/client/views/app/livechatAppearance.js
  9. 8
      packages/rocketchat-livechat/config.js
  10. 3
      packages/rocketchat-livechat/server/lib/Livechat.js
  11. 4
      packages/rocketchat-livechat/server/methods/getInitialData.js
  12. 3
      packages/rocketchat-livechat/server/methods/saveAppearance.js
  13. 3
      packages/rocketchat-livechat/server/publications/livechatAppearance.js

@ -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",

@ -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",

@ -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);
@ -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();
}
@ -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);
}

@ -55,13 +55,6 @@ this.Commands = {
}
}
});
} else {
swal({
title: t('Chat_ended'),
type: 'success',
timer: 1000,
showConfirmButton: false
});
}
},

@ -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;

@ -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;

@ -66,6 +66,13 @@
<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>

@ -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();
@ -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');
@ -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({
@ -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();
@ -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())
}
];

@ -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, {

@ -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;
});

@ -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, {
@ -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);

@ -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) => {

@ -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'
]
}
};

Loading…
Cancel
Save