ui bug fix

This commit is contained in:
Diamantis Tziotzios 2024-06-11 14:16:18 +03:00
parent 70ed00a3d4
commit ce3277edb7
2 changed files with 6 additions and 5 deletions

View File

@ -40,7 +40,7 @@ export class FormService {
public removeAllBackEndErrors(formControl: AbstractControl) {
if (formControl instanceof UntypedFormControl) {
this.removeError(formControl, 'backendError');
FormService.removeError(formControl, 'backendError');
} else if (formControl instanceof UntypedFormGroup) {
Object.keys(formControl.controls).forEach(item => {
const control = formControl.get(item);
@ -53,7 +53,7 @@ export class FormService {
}
}
public removeError(control: UntypedFormControl, error: string) {
public static removeError(control: UntypedFormControl, error: string) {
const err = control.errors;
if (err && err[error]) {
delete err[error];

View File

@ -1,8 +1,9 @@
import { AbstractControl, UntypedFormArray, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms';
import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup, ValidatorFn, Validators } from '@angular/forms';
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
import { isNullOrUndefined } from '@app/utilities/enhancers/utils';
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service';
import { FormService } from '../form-service';
export function BackendErrorValidator(errorModel: ValidationErrorModel, propertyName: string): ValidatorFn {
return (control: AbstractControl): { [key: string]: any } => {
@ -31,12 +32,12 @@ export function CustomErrorValidator(errorModel: ValidationErrorModel, propertyN
}
export function RequiredWithVisibilityRulesValidator(visibilityRulesService: VisibilityRulesService, visibilityRulesKey: string) {
return (control: AbstractControl): { [key: string]: any } => {
return (control: UntypedFormControl): { [key: string]: any } => {
if (visibilityRulesService.isVisibleMap[visibilityRulesKey] ?? true) {
return Validators.required(control);
}
control.setErrors(null);
FormService.removeError(control, 'required');
return null;
};
}