Fixed empty Extra Variable JSON parsing issue

if the user saved a job template with empty extra variables and the Parse as option as JSON, then the UI crapped out. I added a check to make sure the default string is '{}' if the user submits an empty field.
This commit is contained in:
Jared Tabor
2014-12-04 11:59:07 -05:00
parent 3164c6d356
commit c05d746d73

View File

@@ -87,6 +87,10 @@ angular.module('VariablesHelper', ['Utilities'])
// lines, i, newVars = []; // lines, i, newVars = [];
if (parseType === 'json') { if (parseType === 'json') {
try { try {
// perform a check to see if the user cleared the field completly
if(variables === "" ){
variables = "{}";
}
//parse a JSON string //parse a JSON string
if (reviver) { if (reviver) {
json_data = JSON.parse(variables, reviver); json_data = JSON.parse(variables, reviver);
@@ -103,7 +107,7 @@ angular.module('VariablesHelper', ['Utilities'])
} }
} else { } else {
try { try {
if(variables=== ""){ if(variables === ""){
variables = '---'; variables = '---';
} }
json_data = jsyaml.load(variables); json_data = jsyaml.load(variables);