Add valid condition in progress calculatiion of a form

This commit is contained in:
Konstantinos Triantafyllou 2023-07-17 16:34:43 +03:00
parent dd6a2a0df7
commit aec7126fd3
2 changed files with 3 additions and 7 deletions

View File

@ -51,7 +51,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
let valueCurent = 0; let valueCurent = 0;
if (formControl instanceof FormGroup) { if (formControl instanceof FormGroup) {
if (this.checkFormsIfIsFieldsAndVisible(formControl) && this.checkIfIsRequired((formControl as FormGroup))) { if (this.checkFormsIfIsFieldsAndVisible(formControl) && this.checkIfIsRequired((formControl as FormGroup))) {
if (this.haseValue(formControl)) if (this.hasValue(formControl))
valueCurent++; valueCurent++;
} }
if (this.chechFieldIfIsFieldSetAndVisible((formControl as FormGroup)) && this.checkIfIsRequired((formControl as FormGroup))) { if (this.chechFieldIfIsFieldSetAndVisible((formControl as FormGroup)) && this.checkIfIsRequired((formControl as FormGroup))) {
@ -69,11 +69,8 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
} }
return valueCurent; return valueCurent;
} }
private haseValue(formGroup: FormGroup): boolean { private hasValue(formGroup: FormGroup): boolean {
if (formGroup.get('value').value != null && formGroup.get('value').value !== '' && this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value)) { return formGroup.get('value').valid && formGroup.get('value').value != null && formGroup.get('value').value !== '' && this.visibilityRulesService.checkElementVisibility(formGroup.get('id').value);
return true;
}
return false;
} }
private compositeFieldsGetChildsForProgress(formGroup: FormGroup): number { private compositeFieldsGetChildsForProgress(formGroup: FormGroup): number {

View File

@ -158,7 +158,6 @@ export class FormSectionComponent extends BaseComponent implements OnInit, OnCha
const outerRules = (this.visibilityRulesService.getVisibilityDependency(target) as VisibilityRuleSource[]).filter(x => x.sourceControlId === element.id); const outerRules = (this.visibilityRulesService.getVisibilityDependency(target) as VisibilityRuleSource[]).filter(x => x.sourceControlId === element.id);
const updatedRules = outerRules.map(x => { const updatedRules = outerRules.map(x => {
console.log(idMappings, element);
return {...x, sourceControlId: idMappings.find(y => y.old === element.id).new}; return {...x, sourceControlId: idMappings.find(y => y.old === element.id).new};
}); });