diff --git a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html index 014de001c..dd0eaa6ad 100644 --- a/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html +++ b/dmp-frontend/src/app/form/dynamic-fields/dynamic-field-boolean-decision/dynamic-field-boolean-decision.component.html @@ -1,5 +1,5 @@
- +
- +
\ No newline at end of file diff --git a/dmp-frontend/src/app/form/dynamic-form.component.html b/dmp-frontend/src/app/form/dynamic-form.component.html index 1cde376ed..2195b0308 100644 --- a/dmp-frontend/src/app/form/dynamic-form.component.html +++ b/dmp-frontend/src/app/form/dynamic-form.component.html @@ -9,14 +9,19 @@
- + +
+
+
- +
diff --git a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts index d39adbb48..fd1c7ec66 100644 --- a/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts +++ b/dmp-frontend/src/app/form/pprogress-bar/progress-bar.component.ts @@ -1,3 +1,4 @@ +import { VisibilityRulesService } from '../../visibility-rules/visibility-rules.service'; import { Component, Input, OnInit } from '@angular/core'; import { FormGroup, FormControl, FormArray } from '@angular/forms' @@ -8,27 +9,29 @@ import { FormGroup, FormControl, FormArray } from '@angular/forms' export class ProgressBarComponent implements OnInit { @Input() formGroup: FormGroup + constructor(private visibilityRulesService: VisibilityRulesService) { } + private value: number; ngOnInit() { this.formGroup .valueChanges .subscribe(control => { - this.value = (this.getDirtyValues(this.formGroup) / this.getFormControlDepthLength(this.formGroup)) * 100 + this.value = (this.countFormControlsWithValue(this.formGroup) / this.getFormControlDepthLength(this.formGroup)) * 100 }) } - getDirtyValues(form: FormGroup): number { + countFormControlsWithValue(form: FormGroup): number { let value = 0; Object.keys(form.controls).forEach(key => { let control = form.controls[key] - if (control instanceof FormGroup) value += this.getDirtyValues(control); + if (control instanceof FormGroup) value += this.countFormControlsWithValue(control); else if (control instanceof FormArray) { let formArray = (control); for (let i = 0; i < formArray.length; i++) { - value += this.getDirtyValues(formArray.get("" + i)) + value += this.countFormControlsWithValue(formArray.get("" + i)) } } - else if (control.valid) value++; + else if (key === "value" && control.value != null) value++; }); return value; } @@ -44,7 +47,7 @@ export class ProgressBarComponent implements OnInit { value += this.getFormControlDepthLength(formArray.get("" + i)) } } - else if (control instanceof FormControl) value++; + else if (key === "value" && this.visibilityRulesService.isElementVisible(null, form.controls["id"].value)) value++; }); return value; }