progress bar fixes, range visibility rule

This commit is contained in:
annampak 2017-10-13 11:13:52 +03:00
parent 74c7b083e6
commit 66d8b71631
3 changed files with 14 additions and 10 deletions

View File

@ -70,7 +70,7 @@
<div class="panel-footer">
<div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="70"
<div class="progress-bar" role="progressbar" aria-valuenow= ""
aria-valuemin="0" aria-valuemax="100" [ngStyle]="{'width': dirtyValues + '%'}">
{{dirtyValues}}%
</div>

View File

@ -56,9 +56,9 @@
</div>
<div [hidden]="isValid">
<div class="invalid-feedbackCustom" *ngIf="isValidRequired">{{field.label}} is required</div>
<div class="invalid-feedbackCustom" *ngIf="isValidPattern">{{field.label}} must match a regular expression {{field.regex}}</div>
<div class="invalid-feedbackCustom" *ngIf="isValidCustom">{{field.label}} custom Validation</div>
<div class="invalid-feedbackCustom" *ngIf="isValidRequired">The field "{{field.label}}" is required</div>
<div class="invalid-feedbackCustom" *ngIf="isValidPattern">The field {{field.label}} must match a regular expression {{field.regex}}</div>
<div class="invalid-feedbackCustom" *ngIf="isValidCustom">The field {{field.label}} custom Validation</div>
</div>

View File

@ -66,13 +66,17 @@ export class DynamicFormFieldComponent {
}
FieldValueRuleMethod(field, rule) { //fieldValue rule -- checks the value of target and apply rules, at the same time when the field becomes visible
if (rule._ruleStyle == "range") { //calling the AddvalidationRules we apply the validation rules for the new field
this.dataModel.fields.forEach(fld => {
if (fld.key == rule._target && rule._from < fld.value < rule._to) {
console.log("visible" + fld.value)
field.visible = true;
}
var targetField = this.dataModel.getFieldByKey(rule._target);
if (parseInt(rule._from) < parseInt(field.value) && parseInt(field.value)< parseInt(rule._to)) {
console.log("visible" + field.value)
targetField.visible = true;
this.AddvalidationRules(rule._target);
}else{
targetField.visible = false;
this.form.controls[rule._target].clearValidators(); // when a field is hidden must clear the validators and the errors
this.form.controls[rule._target].updateValueAndValidity();
}
});
}
if (rule._ruleStyle == "boolean") { //boolean Decision field
let ruleValue = rule.value.__text;