From df50a4ee6006826269d4542fdbd27605101c5e63 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Tue, 2 Jul 2019 13:19:15 +0300 Subject: [PATCH] Adds: DMP creation dialog to continue to dataset addition or not (Issue - # 74) --- .../src/app/core/services/dmp/dmp.service.ts | 4 +- .../ui/dmp/editor/dmp-editor.component.html | 2 +- .../app/ui/dmp/editor/dmp-editor.component.ts | 42 +++++++++++++++---- dmp-frontend/src/assets/i18n/en.json | 1 + 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts index 7554a46e7..80bfb13e6 100644 --- a/dmp-frontend/src/app/core/services/dmp/dmp.service.ts +++ b/dmp-frontend/src/app/core/services/dmp/dmp.service.ts @@ -60,8 +60,8 @@ export class DmpService { return this.http.get(this.actionUrl + id + '/unlock', { headers: this.headers }); } - createDmp(dataManagementPlanModel: DmpModel): Observable { - return this.http.post(this.actionUrl, dataManagementPlanModel, { headers: this.headers }); + createDmp(dataManagementPlanModel: DmpModel): Observable { + return this.http.post(this.actionUrl, dataManagementPlanModel, { headers: this.headers }); } inactivate(id: String): Observable { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index 4adae6f63..489154160 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -98,7 +98,7 @@ - diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index c023c4b17..addc886a7 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -34,7 +34,6 @@ import { AuthService } from '../../../core/services/auth/auth.service'; import { ExportMethodDialogComponent } from '../../../library/export-method-dialog/export-method-dialog.component'; import { UserInfoListingModel } from '../../../core/model/user/user-info-listing'; import { ProjectTabModel } from './project-tab/project-tab-model'; -import { DatasetListingModel } from '../../../core/model/dataset/dataset-listing'; @Component({ selector: 'app-dmp-editor-component', @@ -233,23 +232,29 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC // return this.projectService.getWithExternal(projectRequestItem); // } - formSubmit(): void { + formSubmit(showAddDatasetDialog?: boolean): void { //this.touchAllFormFields(this.formGroup); if (!this.isFormValid()) { return; } - this.onSubmit(); + this.onSubmit(showAddDatasetDialog); } public isFormValid() { return this.formGroup.valid; } - onSubmit(): void { + onSubmit(showAddDatasetDialog?: boolean): void { this.dmpService.createDmp(this.formGroup.getRawValue()) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => this.onCallbackSuccess(), + complete => { + if (showAddDatasetDialog) { + this.addDatasetOpenDialog(complete); + } + else { this.onCallbackSuccess() } + }, error => this.onCallbackError(error) ); + } onCallbackSuccess(): void { @@ -433,8 +438,31 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.formGroup.disable(); } - saveAndFinalize() { + addDataset() { + this.formSubmit(true); + } + addDatasetOpenDialog(id: String) { + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '500px', + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ADD-DATASET'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CONFIRM'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + isDeleteConfirmation: false + } + }); + + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + this.router.navigate(['datasets/new/' + id]); + } else { + this.router.navigate(['/plans']); + } + }); + } + + saveAndFinalize() { const dialogInputModel: DmpFinalizeDialogInput = { dmpLabel: this.formGroup.get('label').value, dmpDescription: this.formGroup.get('description').value, @@ -456,7 +484,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC if (result && !result.cancelled) { this.formGroup.get('status').setValue(DmpStatus.Finalized); this.formGroup.get('datasetsToBeFinalized').setValue(result.datasetsToBeFinalized); - this.formSubmit(); + this.formSubmit(false); dialogRef.close(); } }); diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 21b75dc19..12fadaa27 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -36,6 +36,7 @@ "DELETE-ITEM": "Delete this item?", "DELETE-USER": "Remove this collaborator?", "FINALIZE-ITEM": "Finalize this item?", + "ADD-DATASET": "Proceed on adding new Dataset?", "ACTIONS": { "CONFIRM": "Yes", "No": "No",