mirror of
https://github.com/ansible/awx.git
synced 2026-01-16 20:30:46 -03:30
text/textarea min/max length
added fields on survey maker for text/textarea min/max length. on survey taker added the error handling for these.
This commit is contained in:
parent
e9e2c1f6ab
commit
f99a73fb85
@ -97,26 +97,46 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
dataContainer: "body",
|
||||
column: 2
|
||||
},
|
||||
// text_options: {
|
||||
// realName: 'answer_options',
|
||||
// type: 'custom',
|
||||
// control:'<div class="row">'+
|
||||
// '<div class="col-xs-6">'+
|
||||
// '<label for="text_min"><span class="label-text">Minimum</span></label><input id="text_min" type="number" name="text_min" ng-model="text_min" aw-max="text_max" class="form-control" integer />'+
|
||||
// '<div class="error" ng-show="survey_question_form.text_min.$error.number || survey_question_form.text_min.$error.integer">This is not valid integer!</div>'+
|
||||
// '<div class="error" ng-show="survey_question_form.text_min.$error.ngMax">Too high!</div>'+
|
||||
// '</div>'+
|
||||
// // '<div class="col-xs-6">'+
|
||||
// // '<label for="minimum"><span class="label-text">Maximum</span></label><input id="text_max" type="number" name="text_max" ng-model="text_max" aw-min="text_min" class="form-control" integer >'+
|
||||
// // '<div class="error" ng-show="survey_question_form.text_max.$error.number || survey_question_form.text_max.$error.integer">This is not valid integer!</div>'+
|
||||
// // '<div class="error" ng-show="survey_question_form.text_max.$error.ngMin">Too low!</div>'+
|
||||
// // '</div>'+
|
||||
// '</div>',
|
||||
// ngShow: 'type.type==="text" ',
|
||||
// addRequired: true,
|
||||
// editRequired: true,
|
||||
// column: 2
|
||||
// },
|
||||
text_options: {
|
||||
realName: 'answer_options',
|
||||
type: 'custom',
|
||||
control:'<div class="row">'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="text_min"><span class="label-text">Minimum</span></label><input id="text_min" type="number" name="text_min" ng-model="text_min" min=0 aw-max="text_max" class="form-control" integer />'+
|
||||
'<div class="error" ng-show="survey_question_form.text_min.$error.number || survey_question_form.text_min.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.text_min.$error.awMax">Too high!</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="text_max" type="number" name="text_max" ng-model="text_max" aw-min="text_min" class="form-control" integer >'+
|
||||
'<div class="error" ng-show="survey_question_form.text_max.$error.number || survey_question_form.text_max.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.text_max.$error.awMin">Too low!</div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
ngShow: 'type.type==="text" ',
|
||||
addRequired: true,
|
||||
editRequired: true,
|
||||
column: 2
|
||||
},
|
||||
textarea_options: {
|
||||
realName: 'answer_options',
|
||||
type: 'custom',
|
||||
control:'<div class="row">'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="textarea_min"><span class="label-text">Minimum</span></label><input id="textarea_min" type="number" name="textarea_min" ng-model="textarea_min" min=0 aw-max="textarea_max" class="form-control" integer />'+
|
||||
'<div class="error" ng-show="survey_question_form.textarea_min.$error.number || survey_question_form.textarea_min.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.textarea_min.$error.awMax">Too high!</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="textarea_max"><span class="label-text">Maximum</span></label><input id="textarea_max" type="number" name="textarea_max" ng-model="textarea_max" aw-min="textarea_min" class="form-control" integer >'+
|
||||
'<div class="error" ng-show="survey_question_form.textarea_max.$error.number || survey_question_form.textarea_max.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.textarea_max.$error.awMin">Too low!</div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
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: '<div>'+
|
||||
// '<label for="default_text"><span class="label-text">Default Answer</span></label>'+
|
||||
// '<input type="text" ng-model="default_text" name="default_text" ng-minlength="text_min" ng-maxlength="text_max || 0" class="form-control" />{{text_min}} survey_question_form.default_text.$error.minlength = {{survey_question_form.default_text.$error.minlength}}'+
|
||||
// '<input type="text" ng-model="default_text" name="default_text" class="form-control" />'+
|
||||
// '<div class="error" ng-show="survey_question_form.default_text.$error.minlength || survey_question_form.default_text.$error.maxlength"> The answer must be between {{text_min}} to {{text_max}} characters long!</div>'+
|
||||
// '</div>',
|
||||
// column: 2,
|
||||
|
||||
@ -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+='<input type="text" id="'+question.variable+'" ng-model="'+question.variable+'" '+
|
||||
'name="'+question.variable+'" '+
|
||||
'name=" '+question.variable+' " ' +
|
||||
'ng-minlength="'+minlength+'" ng-maxlength="'+maxlength+'" '+
|
||||
'class="form-control" ng-required='+question.required+'>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && ' +
|
||||
'job_launch_form.'+question.variable+'.$error.required\">A value is required!</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$error.minlength || ' +
|
||||
'job_launch_form.'+question.variable+'.$error.maxlength\">The answer must be between {{'+minlength+'}} to {{'+maxlength+'}} characters long.</div>'+
|
||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>';
|
||||
}
|
||||
|
||||
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+='<textarea id="'+question.variable+'" name="'+question.variable+'" ng-model="'+question.variable+'" '+
|
||||
'ng-minlength="'+minlength+'" ng-maxlength="'+maxlength+'" '+
|
||||
'class="form-control final" ng-required="'+question.required+'" rows="3"></textarea>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$dirty && ' +
|
||||
'job_launch_form.'+question.variable+'.$error.required\">A value is required!</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+ question.variable + '.$error.minlength || ' +
|
||||
'job_launch_form.'+question.variable+'.$error.maxlength\">The answer must be between {{'+minlength+'}} to {{'+maxlength+'}} characters long.</div>'+
|
||||
'<div class=\"error api-error\" ng-bind=\"" + fld + "_api_error\"></div>';
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user