From fc4c9af86f233884a2e4caa71a18915fcf97c0c0 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Fri, 7 Jun 2019 15:59:10 -0700 Subject: [PATCH] fix empty template message after expanding --- .../syntax-highlight.directive.js | 17 ++++++++++++----- .../src/notifications/add/add.controller.js | 8 ++++++++ .../src/notifications/edit/edit.controller.js | 8 ++++++++ .../notifications/notificationTemplates.form.js | 6 +++--- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.directive.js b/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.directive.js index a44281556c..d0f9dadde6 100644 --- a/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.directive.js +++ b/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.directive.js @@ -12,9 +12,17 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { } $scope.value = $scope.value || $scope.default; + initCodeMirror(); + + $scope.$watch(varName, () => { + $scope.value = $scope[varName]; + }); + } + + function initCodeMirror () { $scope.varName = varName; $scope[varName] = $scope.value; - const codeMirror = AngularCodeMirror($scope.disabled); + const codeMirror = AngularCodeMirror(!!$scope.disabled); codeMirror.addModes({ jinja2: { mode: $scope.mode, @@ -34,10 +42,6 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { lineNumbers: true, mode: $scope.mode, }); - - $scope.$watch(varName, () => { - $scope.value = $scope[varName]; - }); } vm.name = $scope.name; @@ -48,6 +52,9 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { angular.element(document).ready(() => { init(); }); + $scope.$on('reset-code-mirror', () => { + initCodeMirror(); + }); } atSyntaxHighlightController.$inject = [ diff --git a/awx/ui/client/src/notifications/add/add.controller.js b/awx/ui/client/src/notifications/add/add.controller.js index 335f633910..cc116630d3 100644 --- a/awx/ui/client/src/notifications/add/add.controller.js +++ b/awx/ui/client/src/notifications/add/add.controller.js @@ -153,6 +153,14 @@ export default ['Rest', 'Wait', 'NotificationsFormObject', }); }; + $scope.$watch('customize_messages', (value) => { + if (value) { + $scope.$broadcast('reset-code-mirror', { + customize_messages: $scope.customize_messages, + }); + } + }); + $scope.emailOptionsChange = function () { if ($scope.email_options === 'use_ssl') { if ($scope.use_ssl) { diff --git a/awx/ui/client/src/notifications/edit/edit.controller.js b/awx/ui/client/src/notifications/edit/edit.controller.js index 32c520ee43..b0857b6b39 100644 --- a/awx/ui/client/src/notifications/edit/edit.controller.js +++ b/awx/ui/client/src/notifications/edit/edit.controller.js @@ -237,6 +237,14 @@ export default ['Rest', 'Wait', }); }; + $scope.$watch('customize_messages', (value) => { + if (value) { + $scope.$broadcast('reset-code-mirror', { + customize_messages: $scope.customize_messages, + }); + } + }); + $scope.emailOptionsChange = function () { if ($scope.email_options === 'use_ssl') { if ($scope.use_ssl) { diff --git a/awx/ui/client/src/notifications/notificationTemplates.form.js b/awx/ui/client/src/notifications/notificationTemplates.form.js index 93420a8f30..8defd5c405 100644 --- a/awx/ui/client/src/notifications/notificationTemplates.form.js +++ b/awx/ui/client/src/notifications/notificationTemplates.form.js @@ -598,7 +598,7 @@ export default ['i18n', function(i18n) { rows: 2, }, start_body: { - label: i18n._('Start Body'), + label: i18n._('Start Expanded Message'), class: 'Form-formGroup--fullWidth', type: 'syntax_highlight', mode: 'jinja2', @@ -615,7 +615,7 @@ export default ['i18n', function(i18n) { rows: 2, }, success_body: { - label: i18n._('Success Body'), + label: i18n._('Success Expanded Message'), class: 'Form-formGroup--fullWidth', type: 'syntax_highlight', mode: 'jinja2', @@ -632,7 +632,7 @@ export default ['i18n', function(i18n) { rows: 2, }, error_body: { - label: i18n._('Error Body'), + label: i18n._('Error Expanded Message'), class: 'Form-formGroup--fullWidth', type: 'syntax_highlight', mode: 'jinja2',