From d7c41eb9d71094f3af51306d319fe64cf5d80f8b Mon Sep 17 00:00:00 2001 From: Renato Becker Date: Wed, 25 Apr 2018 11:30:44 -0300 Subject: [PATCH 1/2] New settings added to enable/disable the Livechat registration form fields. --- packages/rocketchat-i18n/i18n/en.i18n.json | 5 +- packages/rocketchat-i18n/i18n/pt.i18n.json | 5 +- .../.app/client/lib/_livechat.js | 14 + .../.app/client/lib/commands.js | 2 +- .../.app/client/views/livechatWindow.js | 10 +- .../.app/client/views/register.html | 9 +- .../.app/client/views/register.js | 43 ++- .../client/views/app/livechatAppearance.html | 356 ++++++++++-------- .../client/views/app/livechatAppearance.js | 59 ++- packages/rocketchat-livechat/config.js | 22 +- .../server/lib/Livechat.js | 5 +- .../server/methods/getInitialData.js | 6 +- .../server/methods/saveAppearance.js | 5 +- .../server/publications/livechatAppearance.js | 5 +- 14 files changed, 360 insertions(+), 186 deletions(-) diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index 1be995d49489..2d9fef45d09d 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -1238,6 +1238,7 @@ "Livechat_online": "Livechat online", "Livechat_open_inquiery_show_connecting": "Show Connecting Message Instead of Input When Guest is Not Yet Connected to an Agent", "Livechat_Queue": "Livechat Queue", + "Livechat_registration_form": "Registration Form", "Livechat_room_count": "Livechat Room Count", "Livechat_Routing_Method": "Livechat Routing Method", "Livechat_Take_Confirm": "Do you want to take this client?", @@ -1839,13 +1840,15 @@ "Show_all": "Show All", "Show_Avatars": "Show Avatars", "Show_counter": "Show counter", - "Show_room_counter_on_sidebar": "Show room counter on sidebar", + "Show_email_field": "Show email field", "Show_more": "Show more", + "Show_name_field": "Show name field", "show_offline_users": "show offline users", "Show_on_registration_page": "Show on registration page", "Show_only_online": "Show Online Only", "Show_preregistration_form": "Show Pre-registration Form", "Show_queue_list_to_all_agents": "Show Queue List to All Agents", + "Show_room_counter_on_sidebar": "Show room counter on sidebar", "Show_the_keyboard_shortcut_list": "Show the keyboard shortcut list", "Showing_archived_results": "

Showing %s archived results

", "Showing_online_users": "Showing: __total_showing__, Online: __online__, Total: __total__ users", diff --git a/packages/rocketchat-i18n/i18n/pt.i18n.json b/packages/rocketchat-i18n/i18n/pt.i18n.json index 3affa6dfe214..5563f472c73e 100644 --- a/packages/rocketchat-i18n/i18n/pt.i18n.json +++ b/packages/rocketchat-i18n/i18n/pt.i18n.json @@ -1240,6 +1240,7 @@ "Livechat_online": "Livechat on-line", "Livechat_open_inquiery_show_connecting": "Mostrar conexão de mensagem em vez de entrada quando o visitante ainda não está conectado a um agente", "Livechat_Queue": "Roleta Livechat", + "Livechat_registration_form": "Formulário de pré-registro", "Livechat_room_count": "Contador de salas de livechat", "Livechat_Routing_Method": "Método de roteamento Livechat", "Livechat_Take_Confirm": "Você quer levar esse cliente?", @@ -1841,13 +1842,15 @@ "Show_all": "Mostrar tudo", "Show_Avatars": "Mostrar Avatares", "Show_counter": "Show counter", - "Show_room_counter_on_sidebar": "Mostrar contador do quarto na barra lateral", + "Show_email_field": "Mostrar campo e-mail", "Show_more": "Mostrar mais", + "Show_name_field": "Mostrar campo nome", "show_offline_users": "mostrar usuários offline", "Show_on_registration_page": "Mostrar na página de registro", "Show_only_online": "Mostrar apenas online", "Show_preregistration_form": "Mostrar formulário de pré-registro", "Show_queue_list_to_all_agents": "Mostrar link da roleta à todos agentes", + "Show_room_counter_on_sidebar": "Mostrar contador do quarto na barra lateral", "Show_the_keyboard_shortcut_list": "Exibe a lisgta de atalhos do teclado", "Showing_archived_results": "

Exibindo %s resultados arquivados

", "Showing_online_users": "Mostrando __total_showing__ de __total__ usuários", diff --git a/packages/rocketchat-livechat/.app/client/lib/_livechat.js b/packages/rocketchat-livechat/.app/client/lib/_livechat.js index 781f500bc643..541af4c2a826 100644 --- a/packages/rocketchat-livechat/.app/client/lib/_livechat.js +++ b/packages/rocketchat-livechat/.app/client/lib/_livechat.js @@ -23,6 +23,8 @@ this.Livechat = new (class Livechat { this._videoCall = new ReactiveVar(false); this._transcriptMessage = new ReactiveVar(''); this._conversationFinishedMessage = new ReactiveVar(''); + this._nameFieldRegistrationForm = new ReactiveVar(false); + this._emailFieldRegistrationForm = new ReactiveVar(false); this._connecting = new ReactiveVar(false); this._room = new ReactiveVar(null); this._department = new ReactiveVar(null); @@ -104,6 +106,12 @@ this.Livechat = new (class Livechat { get conversationFinishedMessage() { return this._conversationFinishedMessage.get(); } + get nameFieldRegistrationForm() { + return this._nameFieldRegistrationForm.get(); + } + get emailFieldRegistrationForm() { + return this._emailFieldRegistrationForm.get(); + } get department() { return this._department.get(); } @@ -168,6 +176,12 @@ this.Livechat = new (class Livechat { set conversationFinishedMessage(value) { this._conversationFinishedMessage.set(value); } + set nameFieldRegistrationForm(value) { + this._nameFieldRegistrationForm.set(value); + } + set emailFieldRegistrationForm(value) { + this._emailFieldRegistrationForm.set(value); + } set connecting(value) { this._connecting.set(value); } diff --git a/packages/rocketchat-livechat/.app/client/lib/commands.js b/packages/rocketchat-livechat/.app/client/lib/commands.js index 34631ba9e52d..0e5c1dd1f234 100644 --- a/packages/rocketchat-livechat/.app/client/lib/commands.js +++ b/packages/rocketchat-livechat/.app/client/lib/commands.js @@ -17,7 +17,7 @@ this.Commands = { if (Livechat.transcript) { const visitorData = visitor.getData(); const email = visitorData && visitorData.visitorEmails && visitorData.visitorEmails.length > 0 ? visitorData.visitorEmails[0].address : ''; - const transcriptMessage = (!_.isEmpty(Livechat.transcriptMessage)) ? Livechat.transcriptMessage : (TAPi18n.__('Would_you_like_a_copy_if_this_chat_emailed')); + const transcriptMessage = (Livechat.transcriptMessage) ? Livechat.transcriptMessage : (TAPi18n.__('Would_you_like_a_copy_if_this_chat_emailed')); swal({ title: t('Chat_ended'), diff --git a/packages/rocketchat-livechat/.app/client/views/livechatWindow.js b/packages/rocketchat-livechat/.app/client/views/livechatWindow.js index 3116100f6e50..414bd2cdf9a1 100644 --- a/packages/rocketchat-livechat/.app/client/views/livechatWindow.js +++ b/packages/rocketchat-livechat/.app/client/views/livechatWindow.js @@ -1,6 +1,10 @@ /* globals Department, Livechat, LivechatVideoCall */ import visitor from '../../imports/client/visitor'; +function showDepartments() { + return Department.find({ showOnRegistration: true }).count() > 1; +}; + Template.livechatWindow.helpers({ title() { return Livechat.title; @@ -21,7 +25,7 @@ Template.livechatWindow.helpers({ if (Session.get('triggered') || visitor.getId()) { return false; } - return Livechat.registrationForm; + return (Livechat.registrationForm && (Livechat.nameFieldRegistrationForm || Livechat.emailFieldRegistrationForm || showDepartments())); }, showSwitchDepartmentForm() { return Livechat.showSwitchDepartmentForm; @@ -115,7 +119,8 @@ Template.livechatWindow.onCreated(function() { } Livechat.videoCall = result.videoCall; Livechat.registrationForm = result.registrationForm; - + Livechat.nameFieldRegistrationForm = result.nameFieldRegistrationForm; + Livechat.emailFieldRegistrationForm = result.emailFieldRegistrationForm; if (result.room) { Livechat.room = result.room._id; @@ -145,6 +150,7 @@ Template.livechatWindow.onCreated(function() { Department.insert(department); }); Livechat.allowSwitchingDepartments = result.allowSwitchingDepartments; + Livechat.ready(); } }); diff --git a/packages/rocketchat-livechat/.app/client/views/register.html b/packages/rocketchat-livechat/.app/client/views/register.html index 9538e7113b9c..142ca7637593 100644 --- a/packages/rocketchat-livechat/.app/client/views/register.html +++ b/packages/rocketchat-livechat/.app/client/views/register.html @@ -8,9 +8,12 @@ {{{welcomeMessage}}}

- - - + {{#if showNameFieldRegisterForm}} + + {{/if}} + {{#if showEmailFieldRegisterForm}} + + {{/if}} {{#if showDepartments}}