Skip to content

Commit

Permalink
Merge pull request #8149 from icosamuel/feature/livechat_hide_email
Browse files Browse the repository at this point in the history
[NEW] Feature/livechat hide email
  • Loading branch information
rodrigok committed Dec 8, 2017
2 parents 88177c5 + 175ea0c commit e72e08e
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 1 deletion.
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 @@ -1639,6 +1639,7 @@
"Shared_Location": "Shared Location",
"Should_be_a_URL_of_an_image": "Should be a URL of an image.",
"Should_exists_a_user_with_this_username": "The user must already exist.",
"Show_agent_email": "Show agent email",
"Show_all": "Show All",
"Show_room_counter_on_sidebar": "Show room counter on sidebar",
"Show_more": "Show more",
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-i18n/i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -1276,6 +1276,7 @@
"Shared_Location": "Position partagée",
"Should_be_a_URL_of_an_image": "Doit être l'URL d'une image.",
"Should_exists_a_user_with_this_username": "L'utilisateur doit déjà exister.",
"Show_agent_email": "Afficher le email de l'agent",
"Show_all": "Afficher tout",
"Show_more": "Afficher plus",
"show_offline_users": "montrer les utilisateur hors-ligne",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ <h2>{{_ "Settings"}}</h2>
<span class="colorpicker-swatch border-component-color" style="background-color: {{color}}"></span>
</div>
</div>
<div class="input-line">
<label for="showAgentEmail">{{_ "Show_agent_email"}}</label>
<div class="inline-fields">
<input type="radio" class="preview-settings" name="showAgentEmail" id="showAgentEmailFormTrue" checked="{{showAgentEmailFormTrueChecked}}" value="true">
<label for="showAgentEmailFormTrue">{{_ "True"}}</label>
<input type="radio" class="preview-settings" name="showAgentEmail" id="showAgentEmailFormFalse" checked="{{showAgentEmailFormFalseChecked}}" value="false">
<label for="showAgentEmailFormFalse">{{_ "False"}}</label>
</div>
</div>
</fieldset>
<fieldset>
<legend>{{_ "Livechat_offline"}}</legend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Template.livechatAppearance.helpers({
color() {
return Template.instance().color.get();
},
showAgentEmail() {
return Template.instance().showAgentEmail.get();
},
title() {
return Template.instance().title.get();
},
Expand All @@ -47,6 +50,16 @@ Template.livechatAppearance.helpers({
sampleOfflineSuccessMessage() {
return Template.instance().offlineSuccessMessage.get().replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1<br>$2');
},
showAgentEmailFormTrueChecked() {
if (Template.instance().showAgentEmail.get()) {
return 'checked';
}
},
showAgentEmailFormFalseChecked() {
if (!Template.instance().showAgentEmail.get()) {
return 'checked';
}
},
displayOfflineFormTrueChecked() {
if (Template.instance().displayOfflineForm.get()) {
return 'checked';
Expand Down Expand Up @@ -156,6 +169,7 @@ Template.livechatAppearance.onCreated(function() {
this.title = new ReactiveVar(null);
this.color = new ReactiveVar(null);

this.showAgentEmail = new ReactiveVar(null);
this.displayOfflineForm = new ReactiveVar(null);
this.offlineUnavailableMessage = new ReactiveVar(null);
this.offlineMessage = new ReactiveVar(null);
Expand All @@ -172,6 +186,10 @@ Template.livechatAppearance.onCreated(function() {
const setting = LivechatAppearance.findOne('Livechat_title_color');
this.color.set(setting && setting.value);
});
this.autorun(() => {
const setting = LivechatAppearance.findOne('Livechat_show_agent_email');
this.showAgentEmail.set(setting && setting.value);
});
this.autorun(() => {
const setting = LivechatAppearance.findOne('Livechat_display_offline_form');
this.displayOfflineForm.set(setting && setting.value);
Expand Down Expand Up @@ -222,6 +240,9 @@ Template.livechatAppearance.events({
const settingTitleColor = LivechatAppearance.findOne('Livechat_title_color');
instance.color.set(settingTitleColor && settingTitleColor.value);

const settingShowAgentEmail = LivechatAppearance.findOne('Livechat_show_agent_email');
instance.showAgentEmail.set(settingShowAgentEmail && settingShowAgentEmail.value);

const settingDiplayOffline = LivechatAppearance.findOne('Livechat_display_offline_form');
instance.displayOfflineForm.set(settingDiplayOffline && settingDiplayOffline.value);

Expand Down Expand Up @@ -252,6 +273,10 @@ Template.livechatAppearance.events({
_id: 'Livechat_title_color',
value: instance.color.get()
},
{
_id: 'Livechat_show_agent_email',
value: instance.showAgentEmail.get()
},
{
_id: 'Livechat_display_offline_form',
value: instance.displayOfflineForm.get()
Expand Down
1 change: 1 addition & 0 deletions packages/rocketchat-livechat/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ 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_guest_count', 1, { type: 'int', group: 'Livechat' });

RocketChat.settings.add('Livechat_Room_Count', 1, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Meteor.methods({
const validSettings = [
'Livechat_title',
'Livechat_title_color',
'Livechat_show_agent_email',
'Livechat_display_offline_form',
'Livechat_offline_form_unavailable',
'Livechat_offline_message',
Expand Down
5 changes: 4 additions & 1 deletion packages/rocketchat-livechat/server/models/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,13 @@ RocketChat.models.Users.getAgentInfo = function(agentId) {
fields: {
name: 1,
username: 1,
emails: 1,
customFields: 1
}
};

if (RocketChat.settings.get('Livechat_show_agent_email')) {
options.fields.emails = 1;
}

return this.findOne(query, options);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Meteor.publish('livechat:appearance', function() {
$in: [
'Livechat_title',
'Livechat_title_color',
'Livechat_show_agent_email',
'Livechat_display_offline_form',
'Livechat_offline_form_unavailable',
'Livechat_offline_message',
Expand Down

0 comments on commit e72e08e

Please sign in to comment.