mirror of
https://github.com/ansible/awx.git
synced 2024-10-31 15:21:13 +03:00
code-mirror: keep yaml/json setting in sync with modal
This commit is contained in:
parent
5d3e39beac
commit
33b19ebe1f
@ -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;
|
||||
}
|
||||
|
@ -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>
|
||||
|
@ -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: '&'
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user