diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index c5d00e2052..440db4f66d 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -116,6 +116,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi // url = params.url, e; + html+='
job_launch_form.$valid = {{job_launch_form.$valid}}
'; $('#password-modal').empty().html(html); $('#password-modal').find('textarea').before(scope.helpContainer); e = angular.element(document.getElementById('password-modal')); @@ -143,7 +144,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi id: 'password-modal', scope: scope, buttons: buttons, - width: 600, + width: 620, height: 700, //(scope.passwords.length > 1) ? 700 : 500, minWidth: 500, title: 'Launch Configuration', @@ -158,7 +159,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi } scope.removeDialogReady = scope.$on('DialogReady', function() { $('#password-modal').dialog('open'); - $('#password-accept-button').attr({ "disabled": "disabled" }); + $('#password-accept-button').attr('ng-disabled', 'job_launch_form.$invalid' ); + e = angular.element(document.getElementById('password-accept-button')); + $compile(e)(scope); }); }; @@ -174,22 +177,23 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi callback = params.callback || 'PasswordsAccepted', form = CredentialForm, acceptedPasswords = {}, - fld, field, html; + fld, field, + html=params.html || ""; scope.passwords = params.passwords; // Wait('stop'); - html = ""; + html += "
Launching this job requires the passwords listed below. Enter and confirm each password before continuing.
\n"; - html += "
\n"; + // html += "\n"; scope.passwords.forEach(function(password) { // Prompt for password field = form.fields[password]; fld = password; scope[fld] = ''; - html += "
\n"; - html += "\n"; + html += "
\n"; + html += "\n"; html += "A value is required!
\n"; + html += "
A value is required!
\n"; html += "
\n"; html += "
\n"; @@ -209,8 +213,8 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi fld = field.associated; field = form.fields[field.associated]; scope[fld] = ''; - html += "
\n"; - html += "\n"; + html += "
\n"; + html += "\n"; html += "A value is required!\n"; - html += (field.awPassMatch) ? "A value is required!\n"; + html += (field.awPassMatch) ? "Must match Password value
\n" : ""; html += "
\n"; html += "
\n"; } }); - html += "
\n"; + // html += "\n"; // $('#password-modal').empty().html(buildHtml); @@ -300,12 +304,12 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi scope.clearPWConfirm = function (fld) { // If password value changes, make sure password_confirm must be re-entered scope[fld] = ''; - scope.password_form[fld].$setValidity('awpassmatch', false); + scope.job_launch_form[fld].$setValidity('awpassmatch', false); scope.checkStatus(); }; scope.checkStatus = function() { - if (!scope.password_form.$invalid) { + if (!scope.job_launch_form.$invalid) { $('#password-accept-button').removeAttr('disabled'); } else { @@ -461,7 +465,6 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi choices, element, checked, min, max, - survey_url = GetBasePath('job_templates') + id + '/survey_spec/' ; @@ -469,50 +472,73 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi question.index = index; if(!$('#question_'+question.index+':eq(0)').is('div')){ - html+='
'; - $('#finalized_questions').append(html); + html+='
'; + $('#survey_taker_finalized_questions').append(html); } requiredAsterisk = (question.required===true) ? "prepend-asterisk" : ""; requiredClasses = (question.required===true) ? "ng-pristine ng-invalid-required ng-invalid" : ""; html += '
'+question.question_name+'
\n'; if(!Empty(question.question_description)){ - html += '
'+question.question_description+'
\n'; + html += '
'+question.question_description+'
\n'; } - + scope[question.variable] = question.default; if(question.type === 'text' ){ - defaultValue = (question.default) ? question.default : ""; + //defaultValue = (question.default) ? question.default : ""; + html+='
'+ '
'+ - ''+ - '
'; + ''+ + '
A value is required!
'+ + '
'+ + '
'+ + ''; + } if(question.type === "textarea"){ - defaultValue = (question.default) ? question.default : (question.default_textarea) ? question.default_textarea: "" ; + scope[question.variable] = question.default || question.default_textarea; html+='
'+ '
'+ - ''+ + ''+ + '
A value is required!
'+ + '
'+ '
'; } if(question.type === 'multiplechoice' || question.type === "multiselect"){ choices = question.choices.split(/\n/); element = (question.type==="multiselect") ? "checkbox" : 'radio'; question.default = (question.default) ? question.default : (question.default_multiselect) ? question.default_multiselect : "" ; + + html+='
'; + for( j = 0; j'+ - '' +choices[i]+ - ''; - } + // html+=''; + html+= '' + + ''+choices[j] +'
' ; + } + html+= '
A value is required!
'+ + '
'; + html+= '
'; } if(question.type === 'integer'){ - min = (!Empty(question.min)) ? question.min : ""; - max = (!Empty(question.max)) ? question.max : "" ; - defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_int)) ? question.default_int : "" ; + min = (!Empty(question.min)) ? Number(question.min) : ""; + max = (!Empty(question.max)) ? Number(question.max) : "" ; + //defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_int)) ? question.default_int : "" ; html+='
'+ '
'+ - ''+ + ''+ + '
This is not valid integer!
'+ + '
The value must be in range {{'+min+'}} to {{'+max+'}}!
'+ '
'; } @@ -522,10 +548,13 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_float)) ? question.default_float : "" ; html+='
'+ '
'+ - ''+ + ''+ + '
This is not valid float!
'+ + '
The value must be in range {{'+min+'}} to {{'+max+'}}!
'+ '
'; } + html+=''; if(question.index === scope.survey_questions.length-1){ CreateLaunchDialog({scope: scope, html: html}); } @@ -688,6 +717,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi survey_enabled, launch_url, prompt_for_vars = false, + html, passwords; scope.job_template_id = id; if (base === 'job_templates') { @@ -780,10 +810,11 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi if (scope.removePromptForPasswords) { scope.removePromptForPasswords(); } - scope.removePromptForPasswords = scope.$on('PromptForPasswords', function(e, passwords_needed_to_start) { + scope.removePromptForPasswords = scope.$on('PromptForPasswords', function(e, passwords_needed_to_start,html) { PromptForPasswords({ scope: scope, passwords: passwords_needed_to_start, - callback: 'PromptForVars' + callback: 'PromptForVars', + html: html }); }); @@ -859,17 +890,17 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi new_job_id = data.id; launch_url = url;//data.related.start; prompt_for_vars = data.ask_variables_on_launch; - extra_vars = data.variables_needed_to_start; survey_enabled = data.survey_enabled; // new_job = data; + html = '
'; if (data.passwords_needed_to_start.length > 0) { - scope.$emit('PromptForPasswords', data.passwords_needed_to_start); + scope.$emit('PromptForPasswords', data.passwords_needed_to_start, html); } else if (data.ask_variables_on_launch) { - scope.$emit('PromptForVars'); + scope.$emit('PromptForVars', html); } else if (data.survey_enabled===true) { - scope.$emit('PromptForSurvey'); + scope.$emit('PromptForSurvey', html); } else { scope.$emit('StartPlaybookRun');