From 56f04e01538edacf19e328e57fe020d6df2cab03 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Thu, 1 Aug 2019 14:58:14 -0700 Subject: [PATCH] change custom notification message from checkbox to toggle --- .../src/notifications/add/add.controller.js | 4 ++++ .../src/notifications/edit/edit.controller.js | 3 +++ .../notifications/notificationTemplates.form.js | 4 ++-- .../shared/message-utils.service.js | 16 ++++++++-------- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/awx/ui/client/src/notifications/add/add.controller.js b/awx/ui/client/src/notifications/add/add.controller.js index e42b2dcf1f..b7fc7b6d0e 100644 --- a/awx/ui/client/src/notifications/add/add.controller.js +++ b/awx/ui/client/src/notifications/add/add.controller.js @@ -24,6 +24,7 @@ export default ['Rest', 'Wait', 'NotificationsFormObject', init(); function init() { + $scope.customize_messages = false; Rest.setUrl(GetBasePath('notification_templates')); Rest.options() .then(({data}) => { @@ -164,6 +165,9 @@ export default ['Rest', 'Wait', 'NotificationsFormObject', }); } }); + $scope.toggleForm = function(key) { + $scope[key] = !$scope[key]; + }; $scope.$watch('notification_type', (value) => { if (value) { $scope.$broadcast('reset-code-mirror', { diff --git a/awx/ui/client/src/notifications/edit/edit.controller.js b/awx/ui/client/src/notifications/edit/edit.controller.js index b451621c9c..2f5796c98a 100644 --- a/awx/ui/client/src/notifications/edit/edit.controller.js +++ b/awx/ui/client/src/notifications/edit/edit.controller.js @@ -254,6 +254,9 @@ export default ['Rest', 'Wait', }); } }); + $scope.toggleForm = function(key) { + $scope[key] = !$scope[key]; + }; $scope.$watch('notification_type', (value) => { if (value) { $scope.$broadcast('reset-code-mirror', { diff --git a/awx/ui/client/src/notifications/notificationTemplates.form.js b/awx/ui/client/src/notifications/notificationTemplates.form.js index 7efb76709b..7b233f3a8e 100644 --- a/awx/ui/client/src/notifications/notificationTemplates.form.js +++ b/awx/ui/client/src/notifications/notificationTemplates.form.js @@ -584,9 +584,9 @@ export default ['i18n', function(i18n) { }, customize_messages: { label: i18n._('Customize messages…'), - type: 'checkbox', + type: 'toggleSwitch', + toggleSource: 'customize_messages', class: 'Form-formGroup--fullWidth', - default: false, ngDisabled: '!(notification_template.summary_fields.user_capabilities.edit || canAdd)', }, custom_message_description: { diff --git a/awx/ui/client/src/notifications/shared/message-utils.service.js b/awx/ui/client/src/notifications/shared/message-utils.service.js index 5705949e06..52076626a1 100644 --- a/awx/ui/client/src/notifications/shared/message-utils.service.js +++ b/awx/ui/client/src/notifications/shared/message-utils.service.js @@ -35,32 +35,32 @@ export default [function () { if (!messages) { return; } - let customized = false; + let isCustomized = false; if (messages.started.message) { - customized = true; + isCustomized = true; $scope.started_message = messages.started.message; } if (messages.started.body) { - customized = true; + isCustomized = true; $scope.started_body = messages.started.body; } if (messages.success.message) { - customized = true; + isCustomized = true; $scope.success_message = messages.success.message; } if (messages.success.body) { - customized = true; + isCustomized = true; $scope.success_body = messages.success.body; } if (messages.error.message) { - customized = true; + isCustomized = true; $scope.error_message = messages.error.message; } if (messages.error.body) { - customized = true; + isCustomized = true; $scope.error_body = messages.error.body; } - $scope.customize_messages = customized; + $scope.customize_messages = isCustomized; } }; }];