1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 23:51:09 +03:00

code-mirror: keep yaml/json setting in sync with modal

This commit is contained in:
Keith Grant 2019-03-18 13:53:52 -04:00
parent 5d3e39beac
commit 33b19ebe1f
3 changed files with 11 additions and 3 deletions

View File

@ -18,6 +18,7 @@ function atCodeMirrorController (
}
$scope.parseType = ParseType;
$scope.variablesName = variablesName;
$scope[variablesName] = $scope.variables;
ParseTypeChange({
scope: $scope,
@ -32,13 +33,14 @@ function atCodeMirrorController (
vm.expanded = true;
}
function close (varsFromModal) {
function close (varsFromModal, parseTypeFromModal) {
// TODO: make sure that the variables format matches
// parseType before re-initializing CodeMirror. Ex)
// user changes the format from yaml to json in the
// modal but CM in the form is set to YAML
$scope.variables = varsFromModal;
$scope[variablesName] = $scope.variables;
$scope.parseType = parseTypeFromModal;
// New set of variables from the modal, reinit codemirror
ParseTypeChange({
scope: $scope,
@ -59,6 +61,7 @@ function atCodeMirrorController (
vm.close = close;
vm.expand = expand;
vm.variablesName = variablesName;
vm.parseType = $scope.parseType;
if ($scope.init) {
$scope.init = init;
}

View File

@ -53,9 +53,10 @@
name="{{ vm.name }}"
ng-if="vm.expanded"
modal-vars="variables"
parse-type="parseType"
tooltip="{{ tooltip || vm.strings.get('code_mirror.tooltip.TOOLTIP') }}"
label="{{ label || vm.strings.get('code_mirror.label.VARIABLES') }}"
disabled="{{ disabled || false }}"
close-fn="vm.close">
close-fn="vm.close(values, parseType)">
</at-code-mirror-modal>
</div>

View File

@ -58,7 +58,10 @@ function atCodeMirrorModalController (
vm.strings = strings;
vm.toggle = toggle;
$scope.close = () => {
$scope.closeFn()($scope.modalVars);
$scope.closeFn({
values: $scope.modalVars,
parseType: $scope.parseType,
});
};
if ($scope.init) {
$scope.init = init;
@ -88,6 +91,7 @@ function atCodeMirrorModal () {
labelClass: '@',
tooltip: '@',
modalVars: '=',
parseType: '=',
name: '@',
closeFn: '&'
}