mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-18 07:23:03 +00:00
101108: Automatic ng update @angular/core@14
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { distinctUntilChanged, filter, map } from 'rxjs/operators';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AbstractControl, FormArray, FormControl, FormGroup } from '@angular/forms';
|
||||
import { AbstractControl, UntypedFormArray, UntypedFormControl, UntypedFormGroup } from '@angular/forms';
|
||||
import { Observable } from 'rxjs';
|
||||
import { select, Store } from '@ngrx/store';
|
||||
|
||||
@@ -96,13 +96,13 @@ export class FormService {
|
||||
/**
|
||||
* Method to validate form's fields
|
||||
*/
|
||||
public validateAllFormFields(formGroup: FormGroup | FormArray) {
|
||||
public validateAllFormFields(formGroup: UntypedFormGroup | UntypedFormArray) {
|
||||
Object.keys(formGroup.controls).forEach((field) => {
|
||||
const control = formGroup.get(field);
|
||||
if (control instanceof FormControl) {
|
||||
if (control instanceof UntypedFormControl) {
|
||||
control.markAsTouched({ onlySelf: true });
|
||||
control.markAsDirty({ onlySelf: true });
|
||||
} else if (control instanceof FormGroup || control instanceof FormArray) {
|
||||
} else if (control instanceof UntypedFormGroup || control instanceof UntypedFormArray) {
|
||||
this.validateAllFormFields(control);
|
||||
}
|
||||
});
|
||||
@@ -112,14 +112,14 @@ export class FormService {
|
||||
* Check if form group has an invalid form control
|
||||
* @param formGroup The form group to check
|
||||
*/
|
||||
public hasValidationErrors(formGroup: FormGroup | FormArray): boolean {
|
||||
public hasValidationErrors(formGroup: UntypedFormGroup | UntypedFormArray): boolean {
|
||||
let hasErrors = false;
|
||||
const fields: string[] = Object.keys(formGroup.controls);
|
||||
for (const field of fields) {
|
||||
const control = formGroup.get(field);
|
||||
if (control instanceof FormControl) {
|
||||
if (control instanceof UntypedFormControl) {
|
||||
hasErrors = !control.valid && control.touched;
|
||||
} else if (control instanceof FormGroup || control instanceof FormArray) {
|
||||
} else if (control instanceof UntypedFormGroup || control instanceof UntypedFormArray) {
|
||||
hasErrors = this.hasValidationErrors(control);
|
||||
}
|
||||
if (hasErrors) {
|
||||
@@ -162,7 +162,7 @@ export class FormService {
|
||||
}
|
||||
|
||||
// if the field in question is a concat group, pass down the error to its fields
|
||||
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
|
||||
if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
|
||||
model.group.forEach((subModel) => {
|
||||
const subField = field.controls[subModel.id];
|
||||
|
||||
@@ -183,7 +183,7 @@ export class FormService {
|
||||
}
|
||||
|
||||
// if the field in question is a concat group, clear the error from its fields
|
||||
if (field instanceof FormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
|
||||
if (field instanceof UntypedFormGroup && model instanceof DynamicFormGroupModel && this.formBuilderService.isConcatGroup(model)) {
|
||||
model.group.forEach((subModel) => {
|
||||
const subField = field.controls[subModel.id];
|
||||
|
||||
@@ -194,7 +194,7 @@ export class FormService {
|
||||
field.markAsUntouched();
|
||||
}
|
||||
|
||||
public resetForm(formGroup: FormGroup, groupModel: DynamicFormControlModel[], formId: string) {
|
||||
public resetForm(formGroup: UntypedFormGroup, groupModel: DynamicFormControlModel[], formId: string) {
|
||||
this.formBuilderService.clearAllModelsValue(groupModel);
|
||||
formGroup.reset();
|
||||
this.store.dispatch(new FormChangeAction(formId, formGroup.value));
|
||||
|
Reference in New Issue
Block a user