diff --git a/awx/ui/static/js/forms/SurveyQuestion.js b/awx/ui/static/js/forms/SurveyQuestion.js
index 5ce04d99bc..a37ef64ae1 100644
--- a/awx/ui/static/js/forms/SurveyQuestion.js
+++ b/awx/ui/static/js/forms/SurveyQuestion.js
@@ -97,26 +97,46 @@ angular.module('SurveyQuestionFormDefinition', [])
dataContainer: "body",
column: 2
},
- // text_options: {
- // realName: 'answer_options',
- // type: 'custom',
- // control:'
'+
- // '
'+
- // '
'+
- // '
This is not valid integer!
'+
- // '
Too high!
'+
- // '
'+
- // // '
'+
- // // '
'+
- // // '
This is not valid integer!
'+
- // // '
Too low!
'+
- // // '
'+
- // '
',
- // ngShow: 'type.type==="text" ',
- // addRequired: true,
- // editRequired: true,
- // column: 2
- // },
+ text_options: {
+ realName: 'answer_options',
+ type: 'custom',
+ control:''+
+ '
'+
+ '
'+
+ '
This is not valid integer!
'+
+ '
Too high!
'+
+ '
'+
+ '
'+
+ '
'+
+ '
This is not valid integer!
'+
+ '
Too low!
'+
+ '
'+
+ '
',
+ ngShow: 'type.type==="text" ',
+ addRequired: true,
+ editRequired: true,
+ column: 2
+ },
+ textarea_options: {
+ realName: 'answer_options',
+ type: 'custom',
+ control:''+
+ '
'+
+ '
'+
+ '
This is not valid integer!
'+
+ '
Too high!
'+
+ '
'+
+ '
'+
+ '
'+
+ '
This is not valid integer!
'+
+ '
Too low!
'+
+ '
'+
+ '
',
+ ngShow: 'type.type==="textarea" ',
+ addRequired: true,
+ editRequired: true,
+ column: 2
+ },
int_options: {
realName: 'answer_options',
type: 'custom',
@@ -165,14 +185,14 @@ angular.module('SurveyQuestionFormDefinition', [])
addRequired: false,
editRequired: false,
column: 2,
- ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" ' // type.type === "text" ||
+ ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" '
},
// default_text: {
// realName: 'default_answer',
// type: 'custom',
// control: ''+
// '
'+
- // '
{{text_min}} survey_question_form.default_text.$error.minlength = {{survey_question_form.default_text.$error.minlength}}'+
+ // '
'+
// '
The answer must be between {{text_min}} to {{text_max}} characters long!
'+
// '
',
// column: 2,
diff --git a/awx/ui/static/js/helpers/JobSubmission.js b/awx/ui/static/js/helpers/JobSubmission.js
index 3248705d85..fdb9d8e5c2 100644
--- a/awx/ui/static/js/helpers/JobSubmission.js
+++ b/awx/ui/static/js/helpers/JobSubmission.js
@@ -440,6 +440,7 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
defaultValue,
choices,
element,
+ minlength, maxlength,
checked, min, max,
survey_url = GetBasePath('job_templates') + id + '/survey_spec/' ;
@@ -458,20 +459,30 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
scope[question.variable] = question.default;
if(question.type === 'text' ){
+ minlength = (!Empty(question.min)) ? Number(question.min) : "";
+ maxlength =(!Empty(question.max)) ? Number(question.max) : "" ;
html+=''+
'A value is required!
'+
+ 'The answer must be between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+
'';
}
if(question.type === "textarea"){
scope[question.variable] = question.default || question.default_textarea;
+ minlength = (!Empty(question.min)) ? Number(question.min) : "";
+ maxlength =(!Empty(question.max)) ? Number(question.max) : "" ;
html+=''+
'A value is required!
'+
+ 'The answer must be between {{'+minlength+'}} to {{'+maxlength+'}} characters long.
'+
'';
}
diff --git a/awx/ui/static/js/helpers/Survey.js b/awx/ui/static/js/helpers/Survey.js
index 43bed88548..0b6818bbdb 100644
--- a/awx/ui/static/js/helpers/Survey.js
+++ b/awx/ui/static/js/helpers/Survey.js
@@ -390,6 +390,8 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
element = $('.question_final:eq('+index+')');
element.css('opacity', 1.0);
element.empty();
+ scope.text_min = null;
+ scope.text_max = null;
scope.int_min = null;
scope.int_max = null;
scope.float_min = null;
@@ -415,6 +417,16 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
}
}
}
+ if( question.type === 'text'){
+ scope.text_min = question.min;
+ scope.text_max = question.max;
+ // scope.default_text = question.default;
+ }
+ if( question.type === 'textarea'){
+ scope.textarea_min = question.min;
+ scope.textarea_max = question.max;
+ // scope.default_text = question.default;
+ }
if( question.type === 'integer'){
scope.int_min = question.min;
scope.int_max = question.max;
@@ -509,6 +521,8 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
GenerateForm.inject(form, { id:'new_question', mode: 'add' , scope:scope, related: false, breadCrumbs: false});
scope.required = true; //set the required checkbox to true via the ngmodel attached to scope.required.
+ scope.text_min = null;
+ scope.text_max = null;
scope.int_min = null;
scope.int_max = null;
scope.float_min = null;
@@ -640,6 +654,10 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
scope.default_textarea = "";
scope.survey_question_form.choices.$setPristine();
scope.choices = "";
+ scope.text_min = "";
+ scope.text_max = "" ;
+ scope.textarea_min = "";
+ scope.textarea_max = "" ;
scope.int_min = "";
scope.int_max = "";
scope.float_min = "";
@@ -665,6 +683,16 @@ angular.module('SurveyHelper', [ 'Utilities', 'RestServices', 'SchedulesHelper',
if(fld === "type"){
data[fld] = scope[fld].type;
+ if(scope[fld].type === 'text'){
+ data.min = scope.text_min;
+ data.max = scope.text_max;
+ // data.default = scope.default_text;
+ }
+ if(scope[fld].type === 'textarea'){
+ data.min = scope.textarea_min;
+ data.max = scope.textarea_max;
+ // data.default = scope.default_text;
+ }
if(scope[fld].type === 'float'){
data.min = scope.float_min;
data.max = scope.float_max;