diff --git a/awx/ui/static/js/controllers/JobTemplates.js b/awx/ui/static/js/controllers/JobTemplates.js index c41c593e86..922704cecc 100644 --- a/awx/ui/static/js/controllers/JobTemplates.js +++ b/awx/ui/static/js/controllers/JobTemplates.js @@ -111,7 +111,7 @@ JobTemplatesList.$inject = ['$scope', '$rootScope', '$location', '$log', '$route function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routeParams, JobTemplateForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ReturnToCaller, ClearScope, GetBasePath, InventoryList, CredentialList, ProjectList, LookUpInit, md5Setup, ParseTypeChange, Wait, Empty, ToJSON, - CallbackHelpInit) { + CallbackHelpInit, Store) { ClearScope(); @@ -124,6 +124,7 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa selectPlaybook, checkSCMStatus, callback; + $scope.Store = Store; CallbackHelpInit({ scope: $scope }); generator.inject(form, { mode: 'add', related: false, scope: $scope }); @@ -273,6 +274,118 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa input_type: "radio" }); + if ($scope.removeLoadJobs) { + $scope.rmoveLoadJobs(); + } + $scope.removeLoadJobs = $scope.$on('LoadJobs', function() { + // Retrieve detail record and prepopulate the form + var i, fld, data = $scope.Store("saved_job_template_for_survey").fields; + for (fld in form.fields) { + if (fld !== 'variables' && data[fld] !== null && data[fld] !== undefined) { + if (form.fields[fld].type === 'select') { + if(fld==="playbook"){ + $scope[fld+"_options"] = data[fld+"_options"]; + for (i = 0; i < $scope[fld + '_options'].length; i++) { + if (data[fld] === $scope[fld + '_options'][i]) { + $scope[fld] = $scope[fld + '_options'][i]; + } + } + } + if ($scope[fld + '_options'] && $scope[fld + '_options'].length > 0) { + for (i = 0; i < $scope[fld + '_options'].length; i++) { + if (data[fld] === $scope[fld + '_options'][i].value) { + $scope[fld] = $scope[fld + '_options'][i]; + } + } + } else { + $scope[fld] = data[fld]; + } + } else { + $scope[fld] = data[fld]; + if ( fld === "inventory" || fld === 'project' || fld === "credential" || fld === "cloud_credential"){ + $scope[fld+"_name"] = data[fld+"_name"]; + } + + // if (fld === 'variables') { + // // Parse extra_vars, converting to YAML. + // $scope.variables = ParseVariableString(data.extra_vars); + // master.variables = $scope.variables; + // } + if(fld ==='survey_enabled'){ + $('#job_templates_survey_enabled_chbox').attr('checked', $scope[fld]); + $('#job_templates_delete_survey_btn').show(); + $('#job_templates_edit_survey_btn').show(); + $('#job_templates_create_survey_btn').hide(); + // } + } + } + master[fld] = $scope[fld]; + } + } + // if (fld === 'variables') { + // // Parse extra_vars, converting to YAML. + // $scope.variables = ParseVariableString(data.extra_vars); + // master.variables = $scope.variables; + // } + + $scope.ask_variables_on_launch = (data.ask_variables_on_launch) ? 'true' : 'false'; + master.ask_variables_on_launch = $scope.ask_variables_on_launch; + + // relatedSets = form.relatedSets(data.related); + + if (data.host_config_key) { + $scope.example_config_key = data.host_config_key; + } + // $scope.example_template_id = id; + // $scope.setCallbackHelp(); + + // $scope.callback_url = $scope.callback_server_path + ((data.related.callback) ? data.related.callback : + // GetBasePath('job_templates') + id + '/callback/'); + // master.callback_url = $scope.callback_url; + + LookUpInit({ + scope: $scope, + form: form, + current_item: data.inventory, + list: InventoryList, + field: 'inventory', + input_type: "radio" + }); + + LookUpInit({ + url: GetBasePath('credentials') + '?kind=ssh', + scope: $scope, + form: form, + current_item: data.credential, + list: CredentialList, + field: 'credential', + hdr: 'Select Machine Credential', + input_type: "radio" + }); + + LookUpInit({ + scope: $scope, + form: form, + current_item: data.project, + list: ProjectList, + field: 'project', + input_type: "radio" + }); + }); + + if(Empty($scope.Store("saved_job_template_for_survey"))===false){ + $scope.$emit("LoadJobs"); + } + + $scope.$on("$destroy", function(){ + // alert('are you sure you wana leave?'); + if($scope.Store("saved_job_template_for_survey").editing_survey!==true){ + $scope.Store("saved_job_template_for_survey", false); + $scope.Store('survey_for_new_job_template' , false); + } + + }); + function saveCompleted() { setTimeout(function() { $scope.$apply(function() { $location.path('/job_templates'); }); }, 500); } @@ -313,6 +426,24 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa Rest.post(data) .success(function(data) { $scope.$emit('templateSaveSuccess', data); + $scope.Store("saved_job_template_for_survey", false); + + + var url = data.url+ 'survey_spec/', + survey = $scope.Store('survey_for_new_job_template'); + Rest.setUrl(url); + Rest.post({ name: survey.name, description: survey.description, spec: survey.spec }) + .success(function () { + Wait('stop'); + $scope.Store("survey_for_new_job_template", false); + // $location.path("/job_templates/"+id); + + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new survey. Post returned status: ' + status }); + }); + // $scope.$emit('templateSaveSuccess', data); }) .error(function (data, status) { ProcessErrors($scope, data, status, form, { hdr: 'Error!', @@ -335,17 +466,68 @@ function JobTemplatesAdd($scope, $rootScope, $compile, $location, $log, $routePa $scope[fld] = master[fld]; } }; + //navigate to the survey maker + $scope.editSurvey = function() { + $location.path($location.path() + '/survey/edit'); + }; + //delete a survey by posting a blank survey + $scope.deleteSurvey = function() { + // $location.path($location.path() + '/survey/add'); + // Wait('start'); + // var url = defaultUrl+ id + '/survey_spec/'; + + // Rest.setUrl(url); + // Rest.post({}) + // .success(function () { + $scope.Store("survey_for_new_job_template", false); + Wait('stop'); + $('#job_templates_delete_survey_btn').hide(); + $('#job_templates_edit_survey_btn').hide(); + $('#job_templates_create_survey_btn').show(); + + // }) + // .error(function (data, status) { + // ProcessErrors($scope, data, status, form, { hdr: 'Error!', + // msg: 'Failed to add new survey. Post returned status: ' + status }); + // }); + }; //navigate to the survey maker $scope.addSurvey = function() { - $location.path($location.path() + '/survey/add'); + var data = {}, fld; + try { + for (fld in form.fields) { + if (form.fields[fld].type === 'select' && fld !== 'playbook') { + data[fld] = $scope[fld].value; + } else { + if (fld !== 'variables') { + data[fld] = $scope[fld]; + if(fld === "inventory" || fld === "project" || fld === "credential" || fld === "cloud_credential" ){ + data[fld+"_name"] = $scope[fld + "_name"]; + } + if(fld === "playbook"){ + data[fld+"_options"] = $scope[fld+"_options"]; + } + } + } + } + data.extra_vars = ToJSON($scope.parseType, $scope.variables, true); + $scope.Store("saved_job_template_for_survey", { + "editing_survey" : true, + "fields" : data + }); + $location.path($location.path() + '/survey/add'); + } catch (err) { + Wait('stop'); + Alert("Error", "Error parsing extra variables. Parser returned: " + err); + } }; } JobTemplatesAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm', 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ReturnToCaller', 'ClearScope', 'GetBasePath', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit', - 'md5Setup', 'ParseTypeChange', 'Wait', 'Empty', 'ToJSON', 'CallbackHelpInit' + 'md5Setup', 'ParseTypeChange', 'Wait', 'Empty', 'ToJSON', 'CallbackHelpInit', 'Store' ]; @@ -353,7 +535,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP Alert, ProcessErrors, LoadBreadCrumbs, RelatedSearchInit, RelatedPaginateInit, ReturnToCaller, ClearScope, InventoryList, CredentialList, ProjectList, LookUpInit, GetBasePath, md5Setup, ParseTypeChange, JobStatusToolTip, FormatDate, Wait, Stream, Empty, Prompt, ParseVariableString, ToJSON, SchedulesControllerInit, JobsControllerInit, JobsListUpdate, - GetChoices, SchedulesListInit, SchedulesList, CallbackHelpInit, PlaybookRun) + GetChoices, SchedulesListInit, SchedulesList, CallbackHelpInit, PlaybookRun, Store) { ClearScope(); @@ -369,6 +551,8 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP checkSCMStatus, getPlaybooks, callback, choicesCount = 0; + $scope.Store = Store; + CallbackHelpInit({ scope: $scope }); SchedulesList.well = false; @@ -595,6 +779,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP $scope.removeEnableSurvey(); } $scope.removeEnableSurvey = $scope.$on('EnableSurvey', function(fld) { + $('#job_templates_survey_enabled_chbox').attr('checked', $scope[fld]); Rest.setUrl(defaultUrl + id+ '/survey_spec/'); Rest.get() @@ -642,8 +827,19 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP } } else { $scope[fld] = data[fld]; - if(fld ==='survey_enabled' && $scope[fld]===true){ - $scope.$emit('EnableSurvey', fld); + if(fld ==='survey_enabled'){ + // $scope.$emit('EnableSurvey', fld); + $('#job_templates_survey_enabled_chbox').attr('checked', $scope[fld]); + if(Empty(data.related.survey_spec)){ + $('#job_templates_delete_survey_btn').hide(); + $('#job_templates_edit_survey_btn').hide(); + $('#job_templates_create_survey_btn').show(); + } + else{ + $('#job_templates_delete_survey_btn').show(); + $('#job_templates_edit_survey_btn').show(); + $('#job_templates_create_survey_btn').hide(); + } } } master[fld] = $scope[fld]; @@ -848,6 +1044,31 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP }); }; + //handler for 'Enable Survey' button + $scope.surveyEnabled = function(){ + Rest.setUrl(defaultUrl + id+ '/'); + Rest.patch({"survey_enabled": $scope.survey_enabled}) + .success(function (data) { + + if(Empty(data.related.survey_spec)){ + $('#job_templates_delete_survey_btn').hide(); + $('#job_templates_edit_survey_btn').hide(); + $('#job_templates_create_survey_btn').show(); + } + else{ + $('#job_templates_delete_survey_btn').show(); + $('#job_templates_edit_survey_btn').show(); + $('#job_templates_create_survey_btn').hide(); + } + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { + hdr: 'Error!', + msg: 'Failed to retrieve save survey_enabled: ' + $routeParams.template_id + '. GET status: ' + status + }); + }); + }; + //navigate to the survey maker $scope.addSurvey = function() { $location.path($location.path() + '/survey/add'); @@ -855,6 +1076,7 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP //navigate to the survey maker $scope.editSurvey = function() { + $scope.Store("survey_for_new_job_template", false); $location.path($location.path() + '/survey/edit'); }; @@ -911,9 +1133,9 @@ function JobTemplatesEdit($scope, $rootScope, $compile, $location, $log, $routeP } JobTemplatesEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'JobTemplateForm', - 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', + 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'RelatedSearchInit', 'RelatedPaginateInit', 'ReturnToCaller', 'ClearScope', 'InventoryList', 'CredentialList', 'ProjectList', 'LookUpInit', 'GetBasePath', 'md5Setup', 'ParseTypeChange', 'JobStatusToolTip', 'FormatDate', 'Wait', 'Stream', 'Empty', 'Prompt', 'ParseVariableString', 'ToJSON', 'SchedulesControllerInit', 'JobsControllerInit', 'JobsListUpdate', 'GetChoices', - 'SchedulesListInit', 'SchedulesList', 'CallbackHelpInit', 'PlaybookRun' + 'SchedulesListInit', 'SchedulesList', 'CallbackHelpInit', 'PlaybookRun' , "Store" ]; \ No newline at end of file diff --git a/awx/ui/static/js/controllers/SurveyMaker.js b/awx/ui/static/js/controllers/SurveyMaker.js index 62d3ae65d4..fa03ce401b 100644 --- a/awx/ui/static/js/controllers/SurveyMaker.js +++ b/awx/ui/static/js/controllers/SurveyMaker.js @@ -10,13 +10,27 @@ /** * @ngdoc function * @name controllers.function:SurveyMaker - * @description This controller's for the survey maker page + * @description This controller's for the survey maker page. + * The survey maker interacts with the job template page, and the two go hand in hand. The scenarios are: + * New job template - add new survey + * New job template - edit new survey + * Edit existing job template - add new survey + * Edit Existing job template - edit existing survey + * + * Adding a new survey to any page takes the user to the Add New Survey page + * Adding a new survey to a new job template saves the survey to session memory (navigating to survey maker forces us to save JT in memory temporarily) + * Adding a new survey to an existing job template send the survey to the API + * Editing an existing survey takes the user to the Edit Survey page + * Editing a survey attached to a new job template saves the survey to session memory (saves the job template in session memory) + * Editing a survey attached to an existing job template saves the survey to the API + * + * The variables in local memory are cleaned out whenever the user navigates to a page (other than the Survey Maker page) */ 'use strict'; function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routeParams, SurveyMakerForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, - ReturnToCaller, Wait, SurveyQuestionForm) { + ReturnToCaller, Wait, SurveyQuestionForm, Store) { ClearScope(); @@ -27,7 +41,7 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar id = $location.path().replace(/^\//, '').split('/')[1]; $scope.survey_questions=[]; - + $scope.Store = Store; $scope.answer_types=[ {name: 'Text' , type: 'text'}, {name: 'Textarea', type: 'textarea'}, @@ -152,22 +166,65 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar Alert("Error", "Error parsing extra variables. Parser returned: " + err); } }; + + $scope.formSave = function () { + generator.clearApiErrors(); + Wait('start'); + var url; + if(!$scope.Store("survey_for_new_job_template") && $scope.Store("survey_for_new_job_template")!==false){ + $scope.Store('survey_for_new_job_template', { + // survey_created: true, + name: $scope.survey_name, + description: $scope.survey_description, + spec:$scope.survey_questions + }); + Wait('stop'); + $location.path("/job_templates/add/"); + } + else { + url = GetBasePath(base)+ id + '/survey_spec/'; + + Rest.setUrl(url); + Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) + .success(function () { + Wait('stop'); + $location.path("/job_templates/"+id); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new survey. Post returned status: ' + status }); + }); + } + }; + // Save $scope.formSave = function () { generator.clearApiErrors(); Wait('start'); - var url = GetBasePath(base)+ id + '/survey_spec/'; - - Rest.setUrl(url); - Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) - .success(function () { - Wait('stop'); - $location.path("/job_templates/"+id); - }) - .error(function (data, status) { - ProcessErrors($scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to add new survey. Post returned status: ' + status }); + if($scope.Store("saved_job_template_for_survey")){ + $scope.Store('survey_for_new_job_template', { + // survey_created: true, + name: $scope.survey_name, + description: $scope.survey_description, + spec:$scope.survey_questions }); + Wait('stop'); + $location.path("/job_templates/add/"); + } + else{ + var url = GetBasePath(base)+ id + '/survey_spec/'; + Rest.setUrl(url); + Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) + .success(function () { + Wait('stop'); + $location.path("/job_templates/"+id); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new survey. Post returned status: ' + status }); + }); + } + }; // Cancel @@ -178,12 +235,12 @@ function SurveyMakerAdd($scope, $rootScope, $compile, $location, $log, $routePar } SurveyMakerAdd.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'SurveyMakerForm', - 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm' + 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm', 'Store' ]; function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routeParams, SurveyMakerForm, GenerateForm, Rest, Alert, ProcessErrors, LoadBreadCrumbs, ClearScope, GetBasePath, - ReturnToCaller, Wait, SurveyQuestionForm) { + ReturnToCaller, Wait, SurveyQuestionForm, Store) { ClearScope(); @@ -191,7 +248,8 @@ function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routePa var generator = GenerateForm, form = SurveyMakerForm, base = $location.path().replace(/^\//, '').split('/')[0], - id = $location.path().replace(/^\//, '').split('/')[1]; + id = $location.path().replace(/^\//, '').split('/')[1], + i, data; $scope.survey_questions=[]; @@ -205,6 +263,7 @@ function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routePa {name: 'Float', type: 'number'} ]; + $scope.Store = Store; generator.inject(form, { mode: 'edit', related: false, scope: $scope}); generator.reset(); @@ -291,45 +350,56 @@ function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routePa Wait('start'); - Rest.setUrl(GetBasePath(base)+ id + '/survey_spec/'); - Rest.get() - .success(function (data) { - var i; - $scope.survey_name = data.name; - $scope.survey_description = data.description; - $scope.survey_questions = data.spec; - for(i=0; i<$scope.survey_questions.length; i++){ - $scope.finalizeQuestion($scope.survey_questions[i]); - } - Wait('stop'); - // LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name }); - // for (fld in form.fields) { - // if (data[fld]) { - // $scope[fld] = data[fld]; - // master[fld] = data[fld]; - // } - // } + if($scope.Store("saved_job_template_for_survey") && $scope.Store("saved_job_template_for_survey").editing_survey===true){ + data = $scope.Store("survey_for_new_job_template"); + $scope.survey_name = data.name; + $scope.survey_description = data.description; + $scope.survey_questions = data.spec; + for(i=0; i<$scope.survey_questions.length; i++){ + $scope.finalizeQuestion($scope.survey_questions[i]); + } + Wait('stop'); + } + else{ + Rest.setUrl(GetBasePath(base)+ id + '/survey_spec/'); + Rest.get() + .success(function (data) { + var i; + $scope.survey_name = data.name; + $scope.survey_description = data.description; + $scope.survey_questions = data.spec; + for(i=0; i<$scope.survey_questions.length; i++){ + $scope.finalizeQuestion($scope.survey_questions[i]); + } + Wait('stop'); + // LoadBreadCrumbs({ path: '/organizations/' + id, title: data.name }); + // for (fld in form.fields) { + // if (data[fld]) { + // $scope[fld] = data[fld]; + // master[fld] = data[fld]; + // } + // } - // related = data.related; - // for (set in form.related) { - // if (related[set]) { - // relatedSets[set] = { - // url: related[set], - // iterator: form.related[set].iterator - // }; - // } - // } - - // Initialize related search functions. Doing it here to make sure relatedSets object is populated. - // RelatedSearchInit({ scope: $scope, form: form, relatedSets: relatedSets }); - // RelatedPaginateInit({ scope: $scope, relatedSets: relatedSets }); - // $scope.$emit('organizationLoaded'); - }) - .error(function (data, status) { - ProcessErrors($scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status }); - }); + // related = data.related; + // for (set in form.related) { + // if (related[set]) { + // relatedSets[set] = { + // url: related[set], + // iterator: form.related[set].iterator + // }; + // } + // } + // Initialize related search functions. Doing it here to make sure relatedSets object is populated. + // RelatedSearchInit({ scope: $scope, form: form, relatedSets: relatedSets }); + // RelatedPaginateInit({ scope: $scope, relatedSets: relatedSets }); + // $scope.$emit('organizationLoaded'); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to retrieve organization: ' + $routeParams.id + '. GET status: ' + status }); + }); + } $scope.submitQuestion = function(){ var form = SurveyQuestionForm, data = {}, @@ -375,18 +445,31 @@ function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routePa $scope.formSave = function () { generator.clearApiErrors(); Wait('start'); - var url = GetBasePath(base)+ id + '/survey_spec/'; - - Rest.setUrl(url); - Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) - .success(function () { - Wait('stop'); - $location.path("/job_templates/"+id); - }) - .error(function (data, status) { - ProcessErrors($scope, data, status, form, { hdr: 'Error!', - msg: 'Failed to add new survey. Post returned status: ' + status }); + var url; + if($scope.Store("survey_for_new_job_template") && $scope.Store("survey_for_new_job_template")!==false){ + $scope.Store('survey_for_new_job_template', { + // survey_created: true, + name: $scope.survey_name, + description: $scope.survey_description, + spec:$scope.survey_questions }); + Wait('stop'); + $location.path("/job_templates/add/"); + } + else { + url = GetBasePath(base)+ id + '/survey_spec/'; + + Rest.setUrl(url); + Rest.post({ name: $scope.survey_name, description: $scope.survey_description, spec:$scope.survey_questions }) + .success(function () { + Wait('stop'); + $location.path("/job_templates/"+id); + }) + .error(function (data, status) { + ProcessErrors($scope, data, status, form, { hdr: 'Error!', + msg: 'Failed to add new survey. Post returned status: ' + status }); + }); + } }; // Cancel @@ -397,7 +480,7 @@ function SurveyMakerEdit($scope, $rootScope, $compile, $location, $log, $routePa } SurveyMakerEdit.$inject = ['$scope', '$rootScope', '$compile', '$location', '$log', '$routeParams', 'SurveyMakerForm', - 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm' + 'GenerateForm', 'Rest', 'Alert', 'ProcessErrors', 'LoadBreadCrumbs', 'ClearScope', 'GetBasePath', 'ReturnToCaller', 'Wait', 'SurveyQuestionForm', 'Store' ]; diff --git a/awx/ui/static/js/forms/JobTemplates.js b/awx/ui/static/js/forms/JobTemplates.js index 17e2c1cb84..285ece44b9 100644 --- a/awx/ui/static/js/forms/JobTemplates.js +++ b/awx/ui/static/js/forms/JobTemplates.js @@ -65,7 +65,7 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet job_type: { label: 'Job Type', type: 'select', - ngOptions: 'type.label for type in job_type_options', + ngOptions: 'type.label for type in job_type_options track by type.value', "default": 0, addRequired: true, editRequired: true, @@ -106,7 +106,7 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet playbook: { label: 'Playbook', type:'select', - ngOptions: 'book for book in playbook_options', + ngOptions: 'book for book in playbook_options track by book', id: 'playbook-select', awRequiredWhen: {variable: "playbookrequired", init: "true" }, column: 1, @@ -180,7 +180,7 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet verbosity: { label: 'Verbosity', type: 'select', - ngOptions: 'v.label for v in verbosity_options', + ngOptions: 'v.label for v in verbosity_options track by v.value', "default": 0, addRequired: true, editRequired: true, @@ -261,6 +261,7 @@ angular.module('JobTemplateFormDefinition', ['SchedulesListDefinition', 'Complet editRequird: false, trueValue: 'true', falseValue: 'false', + ngChange: "surveyEnabled()", column: 2, awPopOver: "
If checked, user will be prompted at job launch with a series of questions related to the job.
", dataPlacement: 'right', diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index 8d467f0f83..97a7b21870 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -69,7 +69,7 @@ angular.module('SurveyQuestionFormDefinition', []) realName: 'answer_type', label: 'Answer Type', type: 'select', - ngOptions: 'answer_types.name for answer_types in answer_types', + ngOptions: 'answer_types.name for answer_types in answer_types track by answer_types.type', addRequired: true, editRequired: true, column: 1