Merge branch 'Development' of code-repo.d4science.org:MaDgiK-CITE/argos into Development

This commit is contained in:
Konstantina Galouni 2023-07-17 18:06:05 +03:00
commit e4af3bcbe9
1 changed files with 14 additions and 4 deletions

View File

@ -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 { VisibilityRulesService } from '@app/ui/misc/dataset-description-form/visibility-rules/visibility-rules.service';
import { BaseComponent } from '@common/base/base.component';
@ -9,7 +9,7 @@ import { takeUntil } from 'rxjs/operators';
templateUrl: './form-progress-indication.component.html',
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() isDmpEditor: boolean;
@Input() isDatasetEditor: boolean;
@ -23,6 +23,16 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
public value = 0;
ngOnInit() {
this.init();
}
ngOnChanges(changes: SimpleChanges) {
if(changes.formGroup) {
this.init();
}
}
init() {
setTimeout(() => {this.calculateValueForProgressbar();});
this.formGroup
.valueChanges
@ -143,7 +153,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
countFormControlsValidForProgress(formControl: AbstractControl): number {
let valueCurrent = 0;
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++;
}
} else if (formControl instanceof FormGroup) {
@ -162,7 +172,7 @@ export class FormProgressIndicationComponent extends BaseComponent implements On
countFormControlsRequiredFieldsForTotal(formControl: AbstractControl): number {
let valueCurrent = 0;
if (formControl instanceof FormControl) {
if (this.controlRequired(formControl) && this.controlEnabled(formControl) && formControl['nativeElement']) {
if (this.controlRequired(formControl) && this.controlEnabled(formControl)) {
valueCurrent++;
}
} else if (formControl instanceof FormGroup) {