From c96b3172020aaf1d1fd4666f26cf7cc9e5d2f48f Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Tue, 2 Dec 2014 10:06:57 -0500 Subject: [PATCH] Launch job from job template form added a check that there is a valid survey if survey_enabled === true on the JT form --- awx/ui/static/js/controllers/JobTemplates.js | 29 ++++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index c39bd1a130..c2fdf4464d 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -993,10 +993,33 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP // Launch a job using the selected template $scope.launch = function() { - PlaybookRun({ - scope: $scope, - id: id + + if ($scope.removePromptForSurvey) { + $scope.removePromptForSurvey(); + } + $scope.removePromptForSurvey = $scope.$on('PromptForSurvey', function() { + var action = function () { + // $scope.$emit("GatherFormFields"); + Wait('start'); + $('#prompt-modal').modal('hide'); + $scope.addSurvey(); + + }; + Prompt({ + hdr: 'Incomplete Survey', + body: 'Do you want to create a survey before proceeding?', + action: action + }); }); + + if($scope.survey_enabled === true && $scope.survey_exists!==true){ + $scope.$emit("PromptForSurvey"); + } + else + PlaybookRun({ + scope: $scope, + id: id + }); }; // handler for 'Enable Survey' button