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] Feature/livechat hide email #8149

Merged
merged 13 commits into from
Dec 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1632,6 +1632,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