update custom blueprint system validator
This commit is contained in:
parent
76a355891f
commit
fea69ff087
|
@ -71,7 +71,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
|||
selectedTocEntry: ToCEntry;
|
||||
colorizeInvalid: boolean = false;
|
||||
tocEntryEnumValues = ToCEntryType;
|
||||
close = false;
|
||||
|
||||
usersMap: Map<Guid, User> = new Map<Guid, User>();
|
||||
userFormControl = new FormControl();
|
||||
|
@ -200,9 +199,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
|||
refreshOnNavigateToData(id?: Guid): void {
|
||||
this.formGroup.markAsPristine();
|
||||
let route = [];
|
||||
if(close){
|
||||
this.router.navigate(['/description-templates']);
|
||||
}
|
||||
|
||||
if (id === null) {
|
||||
route.push('../..');
|
||||
} else if (this.isNew) {
|
||||
|
@ -234,19 +231,25 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
|||
}
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
formSubmit(onSuccess?: (response) => void): void {
|
||||
this.formService.removeAllBackEndErrors(this.formGroup);
|
||||
this.formService.touchAllFormFields(this.formGroup);
|
||||
if (!this.isFormValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.persistEntity();
|
||||
this.persistEntity(onSuccess);
|
||||
}
|
||||
|
||||
saveWithClose(close: boolean){
|
||||
this.close = close;
|
||||
this.formSubmit();
|
||||
this.formSubmit((data) => {
|
||||
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
|
||||
if(close){
|
||||
this.router.navigate(['/description-templates']);
|
||||
} else {
|
||||
this.refreshOnNavigateToData(data ? data.id : null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public delete() {
|
||||
|
|
|
@ -91,6 +91,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
rootPath: `definition.`,
|
||||
validationErrorModel: validationErrorModel
|
||||
});
|
||||
formGroup.updateValueAndValidity();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -409,13 +410,13 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
|||
if (keyField == 'label') {
|
||||
control?.addValidators(context.has('label-system') ? context.getValidation('label-system').validators : (context.has('label-extra') ? context.getValidation('label-extra').validators : context.getValidation('label-external-reference').validators));
|
||||
} else if (keyField == 'referenceTypeId') {
|
||||
if (formGroup.get('category').value == DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
||||
if (formGroup.get('category').value === DmpBlueprintFieldCategory.ReferenceType) control?.addValidators([Validators.required, ...context.getValidation('referenceTypeId').validators]);
|
||||
else control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
||||
} else if (keyField == 'systemFieldType') {
|
||||
if (formGroup.get('category').value == DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]);
|
||||
if (formGroup.get('category').value === DmpBlueprintFieldCategory.System) control?.addValidators([Validators.required, ...context.getValidation('systemFieldType').validators]);
|
||||
else control?.addValidators([...context.getValidation('systemFieldType').validators]);
|
||||
} else if (keyField == 'dataType') {
|
||||
if (formGroup.get('category').value == DmpBlueprintFieldCategory.Extra) control?.addValidators([Validators.required, ...context.getValidation('dataType').validators]);
|
||||
if (formGroup.get('category').value === DmpBlueprintFieldCategory.Extra) control?.addValidators([Validators.required, ...context.getValidation('dataType').validators]);
|
||||
else control?.addValidators([...context.getValidation('dataType').validators]);
|
||||
} else {
|
||||
control?.addValidators(context.getValidation(keyField).validators);
|
||||
|
|
|
@ -1274,7 +1274,7 @@
|
|||
},
|
||||
"SECTIONS-REQUIRED": "Required",
|
||||
"FIELDS-REQUIRED": "Required",
|
||||
"SYSTEM-FIELDS-REQUIRED": "Title and Description are required",
|
||||
"SYSTEM-FIELDS-REQUIRED": "Title, Description, Language and Access are required",
|
||||
"FIELDS": {
|
||||
"NAME": "Name",
|
||||
"SECTIONS": "Sections",
|
||||
|
|
|
@ -104,6 +104,8 @@ export function DmpBlueprintSystemFieldRequiredValidator(): ValidatorFn {
|
|||
return (control: AbstractControl): { [key: string]: any } => {
|
||||
let foundTitle = false;
|
||||
let foundDescription = false;
|
||||
let foundLanguage = false;
|
||||
let foundAccess = false;
|
||||
|
||||
const sectionsFormArray = (control as UntypedFormArray);
|
||||
if (sectionsFormArray.controls != null && sectionsFormArray.controls.length > 0 ){
|
||||
|
@ -116,10 +118,16 @@ export function DmpBlueprintSystemFieldRequiredValidator(): ValidatorFn {
|
|||
if (fieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === DmpBlueprintSystemFieldType.Description)){
|
||||
foundDescription = true;
|
||||
}
|
||||
if (fieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === DmpBlueprintSystemFieldType.Language)){
|
||||
foundLanguage = true;
|
||||
}
|
||||
if (fieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === DmpBlueprintSystemFieldType.AccessRights)){
|
||||
foundAccess = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return foundTitle && foundDescription ? null : { 'dmpBlueprintSystemFieldRequired': true };
|
||||
return foundTitle && foundDescription && foundAccess && foundLanguage ? null : { 'dmpBlueprintSystemFieldRequired': true };
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue