Skip to content

Commit ab98c85

Browse files
authored
Feature/mrsimpson#24 deactivate closing comments (RocketChat#170)
* Deactivate Request Closing Comments * Deactivate closing comment for Live-Chat * Create the swal config more nicely * text translation and mergin object properties * incl. setting to config role and roll back to using _ for object mergin * minor naming adjustments
1 parent 57f1e8c commit ab98c85

File tree

5 files changed

+42
-12
lines changed

5 files changed

+42
-12
lines changed

packages/assistify-defaults/server/roles.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,8 @@ const createConfigurationRole = function() {
179179
'change-setting-Accounts_AllowedDomainsList',
180180
'change-setting-Accounts_ManuallyApproveNewUsers',
181181
'change-setting-Accounts_EmailVerification',
182-
'change-setting-Accounts'
182+
'change-setting-Accounts',
183+
'change-setting-Assistify_Deactivate_request_closing_comments'
183184
];
184185

185186
assignPermissions(CONFIGURATION_ROLE_NAME,

packages/assistify-help-request/client/views/tabbar/HelpRequestActions.js

+29-10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { RocketChat, UiTextContext } from 'meteor/rocketchat:lib';
1+
import {RocketChat, UiTextContext} from 'meteor/rocketchat:lib';
2+
3+
const showClosingComment = function() {
4+
return !RocketChat.settings.get('Assistify_Deactivate_request_closing_comments');
5+
};
26

37
Template.HelpRequestActions.helpers({
48
helprequestOpen() {
@@ -36,20 +40,28 @@ Template.HelpRequestActions.helpers({
3640
}
3741
});
3842

43+
3944
Template.HelpRequestActions.events({
4045
'click .close-helprequest'(event, instance) {
4146
event.preventDefault();
4247
const warnText = RocketChat.roomTypes.roomTypes['r'].getUiText(UiTextContext.CLOSE_WARNING);
4348

44-
swal(_.extend({
49+
let swalConfig = {
4550
title: t('Closing_chat'),
4651
text: warnText ? t(warnText) : '',
47-
type: 'input',
48-
inputPlaceholder: t('Close_request_comment'),
4952
showCancelButton: true,
5053
closeOnConfirm: false,
5154
roomId: instance.data.roomId
52-
}), (inputValue) => {
55+
};
56+
57+
if (showClosingComment()) {
58+
swalConfig = _.extend(swalConfig, {
59+
type: 'input',
60+
inputPlaceholder: t('Close_request_comment')
61+
});
62+
}
63+
64+
swal(swalConfig, (inputValue) => {
5365
//inputValue is false on "cancel" and has a string value of the input if confirmed.
5466
if (!(typeof inputValue === 'boolean' && inputValue === false)) {
5567
Meteor.call('assistify:closeHelpRequest', this.roomId, {comment: inputValue}, function(error) {
@@ -74,14 +86,21 @@ Template.HelpRequestActions.events({
7486
},
7587
'click .close-livechat'(event) {
7688
event.preventDefault();
77-
78-
swal({
89+
let swalConfig = {
7990
title: t('Closing_chat'),
80-
type: 'input',
81-
inputPlaceholder: t('Please_add_a_comment'),
91+
type: showClosingComment(),
8292
showCancelButton: true,
8393
closeOnConfirm: false
84-
}, (inputValue) => {
94+
};
95+
96+
if (showClosingComment()) {
97+
swalConfig = _.extend(swalConfig, {
98+
type: 'input',
99+
inputPlaceholder: t('Please_add_a_comment')
100+
});
101+
}
102+
103+
swal(swalConfig, (inputValue) => {
85104
//inputValue is false on "cancel" and has a string value of the input if confirmed.
86105
if (!(typeof inputValue === 'boolean' && inputValue === false)) {
87106

packages/assistify-help-request/config.js

+8
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ Meteor.startup(() => {
2626
section: 'General'
2727
});
2828

29+
RocketChat.settings.add('Assistify_Deactivate_request_closing_comments', false, {
30+
group: 'Assistify',
31+
i18nLabel: 'Deactivate_close_comment',
32+
type: 'boolean',
33+
section:'General',
34+
public: true
35+
});
36+
2937
_createExpertsChannel();
3038

3139
RocketChat.theme.addPackageAsset(() => {

packages/rocketchat-i18n/i18n/assistifyHelpRequest.de.i18n.yml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ create-e: Thema anlegen
88
create-r: Anfrage anlegen
99
delete-e: Thema löschen
1010
delete-r: Anfrage löschen
11+
Deactivate_close_comment: Kommentieren beim Schließen von Anfragen verhindern
1112
Expertise_description: Ein Thema beschreibt ein Wissensgebiet. Experten beantworten hierzu Anfragen
1213
Expertise_does_not_exist: Das Thema gibt es nicht
1314
Expertise_explanation: Ein Thema beschreibt ein Wissensgebiet. Zu einem Thema können Anfragen erstellt werden, die von den Experten, die dem Thema als Mitglieder zugeordnet sind, beantwortet werden können.

packages/rocketchat-i18n/i18n/assistifyHelpRequest.en.i18n.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
application: Application
2-
Asssitify_room_count: Roomcount
2+
Assistify_room_count: Roomcount
33
Choose_experts: Choose experts
44
Close_HelpRequest: Close chat
55
Close_request_comment: You can add (famous) last words
66
Close_request_warning: Please do close the request once you are finished answering the questions asked. This way, we can learn from what you have written.
7+
Deactivate_close_comment: Don't allow closing comments
78
Expertise_description: A topic is an area of knowledge with known experts.
89
Expertise_does_not_exist: Expertise does not exist
910
Expertise_explanation: A topic is an area of knowledge. Experts join a topic in order to help others solve their question in that area.

0 commit comments

Comments
 (0)