From c4108a6890af5357e17adff31a9705177f4d6d83 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Wed, 16 Oct 2013 14:45:37 +0000 Subject: [PATCH] Fix to properly handle empty extra_vars value. No longer sending 'null' to API. --- awx/ui/static/js/controllers/JobTemplates.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index 1a324a9893..ac59060f53 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -231,7 +231,12 @@ function JobTemplatesAdd ($scope, $rootScope, $compile, $location, $log, $routeP } } } + data.extra_vars = JSON.stringify(json_data, undefined, '\t'); + if (data.extra_vars == "null" || data.extra_vars == null) { + data.extra_vars = ""; + } + Rest.setUrl(defaultUrl); Rest.post(data) .success( function(data, status, headers, config) { @@ -413,7 +418,8 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route } if (fld == 'variables') { // Parse extra_vars, converting to YAML. - if ($.isEmptyObject(data.extra_vars) || data.extra_vars == "\{\}" || data.extra_vars == "null" || data.extra_vars = "") { + if ($.isEmptyObject(data.extra_vars) || data.extra_vars == "\{\}" || data.extra_vars == "null" + || data.extra_vars == "" || data.extra_vars == null) { scope.variables = "---"; } else { @@ -502,7 +508,12 @@ function JobTemplatesEdit ($scope, $rootScope, $compile, $location, $log, $route } } } + data.extra_vars = JSON.stringify(json_data, undefined, '\t'); + if (data.extra_vars == "null" || data.extra_vars == null) { + data.extra_vars = ""; + } + Rest.setUrl(defaultUrl + id + '/'); Rest.put(data) .success( function(data, status, headers, config) {