ngMin/ngMax directives fix for surveys

the ngMin and ngMax directives needed to be re-written to work properly with other directives. They weren't playing nice with other directives' values
This commit is contained in:
Jared Tabor
2014-12-01 12:38:08 -05:00
parent bab3bfb70a
commit a319def4b4
2 changed files with 12 additions and 25 deletions

View File

@@ -517,9 +517,9 @@ 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 />'+
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+'" />'+
'<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+'.$dirty && (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.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>';
}
@@ -528,7 +528,7 @@ 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 />'+
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+'"/>'+
'<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>';
}