From c05d746d738ba2e92df8b42b6de75b13b0d3ad1b Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Thu, 4 Dec 2014 11:59:07 -0500 Subject: [PATCH] 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. --- awx/ui/static/js/helpers/Variables.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/awx/ui/static/js/helpers/Variables.js b/awx/ui/static/js/helpers/Variables.js index a1b2047eef..b8d2226201 100644 --- a/awx/ui/static/js/helpers/Variables.js +++ b/awx/ui/static/js/helpers/Variables.js @@ -87,6 +87,10 @@ angular.module('VariablesHelper', ['Utilities']) // lines, i, newVars = []; if (parseType === 'json') { try { + // perform a check to see if the user cleared the field completly + if(variables === "" ){ + variables = "{}"; + } //parse a JSON string if (reviver) { json_data = JSON.parse(variables, reviver); @@ -103,7 +107,7 @@ angular.module('VariablesHelper', ['Utilities']) } } else { try { - if(variables=== ""){ + if(variables === ""){ variables = '---'; } json_data = jsyaml.load(variables);