From 7b828d73beec3dd02a75ecc6f1d80c5508bfe271 Mon Sep 17 00:00:00 2001 From: Keith Grant Date: Thu, 6 Jun 2019 14:22:42 -0700 Subject: [PATCH] fix ids to support multiple syntax-highlights at once --- .../syntax-highlight.directive.js | 13 ++++--- .../syntax-highlight.partial.html | 36 ++++++++++--------- .../src/notifications/add/add.controller.js | 10 +++--- .../notificationTemplates.form.js | 21 ++++++----- awx/ui/client/src/shared/form-generator.js | 4 ++- 5 files changed, 45 insertions(+), 39 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 08d37ee81a..0a43cfb562 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 @@ -11,15 +11,15 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { $scope.disabled = false; } // TODO: get default value - $scope.codeMirrorValue = $scope.codeMirrorValue || ''; + $scope.value = $scope.value || $scope.default; $scope.parseType = 'jinja2'; $scope.variablesName = variablesName; - $scope[variablesName] = $scope.codeMirrorValue; + $scope[variablesName] = $scope.value || ''; const codeMirror = AngularCodeMirror($scope.disabled); codeMirror.addModes({ jinja2: { - mode: 'text/x-jinja2', + mode: 'jinja2', matchBrackets: true, autoCloseBrackets: true, styleActiveLine: true, @@ -29,7 +29,6 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { scrollbarStyle: null, } }); - // codeMirror.fromTextArea(document.getElementById(`${$scope.name}_codemirror`)); codeMirror.showTextArea({ scope: $scope, model: variablesName, @@ -39,12 +38,12 @@ function atSyntaxHighlightController ($scope, AngularCodeMirror) { }); $scope.$watch(variablesName, () => { - $scope.codeMirrorValue = $scope[variablesName]; + $scope.value = $scope[variablesName]; }); } vm.name = $scope.name; - vm.variablesName = variablesName; + // vm.variablesName = variablesName; vm.parseType = $scope.parseType; if ($scope.init) { $scope.init = init; @@ -73,7 +72,7 @@ function atCodeMirrorTextarea () { labelClass: '@', tooltip: '@', tooltipPlacement: '@', - variables: '=', + value: '=', name: '@', init: '=' } diff --git a/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.partial.html b/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.partial.html index 26f99cb7cb..da5c864430 100644 --- a/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.partial.html +++ b/awx/ui/client/lib/components/syntax-highlight/syntax-highlight.partial.html @@ -1,27 +1,29 @@
- - {{ label || vm.strings.get('code_mirror.label.VARIABLES') }} - - - - + + {{ label || vm.strings.get('code_mirror.label.VARIABLES') }} + + + +