From 0bfe5dc6baebafa901c9c77b5924f5cf5f147bff Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Mon, 27 Oct 2014 16:48:34 -0400 Subject: [PATCH] Job Template Page-new JT w/ no survey Fixed a defect where the UI would attempt to save a survey spec even if survey_enabled=false --- awx/ui/static/js/controllers/JobTemplates.js | 25 +++++++++++--------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index fa22ecc88e..8295be57d2 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -339,18 +339,21 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa .success(function(data) { $scope.$emit('templateSaveSuccess', data); - //once the job template information is saved we submit the survey info to the correct endpoint - var url = data.url+ 'survey_spec/'; - Rest.setUrl(url); - Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec: $scope.survey_questions }) - .success(function () { - Wait('stop'); + if(data.survey_enabled===true){ + //once the job template information is saved we submit the survey info to the correct endpoint + var url = data.url+ 'survey_spec/'; + Rest.setUrl(url); + Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec: $scope.survey_questions }) + .success(function () { + Wait('stop'); + + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new survey. Post returned status: ' + status }); + }); + } - }) - .error(function (data, status) { - ProcessErrors($scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to add new survey. Post returned status: ' + status }); - }); }) .error(function (data, status) {