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] Livechat Setting to show/hide feedback form on the widget #18280

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions app/livechat/client/views/app/livechatAppearance.html
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,16 @@ <h2>{{_ "Settings"}}</h2>
<textarea class="preview-settings rc-input__element" name="offlineSuccessMessage" id="offlineSuccessMessage">{{offlineSuccessMessage}}</textarea>
</div>
</fieldset>
<fieldset>
<legend>{{_ "Livechat_feedback_form"}}</legend>
<label class="rc-switch__label">
<input class="rc-switch__input js-input-check" type="checkbox" name="feedbackFormEnabled" {{feedbackFormEnabled}}/>
<span class="rc-switch__button">
<span class="rc-switch__button-inside"></span>
</span>
<span class="rc-switch__text">{{_ "Show_feedback_form"}}</span>
</label>
</fieldset>
<fieldset>
<legend>{{_ "Livechat_registration_form"}}</legend>
<!--
Expand Down
15 changes: 15 additions & 0 deletions app/livechat/client/views/app/livechatAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ Template.livechatAppearance.helpers({
registrationFormMessage() {
return Template.instance().registrationFormMessage.get();
},
feedbackFormEnabled() {
if (Template.instance().feedbackFormEnabled.get()) {
return 'checked';
}
},
});

Template.livechatAppearance.onCreated(async function() {
Expand All @@ -126,6 +131,7 @@ Template.livechatAppearance.onCreated(async function() {
this.registrationFormNameFieldEnabled = new ReactiveVar(null);
this.registrationFormEmailFieldEnabled = new ReactiveVar(null);
this.registrationFormMessage = new ReactiveVar(null);
this.feedbackFormEnabled = new ReactiveVar(null);

const { appearance } = await APIClient.v1.get('livechat/appearance');
this.appearance.set(appearance);
Expand All @@ -147,6 +153,7 @@ Template.livechatAppearance.onCreated(async function() {
const livechatNameFieldRegistrationForm = getSettingFromAppearance(this, 'Livechat_name_field_registration_form');
const livechatEmailFieldRegistrationForm = getSettingFromAppearance(this, 'Livechat_email_field_registration_form');
const conversationFinishedText = getSettingFromAppearance(this, 'Livechat_conversation_finished_text');
const livechatFeedbackForm = getSettingFromAppearance(this, 'Livechat_feedback_form');

this.title.set(livechatTitle && livechatTitle.value);
this.color.set(livechatTitleColor && livechatTitleColor.value);
Expand All @@ -165,6 +172,7 @@ Template.livechatAppearance.onCreated(async function() {
this.registrationFormNameFieldEnabled.set(livechatNameFieldRegistrationForm && livechatNameFieldRegistrationForm.value);
this.registrationFormEmailFieldEnabled.set(livechatEmailFieldRegistrationForm && livechatEmailFieldRegistrationForm.value);
this.conversationFinishedText.set(conversationFinishedText && conversationFinishedText.value);
this.feedbackFormEnabled.set(livechatFeedbackForm && livechatFeedbackForm.value);
});

Template.livechatAppearance.events({
Expand Down Expand Up @@ -228,6 +236,9 @@ Template.livechatAppearance.events({

const settingRegistrationFormMessage = getSettingFromAppearance(instance, 'Livechat_registration_form_message');
instance.registrationFormMessage.set(settingRegistrationFormMessage && settingRegistrationFormMessage.value);

const settingFeedbackFormEnabled = getSettingFromAppearance(instance, 'Livechat_feedback_form');
instance.feedbackFormEnabled.set(settingFeedbackFormEnabled && settingFeedbackFormEnabled.value);
},
'submit .rocket-form'(e, instance) {
e.preventDefault();
Expand Down Expand Up @@ -300,6 +311,10 @@ Template.livechatAppearance.events({
_id: 'Livechat_registration_form_message',
value: s.trim(instance.registrationFormMessage.get()),
},
{
_id: 'Livechat_feedback_form',
value: instance.feedbackFormEnabled.get(),
},
];

Meteor.call('livechat:saveAppearance', settings, (err/* , success*/) => {
Expand Down
1 change: 1 addition & 0 deletions app/livechat/server/api/lib/appearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export async function findAppearance({ userId }) {
'Livechat_email_field_registration_form',
'Livechat_registration_form_message',
'Livechat_conversation_finished_text',
'Livechat_feedback_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 @@ -111,6 +111,7 @@ export function settings() {
forceAcceptDataProcessingConsent: initSettings.Livechat_force_accept_data_processing_consent,
showConnecting: initSettings.Livechat_Show_Connecting,
agentHiddenInfo: initSettings.Livechat_show_agent_info === false,
showFeedbackForm: initSettings.Livechat_feedback_form,
},
theme: {
title: initSettings.Livechat_title,
Expand All @@ -133,7 +134,7 @@ export function settings() {
dataProcessingConsentText: initSettings.Livechat_data_processing_consent_text,
},
survey: {
items: ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness'],
items: ['rating'],
values: ['1', '2', '3', '4', '5'],
},
triggers,
Expand Down
8 changes: 8 additions & 0 deletions app/livechat/server/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ Meteor.startup(function() {
i18nLabel: 'Conversation_finished_text',
});

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

settings.add('Livechat_registration_form', true, {
type: 'boolean',
group: 'Omnichannel',
Expand Down
1 change: 1 addition & 0 deletions app/livechat/server/lib/Livechat.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ export const Livechat = {
'Livechat_force_accept_data_processing_consent',
'Livechat_data_processing_consent_text',
'Livechat_show_agent_info',
'Livechat_feedback_form',
]).forEach((setting) => {
rcSettings[setting._id] = setting.value;
});
Expand Down
1 change: 1 addition & 0 deletions app/livechat/server/methods/saveAppearance.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Meteor.methods({
'Livechat_name_field_registration_form',
'Livechat_email_field_registration_form',
'Livechat_registration_form_message',
'Livechat_feedback_form',
];

const valid = settings.every((setting) => validSettings.indexOf(setting._id) !== -1);
Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -2246,6 +2246,7 @@
"Livechat_Dashboard": "Omnichannel Dashboard",
"Livechat_DepartmentOfflineMessageToChannel": "Send this department's Livechat offline messages to a channel",
"Livechat_enabled": "Omnichannel enabled",
"Livechat_feedback_form": "Feedback form",
"Livechat_Facebook_API_Key": "OmniChannel API Key",
"Livechat_Facebook_API_Secret": "OmniChannel API Secret",
"Livechat_Facebook_Enabled": "Facebook integration enabled",
Expand Down Expand Up @@ -3239,6 +3240,7 @@
"Show_Avatars": "Show Avatars",
"Show_counter": "Show counter",
"Show_email_field": "Show email field",
"Show_feedback_form": "Show feedback form",
"Show_Message_In_Main_Thread": "Show thread messages in the main thread",
"Show_more": "Show more",
"Show_name_field": "Show name field",
Expand Down