-
diff --git a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts
index c87a41890..9f5668b7e 100644
--- a/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts
+++ b/dmp-frontend/src/app/form/dynamic-form-section/dynamic-form-section.ts
@@ -19,7 +19,7 @@ export class DynamicFormSectionComponent implements OnInit {
@Input() form: FormGroup;
@Input() pathName: string;
@Input() path: string;
- constructor(private visibilityRulesService:VisibilityRulesService) { }
+ constructor(private visibilityRulesService: VisibilityRulesService) { }
ngOnInit() {
console.log(this.section);
@@ -31,11 +31,11 @@ export class DynamicFormSectionComponent implements OnInit {
((this.form.get("compositeFields").get('' + fieldsetIndex).get('multiplicityItems'))).push(compositeField.buildForm());
}
- isVisible(fieldSet:CompositeField):boolean{
- if(!this.visibilityRulesService.isElementVisible(null,fieldSet.id)) return false;
- for(var i=0; iformArray.get("" + i))
}
}
- else if (key === "value" && control.value != null) value++;
+ else if (key === "value" && control.value != null && control.value != "") value++;
});
return value;
}
@@ -52,16 +52,17 @@ export class ProgressBarComponent implements OnInit {
getFormControlDepthLength(form: FormGroup): number {
let value = 0;
Object.keys(form.controls).forEach(key => {
- let control = form.controls[key]
- if (control instanceof FormGroup)
- { value += this.getFormControlDepthLength(control);}
+ let control = form.controls[key];
+ if (control instanceof FormGroup) { value += this.getFormControlDepthLength(control); }
else if (control instanceof FormArray) {
let formArray = (control);
for (let i = 0; i < formArray.length; i++) {
- value += this.getFormControlDepthLength(formArray.get("" + i))
+ if (formArray.get("" + i).value && this.visibilityRulesService.isElementVisible(null, formArray.get("" + i).value.id))
+ value += this.getFormControlDepthLength(formArray.get("" + i))
}
}
- else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) value++;
+ else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value))
+ value++;
});
return value;
}
diff --git a/dmp-frontend/src/app/models/CompositeField.ts b/dmp-frontend/src/app/models/CompositeField.ts
index a59fb2cc5..c91f9f504 100644
--- a/dmp-frontend/src/app/models/CompositeField.ts
+++ b/dmp-frontend/src/app/models/CompositeField.ts
@@ -14,6 +14,7 @@ export class CompositeField extends BaseModel implements Serializable();
diff --git a/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts b/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts
index e4e52b35a..c77a8dc46 100644
--- a/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts
+++ b/dmp-frontend/src/app/visibility-rules/visibility-rules.service.ts
@@ -17,7 +17,8 @@ export class VisibilityRulesService {
if (this.checkElementVisibility(visibilityRule)) {
return true
} else {
- if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
+ this.clearValues(pathKey)
+ // if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
return false;
}
}
@@ -40,4 +41,13 @@ export class VisibilityRulesService {
private getParentPath(parentId: string): string {
return '';
}
+
+ private clearValues(pathKey) {
+ if (pathKey && this.formGroup.get(pathKey + '.value')) this.formGroup.get(pathKey + '.value').patchValue(null)
+ if (pathKey && this.formGroup.get(pathKey)["controls"].fields){
+ for (var i = 0; i < this.formGroup.get(pathKey)["controls"].fields.length; i++)
+ this.clearValues(pathKey+'.fields.'+i);
+ }
+
+ }
}
\ No newline at end of file