mirror of
https://github.com/ansible/awx.git
synced 2026-01-22 23:18:03 -03:30
renamed ngmin/ngmax
renamed to awmin/awmax to match custom directive format. the prefix 'ng' is meant to imply an 'angular' specific directive
This commit is contained in:
parent
98fa7eae40
commit
e14630b155
@ -76,19 +76,39 @@ 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
|
||||
// },
|
||||
int_options: {
|
||||
realName: 'answer_options',
|
||||
type: 'custom',
|
||||
control:'<div class="row">'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="int_min" type="number" name="int_min" ng-model="int_min" ng-max="int_max" class="form-control" integer >'+
|
||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="int_min" type="number" name="int_min" ng-model="int_min" aw-max="int_max" class="form-control" integer >'+
|
||||
'<div class="error" ng-show="survey_question_form.int_min.$error.number || survey_question_form.int_min.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.int_min.$error.ngMax">Too high!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.int_min.$error.awMax">Too high!</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="int_max" type="number" name="int_max" ng-model="int_max" ng-min="int_min" class="form-control" integer >'+
|
||||
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="int_max" type="number" name="int_max" ng-model="int_max" aw-min="int_min" class="form-control" integer >'+
|
||||
'<div class="error" ng-show="survey_question_form.int_max.$error.number || survey_question_form.int_max.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.int_max.$error.ngMin">Too low!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.int_max.$error.awMin">Too low!</div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
ngShow: 'type.type==="integer" ',
|
||||
@ -101,12 +121,15 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
type: 'custom',
|
||||
control: '<div class="row">'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="float_min" type="number" name="float_min" ng-model="float_min" class="form-control" smart-float >'+
|
||||
'<div class="error" ng-show="survey_question_form.float_min.$invalid">This is not valid float!</div>'+
|
||||
'<label for="minimum"><span class="label-text">Minimum</span></label><input id="float_min" type="number" name="float_min" ng-model="float_min" class="form-control" smart-float aw-max="float_max">'+
|
||||
'<div class="error" ng-show="survey_question_form.float_min.$error.float">This is not valid float!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.float_min.$error.awMax">Too high!</div>'+
|
||||
'</div>'+
|
||||
'<div class="col-xs-6">'+
|
||||
'<label for="minimum"><span class="label-text">Maximum</span></label><input id="float_max" type="number" name="float_max" ng-model="float_max" class="form-control" smart-float >'+
|
||||
'<div class="error" ng-show="survey_question_form.float_max.$invalid">This is not valid float!</div>'+
|
||||
'<label for="maximum"><span class="label-text">Maximum</span></label><input id="float_max" type="number" name="float_max" ng-model="float_max" class="form-control" smart-float aw-min="float_min">'+
|
||||
'<div class="error" ng-show="survey_question_form.float_max.$error.float">This is not valid float!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.float_max.$error.awMin">Too low!</div>'+
|
||||
|
||||
'</div>'+
|
||||
'</div>',
|
||||
ngShow: 'type.type==="float" ',
|
||||
@ -121,8 +144,19 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
addRequired: false,
|
||||
editRequired: false,
|
||||
column: 2,
|
||||
ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" '
|
||||
ngHide: 'type.type === "textarea" || type.type === "multiselect" || type.type === "integer" || type.type === "float" ' // type.type === "text" ||
|
||||
},
|
||||
// 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}}'+
|
||||
// '<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,
|
||||
// ngShow: 'type.type === "text" '
|
||||
// },
|
||||
default_multiselect: {
|
||||
realName: 'default_answer',
|
||||
label: 'Default Answer',
|
||||
@ -138,9 +172,9 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
type: 'custom',
|
||||
control: '<div>'+
|
||||
'<label for="default_int"><span class="label-text">Default Answer</span></label>'+
|
||||
'<input type="number" ng-model="default_int" name="default_int" ng-min="int_min" ng-max="int_max" class="form-control" integer />'+
|
||||
'<input type="number" ng-model="default_int" name="default_int" aw-min="int_min" aw-max="int_max" class="form-control" integer />'+
|
||||
'<div class="error" ng-show="survey_question_form.default_int.$error.number || survey_question_form.default_int.$error.integer">This is not valid integer!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.default_int.$error.ngMin || survey_question_form.default_int.$error.ngMax"> The value must be in range {{int_min}} to {{int_max}}!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.default_int.$error.awMin || survey_question_form.default_int.$error.awMax"> The value must be in range {{int_min}} to {{int_max}}!</div>'+
|
||||
'</div>',
|
||||
column: 2,
|
||||
ngShow: 'type.type === "integer" '
|
||||
@ -150,9 +184,9 @@ angular.module('SurveyQuestionFormDefinition', [])
|
||||
type: 'custom',
|
||||
control: '<div>'+
|
||||
'<label for="default_float"><span class="label-text">Default Answer</span></label>'+
|
||||
'<input type="number" ng-model="default_float" name="default_float" ng-min="float_min" ng-max="float_max" class="form-control" />'+
|
||||
'<input type="number" ng-model="default_float" name="default_float" aw-min="float_min" aw-max="float_max" class="form-control" />'+
|
||||
'<div class="error" ng-show="survey_question_form.default_float.$error.number || survey_question_form.default_float.$error.float">This is not valid float!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.default_float.$error.ngMin || survey_question_form.default_float.$error.ngMax"> The value must be in range {{float_min}} to {{float_max}}!</div>'+
|
||||
'<div class="error" ng-show="survey_question_form.default_float.$error.awMin || survey_question_form.default_float.$error.awMax"> The value must be in range {{float_min}} to {{float_max}}!</div>'+
|
||||
'</div>',
|
||||
column: 2,
|
||||
ngShow: 'type.type=== "float" '
|
||||
|
||||
@ -517,10 +517,10 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
||||
if(question.type === 'integer'){
|
||||
min = (!Empty(question.min)) ? Number(question.min) : "";
|
||||
max = (!Empty(question.max)) ? Number(question.max) : "" ;
|
||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class="form-control" name="'+question.variable+'" ng-required="'+question.required+'" integer ng-min="'+min+'" ng-max="'+max+'" />'+
|
||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class="form-control" name="'+question.variable+'" ng-required="'+question.required+'" integer aw-min="'+min+'" aw-max="'+max+'" />'+
|
||||
'<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.number || job_launch_form.'+question.variable+'.$error.integer" >This is not valid integer!</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.awMin || job_launch_form.'+question.variable+'.$error.awMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||
|
||||
}
|
||||
|
||||
@ -528,9 +528,9 @@ function($location, Wait, GetBasePath, LookUpInit, JobTemplateForm, CredentialLi
|
||||
min = (!Empty(question.min)) ? question.min : "";
|
||||
max = (!Empty(question.max)) ? question.max : "" ;
|
||||
defaultValue = (!Empty(question.default)) ? question.default : (!Empty(question.default_float)) ? question.default_float : "" ;
|
||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class=" form-control" name="'+question.variable+'" ng-required="'+question.variable+'" smart-float ng-min="'+min+'" ng-max="'+max+'"/>'+
|
||||
html+='<input type="number" id="'+question.variable+'" ng-model="'+question.variable+'" class=" form-control" name="'+question.variable+'" ng-required="'+question.variable+'" smart-float aw-min="'+min+'" aw-max="'+max+'"/>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.number || job_launch_form.'+question.variable+'.$error.float">This is not valid float!</div>'+
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.ngMin || job_launch_form.'+question.variable+'.$error.ngMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||
'<div class="error survey_error" ng-show="job_launch_form.'+question.variable+'.$error.awMin || job_launch_form.'+question.variable+'.$error.awMax"> The value must be in range {{'+min+'}} to {{'+max+'}}!</div>';
|
||||
}
|
||||
html+='</div>';
|
||||
if(question.index === scope.survey_questions.length-1){
|
||||
|
||||
@ -144,18 +144,18 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
};
|
||||
})
|
||||
|
||||
.directive('ngMin', ['Empty', function (Empty) {
|
||||
.directive('awMin', ['Empty', function (Empty) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
link: function (scope, elem, attr, ctrl) {
|
||||
ctrl.$parsers.unshift( function(viewValue) {
|
||||
var min = (attr.ngMin) ? scope.$eval(attr.ngMin) : -Infinity;
|
||||
var min = (attr.awMin) ? scope.$eval(attr.awMin) : -Infinity;
|
||||
if (!Empty(min) && !Empty(viewValue) && Number(viewValue) < min) {
|
||||
ctrl.$setValidity('ngMin', false);
|
||||
ctrl.$setValidity('awMin', false);
|
||||
return undefined;
|
||||
} else {
|
||||
ctrl.$setValidity('ngMin', true);
|
||||
ctrl.$setValidity('awMin', true);
|
||||
return viewValue;
|
||||
}
|
||||
});
|
||||
@ -163,18 +163,18 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ngMax', ['Empty', function (Empty) {
|
||||
.directive('awMax', ['Empty', function (Empty) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
link: function (scope, elem, attr, ctrl) {
|
||||
ctrl.$parsers.unshift( function(viewValue) {
|
||||
var max = (attr.ngMax) ? scope.$eval(attr.ngMax) : Infinity;
|
||||
var max = (attr.awMax) ? scope.$eval(attr.awMax) : Infinity;
|
||||
if (!Empty(max) && !Empty(viewValue) && Number(viewValue) > max) {
|
||||
ctrl.$setValidity('ngMax', false);
|
||||
ctrl.$setValidity('awMax', false);
|
||||
return undefined;
|
||||
} else {
|
||||
ctrl.$setValidity('ngMax', true);
|
||||
ctrl.$setValidity('awMax', true);
|
||||
return viewValue;
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user