From 0bd3422903e1553bae83563bd08fbb4ef6034e18 Mon Sep 17 00:00:00 2001 From: Aldo Mihasi Date: Wed, 27 Sep 2023 16:20:54 +0300 Subject: [PATCH] check if blueprint is valid when finalizing in editor --- .../editor/dmp-profile-editor.component.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts index ed3ee6d4c..4059cc258 100644 --- a/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts +++ b/dmp-frontend/src/app/ui/admin/dmp-profile/editor/dmp-profile-editor.component.ts @@ -399,9 +399,9 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie this.descriptionTemplatesArray(sectionIndex).push(profile.buildForm()); } - formSubmit(): void { + checkValidity() { this.formService.touchAllFormFields(this.formGroup); - if (!this.isFormValid()) { return; } + if (!this.isFormValid()) { return false; } let errorMessages = []; if(!this.hasTitle()) { errorMessages.push("Title should be set."); @@ -414,9 +414,14 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie } if(errorMessages.length > 0) { this.showValidationErrorsDialog(undefined, errorMessages); - return; + return false; } - this.onSubmit(); + return true; + } + + formSubmit(): void { + if (this.checkValidity()) + this.onSubmit(); } public isFormValid() { @@ -548,10 +553,10 @@ export class DmpProfileEditorComponent extends BaseComponent implements AfterVie } finalize() { - //const data = this.form.value; - this.formGroup.get('status').setValue(DmpProfileStatus.Finalized); - - this.onSubmit(); + if (this.checkValidity()) { + this.formGroup.get('status').setValue(DmpProfileStatus.Finalized); + this.onSubmit(); + } } downloadXML(): void {