change custom notification message from checkbox to toggle

This commit is contained in:
Keith Grant
2019-08-01 14:58:14 -07:00
committed by Jim Ladd
parent 1470fa61d5
commit 56f04e0153
4 changed files with 17 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
init(); init();
function init() { function init() {
$scope.customize_messages = false;
Rest.setUrl(GetBasePath('notification_templates')); Rest.setUrl(GetBasePath('notification_templates'));
Rest.options() Rest.options()
.then(({data}) => { .then(({data}) => {
@@ -164,6 +165,9 @@ export default ['Rest', 'Wait', 'NotificationsFormObject',
}); });
} }
}); });
$scope.toggleForm = function(key) {
$scope[key] = !$scope[key];
};
$scope.$watch('notification_type', (value) => { $scope.$watch('notification_type', (value) => {
if (value) { if (value) {
$scope.$broadcast('reset-code-mirror', { $scope.$broadcast('reset-code-mirror', {

View File

@@ -254,6 +254,9 @@ export default ['Rest', 'Wait',
}); });
} }
}); });
$scope.toggleForm = function(key) {
$scope[key] = !$scope[key];
};
$scope.$watch('notification_type', (value) => { $scope.$watch('notification_type', (value) => {
if (value) { if (value) {
$scope.$broadcast('reset-code-mirror', { $scope.$broadcast('reset-code-mirror', {

View File

@@ -584,9 +584,9 @@ export default ['i18n', function(i18n) {
}, },
customize_messages: { customize_messages: {
label: i18n._('Customize messages…'), label: i18n._('Customize messages…'),
type: 'checkbox', type: 'toggleSwitch',
toggleSource: 'customize_messages',
class: 'Form-formGroup--fullWidth', class: 'Form-formGroup--fullWidth',
default: false,
ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)', ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)',
}, },
custom_message_description: { custom_message_description: {

View File

@@ -35,32 +35,32 @@ export default [function () {
if (!messages) { if (!messages) {
return; return;
} }
let customized = false; let isCustomized = false;
if (messages.started.message) { if (messages.started.message) {
customized = true; isCustomized = true;
$scope.started_message = messages.started.message; $scope.started_message = messages.started.message;
} }
if (messages.started.body) { if (messages.started.body) {
customized = true; isCustomized = true;
$scope.started_body = messages.started.body; $scope.started_body = messages.started.body;
} }
if (messages.success.message) { if (messages.success.message) {
customized = true; isCustomized = true;
$scope.success_message = messages.success.message; $scope.success_message = messages.success.message;
} }
if (messages.success.body) { if (messages.success.body) {
customized = true; isCustomized = true;
$scope.success_body = messages.success.body; $scope.success_body = messages.success.body;
} }
if (messages.error.message) { if (messages.error.message) {
customized = true; isCustomized = true;
$scope.error_message = messages.error.message; $scope.error_message = messages.error.message;
} }
if (messages.error.body) { if (messages.error.body) {
customized = true; isCustomized = true;
$scope.error_body = messages.error.body; $scope.error_body = messages.error.body;
} }
$scope.customize_messages = customized; $scope.customize_messages = isCustomized;
} }
}; };
}]; }];