From 1b94b616f0f34dfd173714318c43267e4697e0df Mon Sep 17 00:00:00 2001 From: mabashian Date: Tue, 26 Feb 2019 15:58:28 -0500 Subject: [PATCH] Default empty max hosts to 0 --- .../src/organizations/add/organizations-add.controller.js | 5 ++++- .../src/organizations/edit/organizations-edit.controller.js | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/awx/ui/client/src/organizations/add/organizations-add.controller.js b/awx/ui/client/src/organizations/add/organizations-add.controller.js index f13a9b09c6..cd6aea6cb9 100644 --- a/awx/ui/client/src/organizations/add/organizations-add.controller.js +++ b/awx/ui/client/src/organizations/add/organizations-add.controller.js @@ -46,6 +46,9 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', for (fld in form.fields) { params[fld] = $scope[fld]; } + if (!params.max_hosts || params.max_hosts === '') { + params.max_hosts = 0; + } var url = GetBasePath(base); url += (base !== 'organizations') ? $stateParams.project_id + '/organizations/' : ''; Rest.setUrl(url); @@ -71,7 +74,7 @@ export default ['$scope', '$rootScope', '$location', '$stateParams', let explanation = _.has(data, "name") ? data.name[0] : ""; ProcessErrors($scope, data, status, OrganizationForm, { hdr: 'Error!', - msg: `Failed to save organization. PUT status: ${status}. ${explanation}` + msg: `Failed to save organization. POST status: ${status}. ${explanation}` }); }); }; diff --git a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js index c6a54eca5a..a847068d49 100644 --- a/awx/ui/client/src/organizations/edit/organizations-edit.controller.js +++ b/awx/ui/client/src/organizations/edit/organizations-edit.controller.js @@ -56,7 +56,7 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup', $scope.organization_name = data.name; for (fld in form.fields) { - if (data[fld]) { + if (typeof data[fld] !== 'undefined') { $scope[fld] = data[fld]; master[fld] = data[fld]; } @@ -97,6 +97,9 @@ export default ['$scope', '$location', '$stateParams', 'OrgAdminLookup', for (fld in form.fields) { params[fld] = $scope[fld]; } + if (!params.max_hosts || params.max_hosts === '') { + params.max_hosts = 0; + } Rest.setUrl(defaultUrl + id + '/'); Rest.put(params) .then(() => {