add use code-mirror directive for host variables; fix multiple code-mirrors on page at once

This commit is contained in:
Keith Grant
2019-03-18 11:48:21 -04:00
parent bed63b3690
commit 5d3e39beac
9 changed files with 55 additions and 46 deletions

View File

@@ -9,18 +9,19 @@ function atCodeMirrorController (
ParseTypeChange
) {
const vm = this;
const variablesName = `${$scope.name}_variables`;
function init () {
if ($scope.disabled === 'true') {
$scope.disabled = true;
} else if ($scope.disabled === 'false') {
$scope.disabled = false;
}
$scope.value = $scope.variables.value;
$scope.parseType = ParseType;
$scope[variablesName] = $scope.variables;
ParseTypeChange({
scope: $scope,
variable: 'variables',
variable: variablesName,
parse_variable: 'parseType',
field_id: `${$scope.name}_variables`,
readOnly: $scope.disabled
@@ -37,10 +38,11 @@ function atCodeMirrorController (
// 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;
// New set of variables from the modal, reinit codemirror
ParseTypeChange({
scope: $scope,
variable: 'variables',
variable: variablesName,
parse_variable: 'parseType',
field_id: `${$scope.name}_variables`,
readOnly: $scope.disabled
@@ -56,6 +58,7 @@ function atCodeMirrorController (
vm.expanded = false;
vm.close = close;
vm.expand = expand;
vm.variablesName = variablesName;
if ($scope.init) {
$scope.init = init;
}

View File

@@ -23,7 +23,7 @@
type="radio"
value="yaml"
ng-model="parseType"
ng-change="parseTypeChange('parseType', 'variables')"
ng-change="parseTypeChange('parseType', vm.variablesName)"
class="ng-pristine ng-untouched ng-valid ng-not-empty">
{{ vm.strings.get('label.YAML')}}
</label>
@@ -32,7 +32,7 @@
type="radio"
value="json"
ng-model="parseType"
ng-change="parseTypeChange('parseType', 'variables')"
ng-change="parseTypeChange('parseType', vm.variablesName)"
class="ng-pristine ng-untouched ng-valid ng-not-empty">
{{ vm.strings.get('label.JSON')}}
</label>

View File

@@ -13,7 +13,7 @@ function atCodeMirrorModalController (
ParseTypeChange
) {
const vm = this;
const variablesName = `${$scope.name}_variables`;
// const variablesName = `${$scope.name}_variables`;
function resize () {
if ($scope.disabled === 'true') {
$scope.disabled = true;
@@ -53,8 +53,6 @@ function atCodeMirrorModalController (
minWidth: 600
});
$(`${CodeMirrorModalID} .modal-dialog`).on('resize', resize);
$scope.foovars = 'testing';
}
vm.strings = strings;