small reapply validator fix

This commit is contained in:
amentis 2024-02-09 16:16:46 +02:00
parent 1a6e776b41
commit 075573ffaf
2 changed files with 11 additions and 10 deletions

View File

@ -389,7 +389,7 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des
const control = fields?.get(key); const control = fields?.get(key);
DescriptionFieldEditorModel.reapplyValidators({ DescriptionFieldEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup, formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}fields.`, rootPath: `${rootPath}fields[${key}].`,
validationErrorModel: validationErrorModel validationErrorModel: validationErrorModel
}) })
}); });

View File

@ -234,16 +234,17 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
}): void { }): void {
const { formGroup, rootPath, validationErrorModel } = params; const { formGroup, rootPath, validationErrorModel } = params;
const context = DmpPropertiesEditorModel.createValidationContext({
rootPath,
validationErrorModel
});
['dmpBlueprintValues'].forEach(keyField => { const dmpBlueprintValues = formGroup?.get('dmpBlueprintValues') as UntypedFormGroup;
const control = formGroup?.get(keyField); const keys = Object.keys(dmpBlueprintValues.value as Object);
control?.clearValidators(); keys.forEach((key) => {
control?.addValidators(context.getValidation(keyField).validators); const control = dmpBlueprintValues?.get(key);
}); DmpBlueprintValueEditorModel.reapplyValidators({
formGroup: control as UntypedFormGroup,
rootPath: `${rootPath}dmpBlueprintValues[${key}].`,
validationErrorModel: validationErrorModel
})
});
(formGroup.get('contacts') as FormArray).controls?.forEach( (formGroup.get('contacts') as FormArray).controls?.forEach(
(control, index) => DmpContactEditorModel.reapplyValidators({ (control, index) => DmpContactEditorModel.reapplyValidators({