Merge branch 'dmp-refactoring' of https://code-repo.d4science.org/MaDgiK-CITE/argos into dmp-refactoring
This commit is contained in:
commit
4ffbafc85f
|
@ -71,7 +71,6 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
selectedTocEntry: ToCEntry;
|
selectedTocEntry: ToCEntry;
|
||||||
colorizeInvalid: boolean = false;
|
colorizeInvalid: boolean = false;
|
||||||
tocEntryEnumValues = ToCEntryType;
|
tocEntryEnumValues = ToCEntryType;
|
||||||
close = false;
|
|
||||||
|
|
||||||
usersMap: Map<Guid, User> = new Map<Guid, User>();
|
usersMap: Map<Guid, User> = new Map<Guid, User>();
|
||||||
userFormControl = new FormControl();
|
userFormControl = new FormControl();
|
||||||
|
@ -200,9 +199,7 @@ export class DescriptionTemplateEditorComponent extends BaseEditor<DescriptionTe
|
||||||
refreshOnNavigateToData(id?: Guid): void {
|
refreshOnNavigateToData(id?: Guid): void {
|
||||||
this.formGroup.markAsPristine();
|
this.formGroup.markAsPristine();
|
||||||
let route = [];
|
let route = [];
|
||||||
if(close){
|
|
||||||
this.router.navigate(['/description-templates']);
|
|
||||||
}
|
|
||||||
if (id === null) {
|
if (id === null) {
|
||||||
route.push('../..');
|
route.push('../..');
|
||||||
} else if (this.isNew) {
|
} 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.removeAllBackEndErrors(this.formGroup);
|
||||||
this.formService.touchAllFormFields(this.formGroup);
|
this.formService.touchAllFormFields(this.formGroup);
|
||||||
if (!this.isFormValid()) {
|
if (!this.isFormValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.persistEntity();
|
this.persistEntity(onSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveWithClose(close: boolean){
|
saveWithClose(close: boolean){
|
||||||
this.close = close;
|
this.formSubmit((data) => {
|
||||||
this.formSubmit();
|
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() {
|
public delete() {
|
||||||
|
|
|
@ -91,6 +91,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
||||||
rootPath: `definition.`,
|
rootPath: `definition.`,
|
||||||
validationErrorModel: validationErrorModel
|
validationErrorModel: validationErrorModel
|
||||||
});
|
});
|
||||||
|
formGroup.updateValueAndValidity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -409,13 +410,13 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
if (keyField == 'label') {
|
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));
|
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') {
|
} 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 control?.addValidators([...context.getValidation('referenceTypeId').validators]);
|
||||||
} else if (keyField == 'systemFieldType') {
|
} 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 control?.addValidators([...context.getValidation('systemFieldType').validators]);
|
||||||
} else if (keyField == 'dataType') {
|
} 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('dataType').validators]);
|
||||||
} else {
|
} else {
|
||||||
control?.addValidators(context.getValidation(keyField).validators);
|
control?.addValidators(context.getValidation(keyField).validators);
|
||||||
|
|
|
@ -1274,7 +1274,7 @@
|
||||||
},
|
},
|
||||||
"SECTIONS-REQUIRED": "Required",
|
"SECTIONS-REQUIRED": "Required",
|
||||||
"FIELDS-REQUIRED": "Required",
|
"FIELDS-REQUIRED": "Required",
|
||||||
"SYSTEM-FIELDS-REQUIRED": "Title and Description are required",
|
"SYSTEM-FIELDS-REQUIRED": "Title, Description, Language and Access are required",
|
||||||
"FIELDS": {
|
"FIELDS": {
|
||||||
"NAME": "Name",
|
"NAME": "Name",
|
||||||
"SECTIONS": "Sections",
|
"SECTIONS": "Sections",
|
||||||
|
|
|
@ -104,6 +104,8 @@ export function DmpBlueprintSystemFieldRequiredValidator(): ValidatorFn {
|
||||||
return (control: AbstractControl): { [key: string]: any } => {
|
return (control: AbstractControl): { [key: string]: any } => {
|
||||||
let foundTitle = false;
|
let foundTitle = false;
|
||||||
let foundDescription = false;
|
let foundDescription = false;
|
||||||
|
let foundLanguage = false;
|
||||||
|
let foundAccess = false;
|
||||||
|
|
||||||
const sectionsFormArray = (control as UntypedFormArray);
|
const sectionsFormArray = (control as UntypedFormArray);
|
||||||
if (sectionsFormArray.controls != null && sectionsFormArray.controls.length > 0 ){
|
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)){
|
if (fieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === DmpBlueprintSystemFieldType.Description)){
|
||||||
foundDescription = true;
|
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