Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW][Omnichannel] Ability to set character message limit on Livechat widget #18261

Merged
13 changes: 13 additions & 0 deletions app/livechat/client/views/app/livechatAppearance.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ <h2>{{_ "Settings"}}</h2>
<label for="color">{{_ "Title_bar_color"}}</label>
<input type="color" class="preview-settings rc-input__element" name="color" id="color" value="{{color}}" />
</div>
<div class="input-line">
<label for="showLimitTextLength">{{_ "Livechat_enable_message_character_limit"}}</label>
<div class="inline-fields">
<input type="radio" class="preview-settings" name="showLimitTextLength" id="showLimitTextLengthFormTrue" checked="{{showLimitTextLengthFormTrueChecked}}" value="true">
<label for="showLimitTextLengthFormTrue">{{_ "True"}}</label>
<input type="radio" class="preview-settings" name="showLimitTextLength" id="showLimitTextLengthFormFalse" checked="{{showLimitTextLengthFormFalseChecked}}" value="false">
<label for="showLimitTextLengthFormFalse">{{_ "False"}}</label>
</div>
</div>
<div class="input-line">
<label for="limitTextLength">{{_ "Message_Characther_Limit"}}</label>
ogustavo-pereira marked this conversation as resolved.
Show resolved Hide resolved
<input type="number" class="preview-settings rc-input__element" name="limitTextLength" id="limitTextLength" value="{{limitTextLength}}">
</div>
<div class="input-line">
<label for="showAgentInfo">{{_ "Show_agent_info"}}</label>
<div class="inline-fields">
Expand Down
34 changes: 33 additions & 1 deletion app/livechat/client/views/app/livechatAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,19 @@ import { APIClient } from '../../../../utils/client';
const getSettingFromAppearance = (instance, settingName) => instance.appearance.get() && instance.appearance.get().find((setting) => setting._id === settingName);

Template.livechatAppearance.helpers({
showLimitTextLengthFormTrueChecked() {
if (Template.instance().showLimitTextLength.get()) {
return 'checked';
}
},
showLimitTextLengthFormFalseChecked() {
if (!Template.instance().showLimitTextLength.get()) {
return 'checked';
}
},
limitTextLength() {
return Template.instance().limitTextLength.get();
},
color() {
return Template.instance().color.get();
},
Expand Down Expand Up @@ -110,7 +123,8 @@ Template.livechatAppearance.onCreated(async function() {
this.appearance = new ReactiveVar([]);
this.title = new ReactiveVar(null);
this.color = new ReactiveVar(null);

this.showLimitTextLength = new ReactiveVar(null);
this.limitTextLength = new ReactiveVar(null);
this.showAgentInfo = new ReactiveVar(null);
this.showAgentEmail = new ReactiveVar(null);
this.displayOfflineForm = new ReactiveVar(null);
Expand All @@ -132,6 +146,8 @@ Template.livechatAppearance.onCreated(async function() {

const livechatTitle = getSettingFromAppearance(this, 'Livechat_title');
const livechatTitleColor = getSettingFromAppearance(this, 'Livechat_title_color');
const livechatShowMessageCharacterLimit = getSettingFromAppearance(this, 'Livechat_enable_message_character_limit');
const livechatMessageCharacterLimit = getSettingFromAppearance(this, 'Livechat_message_character_limit');
const livechatShowAgentInfo = getSettingFromAppearance(this, 'Livechat_show_agent_info');
const livechatShowAgentEmail = getSettingFromAppearance(this, 'Livechat_show_agent_email');
const livechatDisplayOfflineForm = getSettingFromAppearance(this, 'Livechat_display_offline_form');
Expand All @@ -150,6 +166,8 @@ Template.livechatAppearance.onCreated(async function() {

this.title.set(livechatTitle && livechatTitle.value);
this.color.set(livechatTitleColor && livechatTitleColor.value);
this.showLimitTextLength.set(livechatShowMessageCharacterLimit && livechatShowMessageCharacterLimit.value);
this.limitTextLength.set(livechatMessageCharacterLimit && livechatMessageCharacterLimit.value);
this.showAgentInfo.set(livechatShowAgentInfo && livechatShowAgentInfo.value);
this.showAgentEmail.set(livechatShowAgentEmail && livechatShowAgentEmail.value);
this.displayOfflineForm.set(livechatDisplayOfflineForm && livechatDisplayOfflineForm.value);
Expand Down Expand Up @@ -187,6 +205,12 @@ Template.livechatAppearance.events({
const settingTitleColor = getSettingFromAppearance(instance, 'Livechat_title_color');
instance.color.set(settingTitleColor && settingTitleColor.value);

const settinglivechatShowMessageCharacterLimit = getSettingFromAppearance(instance, 'Livechat_enable_message_character_limit');
instance.showLimitTextLength.set(settinglivechatShowMessageCharacterLimit && settinglivechatShowMessageCharacterLimit.value);

const settinglivechatMessageCharacterLimit = getSettingFromAppearance(instance, 'Livechat_message_character_limit');
instance.limitTextLength.set(settinglivechatMessageCharacterLimit && settinglivechatMessageCharacterLimit.value);

const settingShowAgentInfo = getSettingFromAppearance(instance, 'Livechat_show_agent_info');
instance.showAgentInfo.set(settingShowAgentInfo && settingShowAgentInfo.value);

Expand Down Expand Up @@ -240,6 +264,14 @@ Template.livechatAppearance.events({
_id: 'Livechat_title_color',
value: instance.color.get(),
},
{
_id: 'Livechat_enable_message_character_limit',
value: instance.showLimitTextLength.get(),
},
{
_id: 'Livechat_message_character_limit',
value: parseInt(instance.limitTextLength.get()),
},
{
_id: 'Livechat_show_agent_info',
value: instance.showAgentInfo.get(),
Expand Down
2 changes: 2 additions & 0 deletions app/livechat/server/api/lib/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export async function findAppearance({ userId }) {
$in: [
'Livechat_title',
'Livechat_title_color',
'Livechat_enable_message_character_limit',
'Livechat_message_character_limit',
'Livechat_show_agent_info',
'Livechat_show_agent_email',
'Livechat_display_offline_form',
Expand Down
3 changes: 2 additions & 1 deletion app/livechat/server/api/lib/livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export function settings() {
const departments = findDepartments();
const sound = `${ Meteor.absoluteUrl() }sounds/chime.mp3`;
const emojis = Meteor.call('listEmojiCustom');

return {
enabled: initSettings.Livechat_enabled,
settings: {
Expand All @@ -111,6 +110,8 @@ export function settings() {
forceAcceptDataProcessingConsent: initSettings.Livechat_force_accept_data_processing_consent,
showConnecting: initSettings.Livechat_Show_Connecting,
agentHiddenInfo: initSettings.Livechat_show_agent_info === false,
limitTextLength: initSettings.Livechat_enable_message_character_limit
&& (initSettings.Livechat_message_character_limit || initSettings.Message_MaxAllowedSize),
},
theme: {
title: initSettings.Livechat_title,
Expand Down
14 changes: 14 additions & 0 deletions app/livechat/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,20 @@ Meteor.startup(function() {
public: true,
});

settings.add('Livechat_enable_message_character_limit', false, {
type: 'boolean',
group: 'Omnichannel',
section: 'Livechat',
public: true,
});

settings.add('Livechat_message_character_limit', 0, {
type: 'int',
group: 'Omnichannel',
section: 'Livechat',
public: true,
});

settings.add('Livechat_display_offline_form', true, {
type: 'boolean',
group: 'Omnichannel',
Expand Down
3 changes: 3 additions & 0 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,9 @@ export const Livechat = {
Settings.findNotHiddenPublic([
'Livechat_title',
'Livechat_title_color',
'Livechat_enable_message_character_limit',
'Livechat_message_character_limit',
ogustavo-pereira marked this conversation as resolved.
Show resolved Hide resolved
'Message_MaxAllowedSize',
'Livechat_enabled',
'Livechat_registration_form',
'Livechat_allow_switching_departments',
Expand Down
2 changes: 2 additions & 0 deletions app/livechat/server/methods/saveAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Meteor.methods({
const validSettings = [
'Livechat_title',
'Livechat_title_color',
'Livechat_enable_message_character_limit',
'Livechat_message_character_limit',
'Livechat_show_agent_info',
'Livechat_show_agent_email',
'Livechat_display_offline_form',
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2272,6 +2272,8 @@
"Livechat_Take_Confirm": "Do you want to take this client?",
"Livechat_title": "Livechat Title",
"Livechat_title_color": "Livechat Title Background Color",
"Livechat_enable_message_character_limit": "Enable message character limit",
"Livechat_message_character_limit": "Livechat message character limit",
"Livechat_transcript_already_requested_warning": "The transcript of this chat has already been requested and will be sent as soon as the conversation ends.",
"Livechat_transcript_request_has_been_canceled": "The chat transcription request has been canceled.",
"Livechat_transcript_has_been_requested": "The chat transcript has been requested.",
Expand Down Expand Up @@ -2443,6 +2445,7 @@
"Message_AudioRecorderEnabled_Description": "Requires 'audio/mp3' files to be an accepted media type within 'File Upload' settings.",
"Message_BadWordsFilterList": "Add Bad Words to the Blacklist",
"Message_BadWordsFilterListDescription": "Add List of Comma-separated list of bad words to filter",
"Message_Characther_Limit": "Message Characther Limit",
"MessageBox_view_mode": "MessageBox View Mode",
"message_counter": "__counter__ message",
"message_counter_plural": "__counter__ messages",
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2016,6 +2016,8 @@
"Livechat_Take_Confirm": "Você quer levar esse cliente?",
"Livechat_title": "Título Livechat",
"Livechat_title_color": "Cor de fundo do título do Livechat",
"Livechat_enable_message_character_limit": "Habilitar Limite de caracteres de mensagem",
"Livechat_message_character_limit": "Limite de caracteres da mensagem no livechat",
"Livechat_transcript_already_requested_warning": "A transcrição deste bate-papo já foi solicitada e será enviada assim que a conversa for encerrada.",
"Livechat_transcript_request_has_been_canceled": "A requisição de transcrição do bate-papo foi cancelada.",
"Livechat_transcript_has_been_requested": "A transcrição do bate-papo foi requisitada.",
Expand Down Expand Up @@ -2168,6 +2170,7 @@
"Message_AudioRecorderEnabled_Description": "Requer arquivos 'audio / mp3' para ser um tipo de mídia aceito dentro das configurações 'Upload de arquivo'.",
"Message_BadWordsFilterList": "Adicione palavrões para a lista negra",
"Message_BadWordsFilterListDescription": "Adicione palavrões separados por vírgula para filtrar",
"Message_Characther_Limit": "Limite do caráter da mensagem",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI Characther -> Character, but its the same everywhere for this so it still functions fine

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @dlassalle. I'll fix this typo.

"message_counter": "__counter__ mensagem",
"message_counter_plural": "__counter__ mensagens",
"Message_DateFormat": "Formato de Data",
Expand Down
3 changes: 3 additions & 0 deletions packages/rocketchat-i18n/i18n/pt.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1894,6 +1894,8 @@
"Livechat_Take_Confirm": "Quer levar este cliente?",
"Livechat_title": "Título Livechat",
"Livechat_title_color": "Cor de fundo do título do Livechat",
"Livechat_enable_message_character_limit": "Habilitar Limite de caracteres de mensagem",
"Livechat_message_character_limit": "Limite de caracteres da mensagem no livechat",
"Livechat_transcript_sent": "Transcrição de Livechat enviada",
"Livechat_Users": "Utilizadores Livechat",
"LiveStream & Broadcasting": "Livestream e Broadcasting",
Expand Down Expand Up @@ -2021,6 +2023,7 @@
"Message_AudioRecorderEnabled_Description": "Requer arquivos 'áudio / mp3' para ser um tipo de leitor aceite dentro das configurações 'Carregar ficheiro'.",
"Message_BadWordsFilterList": "Adicione palavrões para a lista negra",
"Message_BadWordsFilterListDescription": "Adicione palavrões separados por vírgula para filtrar",
"Message_Characther_Limit": "Limite do caráter da mensagem",
"Message_DateFormat": "Formato de Data",
"Message_DateFormat_Description": "Veja também: <a href=\"http://momentjs.com/docs/#/displaying/format/\" target=\"momemt\">Moment.js</a>",
"Message_deleting_blocked": "Esta mensagem não pode ser mais apagada",
Expand Down