diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js index a0ef474193..40f692d474 100644 --- a/awx/ui/static/js/forms/SurveyQuestion.js +++ b/awx/ui/static/js/forms/SurveyQuestion.js @@ -142,6 +142,27 @@ export default editRequired: true, column: 2 }, + password_options: { + realName: 'answer_options', + type: 'custom', + control:'
'+ + '
'+ + ''+ + '
The minimum length you entered is not a number. Please enter a number.
'+ + '
The minimium length is too high. Please enter a lower number.
'+ + '
The minimum length is too low. Please enter a positive number.
'+ + '
'+ + '
'+ + ''+ + '
The maximum length you entered is not a number. Please enter a number.
'+ + '
The maximum length is too low. Please enter a number larger than the minimum length you set.
'+ + '
'+ + '
', + ngShow: 'type.type==="password" ', + addRequired: true, + editRequired: true, + column: 2 + }, int_options: { realName: 'answer_options', type: 'custom', @@ -189,7 +210,7 @@ export default control: '
'+ ''+ '
'+ - ''+ + ''+ '
Please enter an answer for the choices listed.
' + '
The answer is shorter than the minimium length. Please make the answer longer.
' + '
The answer is longer than the maximum length. Please make the answer shorter.
' + @@ -197,7 +218,7 @@ export default '
'+ '
', column: 2, - ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" ' + ngShow: 'type.type === "text" || type.type === "multiplechoice" ' }, default_multiselect: { realName: 'default_answer' , @@ -243,7 +264,7 @@ export default control: '
'+ ''+ '
'+ - ''+ + ''+ '
The answer is shorter than the minimium length. Please make the answer longer.
' + '
The answer is longer than the maximum length. Please make the answer shorter.
' + '
'+ @@ -252,6 +273,23 @@ export default column : 2, ngShow: 'type.type === "textarea" ' }, + default_password: { + realName: 'default_answer' , + type: 'custom' , + control: '
'+ + ''+ + '
'+ + ''+ + ''+ + ''+ + '
The answer is shorter than the minimium length. Please make the answer longer.
' + + '
The answer is longer than the maximum length. Please make the answer shorter.
' + + '
'+ + '
'+ + '
', + column: 2, + ngShow: 'type.type === "password" ' + }, required: { realName: 'required_answer', label: 'Required', diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index df9e045bf7..cd6a85c46e 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -473,7 +473,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H relatedSets = {}, buttons, url, form_scope; - var form_scope = + form_scope = generator.inject(HostForm, { mode: 'edit', id: 'host-modal-dialog', breadCrumbs: false, related: false, scope: scope }); generator.reset(); @@ -1307,4 +1307,3 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H } }; }]); - diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js index 365837a2cf..d352f6c4ce 100644 --- a/awx/ui/static/js/helpers/JobSubmission.js +++ b/awx/ui/static/js/helpers/JobSubmission.js @@ -556,7 +556,32 @@ angular.module('JobSubmissionHelper', [ 'RestServices', 'Utilities', 'Credential 'job_launch_form.'+question.variable+'.$error.maxlength\">Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ '
'; } + if(question.type === 'password' ){ + minlength = (!Empty(question.min)) ? Number(question.min) : ""; + maxlength =(!Empty(question.max)) ? Number(question.max) : "" ; + html+=''+ + '
Please enter an answer.
'+ + '
Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ + '
'; + html+=''+ + '
Please enter an answer.
'+ + '
Please enter an answer between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+ + '
'; + html+= ''; + } if(question.type === 'multiplechoice'){ choices = question.choices.split(/\n/); element = (question.type==="multiselect") ? "checkbox" : 'radio'; diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js index 233eb94121..042062e76d 100644 --- a/awx/ui/static/js/helpers/Survey.js +++ b/awx/ui/static/js/helpers/Survey.js @@ -324,6 +324,17 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', html += '
'; } + if(question.type === 'password'){ + defaultValue = (question.default) ? question.default : ""; + defaultValue = defaultValue.replace(//g, ">"); + defaultValue = scope.serialize(defaultValue); + html+='
'+ + '
'+ + ''+ + '
'; + } + if(question.type === 'integer'){ min = (!Empty(question.min)) ? question.min : ""; max = (!Empty(question.max)) ? question.max : "" ; @@ -430,6 +441,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.int_max = null; scope.float_min = null; scope.float_max = null; + scope.password_min = null; + scope.password_max = null; + scope.pwcheckbox = false; if (scope.removeFillQuestionForm) { scope.removeFillQuestionForm(); @@ -455,6 +469,11 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.textarea_max = question.max; scope.default_textarea= question.default; } + if(question.type === 'password'){ + scope.password_min = question.min; + scope.password_max = question.max; + scope.default_password = question.default; + } if( question.type === 'integer'){ scope.int_min = question.min; scope.int_max = question.max; @@ -501,6 +520,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.answer_types=[ {name: 'Text' , type: 'text'}, {name: 'Textarea', type: 'textarea'}, + {name: 'Password', type: 'password'}, {name: 'Multiple Choice (single select)', type: 'multiplechoice'}, {name: 'Multiple Choice (multiple select)', type: 'multiselect'}, {name: 'Integer', type: 'integer'}, @@ -738,6 +758,8 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.text_max = "" ; scope.textarea_min = ""; scope.textarea_max = "" ; + scope.password_min = "" ; + scope.password_max = "" ; scope.int_min = ""; scope.int_max = ""; scope.float_min = ""; @@ -747,6 +769,7 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', scope.survey_question_form.default_float.$setPristine(); scope.survey_question_form.default_int.$setPristine(); scope.survey_question_form.default_textarea.$setPristine(); + scope.survey_question_form.default_password.$setPristine(); scope.survey_question_form.choices.$setPristine(); scope.survey_question_form.int_min.$setPristine(); scope.survey_question_form.int_max.$setPristine(); @@ -758,7 +781,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', choiceArray, answerArray, key, elementID; - // Wait('start'); scope.invalidChoice = false; scope.duplicate = false; scope.minTextError = false; @@ -786,6 +808,17 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', } } + if(scope.type.type==="password"){ + if(scope.default_password.trim() !== ""){ + if(scope.default_password.trim().length < scope.password_min && scope.password_min !== "" ){ + scope.minTextError = true; + } + if(scope.password_max < scope.default_password.trim().length && scope.password_max !== "" ){ + scope.maxTextError = true; + } + } + } + if(scope.type.type==="multiselect" && scope.default_multiselect.trim() !== ""){ choiceArray = scope.choices.split(/\n/); answerArray = scope.default_multiselect.split(/\n/); @@ -844,7 +877,6 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', } if(scope.duplicate===true || scope.invalidChoice===true || scope.minTextError === true || scope.maxTextError === true){ - // Wait('stop'); return; } @@ -855,9 +887,9 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper', data.required = scope.required; data.type = scope.type.type; data.variable = scope.variable; - data.min = (scope.type.type === 'text') ? scope.text_min : (scope.type.type === 'textarea') ? scope.textarea_min : (scope.type.type === "float") ? scope.float_min : (scope.type.type==="integer") ? scope.int_min : "" ; - data.max = (scope.type.type === 'text') ? scope.text_max : (scope.type.type === 'textarea') ? scope.textarea_max : (scope.type.type === "float") ? scope.float_max : (scope.type.type==="integer") ? scope.int_max : "" ; - data.default = (scope.type.type === 'textarea') ? scope.default_textarea : (scope.type.type === "float") ? scope.default_float : (scope.type.type==="integer") ? scope.default_int : (scope.type.type === "multiselect") ? scope.default_multiselect : (scope.default) ? scope.default : "" ; + data.min = (scope.type.type === 'text') ? scope.text_min : (scope.type.type === 'textarea') ? scope.textarea_min : (scope.type.type === 'password') ? scope.password_min : (scope.type.type === "float") ? scope.float_min : (scope.type.type==="integer") ? scope.int_min : "" ; + data.max = (scope.type.type === 'text') ? scope.text_max : (scope.type.type === 'textarea') ? scope.textarea_max : (scope.type.type === 'password') ? scope.password_max : (scope.type.type === "float") ? scope.float_max : (scope.type.type==="integer") ? scope.int_max : "" ; + data.default = (scope.type.type === 'textarea') ? scope.default_textarea : (scope.type.type === "float") ? scope.default_float : (scope.type.type==="integer") ? scope.default_int : (scope.type.type === "multiselect") ? scope.default_multiselect : (scope.type.type === "password") ? scope.default_password : (scope.default) ? scope.default : "" ; data.choices = (scope.type.type === "multiplechoice") ? scope.choices : (scope.type.type === 'multiselect') ? scope.choices : "" ; Wait('stop');