Fix to properly handle empty extra_vars value. No longer sending 'null' to API.

This commit is contained in:
chouseknecht
2013-10-16 14:45:37 +00:00
parent 9ff7f05dfc
commit c4108a6890

View File

@@ -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) {