Fix progress indicator in prifilled dataset form. #8764
This commit is contained in:
parent
aec7126fd3
commit
7bc4f4055c
|
@ -1,4 +1,4 @@
|
||||||
import { Component, ElementRef, Input, OnInit } from '@angular/core';
|
import {ChangeDetectorRef, Component, ElementRef, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
||||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||||
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
|
import { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
|
@ -9,7 +9,7 @@ import { takeUntil } from 'rxjs/operators';
|
||||||
templateUrl: './form-progress-indication.component.html',
|
templateUrl: './form-progress-indication.component.html',
|
||||||
styleUrls: ['./form-progress-indication.component.scss']
|
styleUrls: ['./form-progress-indication.component.scss']
|
||||||
})
|
})
|
||||||
export class FormProgressIndicationComponent extends BaseComponent implements OnInit {
|
export class FormProgressIndicationComponent extends BaseComponent implements OnInit, OnChanges {
|
||||||
@Input() formGroup: FormGroup;
|
@Input() formGroup: FormGroup;
|
||||||
@Input() isDmpEditor: boolean;
|
@Input() isDmpEditor: boolean;
|
||||||
@Input() isDatasetEditor: boolean;
|
@Input() isDatasetEditor: boolean;
|
||||||
|
@ -23,6 +23,16 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
||||||
|
|
||||||
public value = 0;
|
public value = 0;
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
|
||||||
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
|
if(changes.formGroup) {
|
||||||
|
this.init();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
init() {
|
||||||
setTimeout(() => {this.calculateValueForProgressbar();});
|
setTimeout(() => {this.calculateValueForProgressbar();});
|
||||||
this.formGroup
|
this.formGroup
|
||||||
.valueChanges
|
.valueChanges
|
||||||
|
@ -143,7 +153,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
||||||
countFormControlsValidForProgress(formControl: AbstractControl): number {
|
countFormControlsValidForProgress(formControl: AbstractControl): number {
|
||||||
let valueCurrent = 0;
|
let valueCurrent = 0;
|
||||||
if (formControl instanceof FormControl) {
|
if (formControl instanceof FormControl) {
|
||||||
if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl['nativeElement'] && formControl.valid) {
|
if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl.valid) {
|
||||||
valueCurrent++;
|
valueCurrent++;
|
||||||
}
|
}
|
||||||
} else if (formControl instanceof FormGroup) {
|
} else if (formControl instanceof FormGroup) {
|
||||||
|
@ -162,7 +172,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
|
||||||
countFormControlsRequiredFieldsForTotal(formControl: AbstractControl): number {
|
countFormControlsRequiredFieldsForTotal(formControl: AbstractControl): number {
|
||||||
let valueCurrent = 0;
|
let valueCurrent = 0;
|
||||||
if (formControl instanceof FormControl) {
|
if (formControl instanceof FormControl) {
|
||||||
if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl['nativeElement']) {
|
if (this.controlRequired(formControl) && this.controlEnabled(formControl)) {
|
||||||
valueCurrent++;
|
valueCurrent++;
|
||||||
}
|
}
|
||||||
} else if (formControl instanceof FormGroup) {
|
} else if (formControl instanceof FormGroup) {
|
||||||
|
|
Loading…
Reference in New Issue