From 04f09ef578e932dc62a5d0f1b3630bfbe62fc435 Mon Sep 17 00:00:00 2001 From: gpapavgeri Date: Mon, 20 Jul 2020 12:16:23 +0300 Subject: [PATCH] Add UNFINALIZE button (dmp&dataset overview) & DEPOSIT button hidden after doi creation (dmp overview) --- .../overview/dataset-overview.component.html | 18 ++++-- .../overview/dataset-overview.component.ts | 55 +++++++++++++---- .../dmp/overview/dmp-overview.component.html | 60 ++++++++++++++----- .../ui/dmp/overview/dmp-overview.component.ts | 59 +++++++++++------- dmp-frontend/src/assets/i18n/en.json | 1 + dmp-frontend/src/assets/i18n/es.json | 1 + dmp-frontend/src/assets/i18n/gr.json | 1 + 7 files changed, 140 insertions(+), 55 deletions(-) diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html index aa9904242..5fda70400 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.html @@ -49,8 +49,8 @@ matTooltipPosition="above"> content_copy - @@ -76,7 +76,8 @@
{{'DMP-OVERVIEW.RESEARCHERS' | translate}}
- +
 
{{ researcher.name }},
{{ researcher.name }}
@@ -102,6 +103,12 @@
+
+ +

{{ 'DATASET-WIZARD.ACTIONS.REVERSE' | translate }}

+
- @@ -169,4 +177,4 @@ - + \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts index 3b5b9b782..52bf7d3d1 100644 --- a/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts +++ b/dmp-frontend/src/app/ui/dataset/overview/dataset-overview.component.ts @@ -31,6 +31,7 @@ import { LockService } from '@app/core/services/lock/lock.service'; import { DatasetsToBeFinalized } from '@app/core/model/dataset/datasets-toBeFinalized'; import { DatasetModel } from '@app/core/model/dataset/dataset'; import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; +import { DmpStatus } from '@app/core/common/enum/dmp-status'; @Component({ @@ -301,15 +302,15 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { this.router.navigate(['/datasets']); } + onDeleteCallbackError(error) { + this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); + } + onUpdateCallbackSuccess(): void { this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.reloadPage(); } - onDeleteCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); - } - onUpdateCallbackError(error) { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); } @@ -358,15 +359,15 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { } //GK: NO -// downloadJson(id: string) { -// this.datasetService.downloadJson(id) -// .pipe(takeUntil(this._destroyed)) -// .subscribe(response => { -// const blob = new Blob([response.body], { type: 'application/json' }); -// const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); -// FileSaver.saveAs(blob, filename); -// }) -// } + // downloadJson(id: string) { + // this.datasetService.downloadJson(id) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(response => { + // const blob = new Blob([response.body], { type: 'application/json' }); + // const filename = this.getFilenameFromContentDispositionHeader(response.headers.get('Content-Disposition')); + // FileSaver.saveAs(blob, filename); + // }) + // } getFilenameFromContentDispositionHeader(header: string): string { const regex: RegExp = new RegExp(/filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/g); @@ -492,4 +493,32 @@ export class DatasetOverviewComponent extends BaseComponent implements OnInit { }); } + hasReversableStatus(dataset: DatasetOverviewModel): boolean { + return dataset.dmp.status == DmpStatus.Draft && dataset.status == DatasetStatus.Finalized + } + + reverse(dataset: DatasetOverviewModel) { + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + restoreFocus: false, + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), + confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), + cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), + isDeleteConfirmation: false + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + this.getDatasetWizardModel(this.dataset.id); + this.datasetWizardModel.status = DatasetStatus.Draft; + this.datasetWizardService.createDataset(this.datasetWizardModel) + .pipe(takeUntil(this._destroyed)) + .subscribe( + data => this.onUpdateCallbackSuccess(), + error => this.onUpdateCallbackError(error) + ); + } + }); + } + } diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html index 89f80ea81..63ffdc00d 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.html @@ -33,8 +33,10 @@ . - - {{'DMP-LISTING.VERSION' | translate}} {{version.version}} + + + {{'DMP-LISTING.VERSION' | translate}} {{version.version}}
{{'GENERAL.STATUSES.EDIT' | translate}} : @@ -48,13 +50,19 @@
- - -
@@ -63,7 +71,8 @@
{{'DMP-OVERVIEW.RESEARCHERS' | translate}}
- +
 
{{ researcher.name }},
{{ researcher.name }}
@@ -79,7 +88,8 @@
-
+

{{ 'DMP-LISTING.ACTIONS.DEPOSIT' | translate }}

+
+ +

{{ 'DMP-LISTING.ACTIONS.UNFINALIZE' | translate }}

+
-
+

{{ 'DMP-LISTING.ACTIONS.START-NEW-VERSION' | translate }}

-
+
@@ -195,10 +220,13 @@

{{ roleDisplay(user) }}

- +
-
+
---> +--> \ No newline at end of file diff --git a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts index 506537218..d824b15f9 100644 --- a/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts +++ b/dmp-frontend/src/app/ui/dmp/overview/dmp-overview.component.ts @@ -221,15 +221,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.dmpService.delete(this.dmp.id) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => { this.onCallbackSuccess() }, + complete => { this.onDeleteCallbackSuccess() }, error => this.onDeleteCallbackError(error) ); } }); } - onCallbackSuccess(): void { - this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + onDeleteCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DATASET-PROFILE-DELETE'), SnackBarNotificationLevel.Success); this.router.navigate(['/plans']); } @@ -237,6 +237,15 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-DELETE'), SnackBarNotificationLevel.Error); } + onUpdateCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); + this.reloadPage(); + } + + onUpdateCallbackError(error) { + this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DATASET-UPLOAD.SNACK-BAR.UNSUCCESSFUL'), SnackBarNotificationLevel.Error); + } + downloadXml(id: string) { this.dmpService.downloadXML(id) .pipe(takeUntil(this._destroyed)) @@ -478,7 +487,7 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { if (result) { this.dmpService.publish(dmpId) .pipe(takeUntil(this._destroyed)) - .subscribe(() => { + .subscribe(() => { this.hasPublishButton = false; this.reloadPage(); }); @@ -516,18 +525,14 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { .subscribe( complete => { this.dmp.status = DmpStatus.Finalized; - this.onCallbackSuccess() + this.onUpdateCallbackSuccess(); }, - error => this.onFinalizeCallbackError(error) + error => this.onUpdateCallbackError(error) ); } }); } - onFinalizeCallbackError(error) { - this.uiNotificationService.snackBarNotification(error.error.message ? error.error.message : this.language.instant('DMP-EDITOR.SNACK-BAR.UNSUCCESSFUL-FINALIZE'), SnackBarNotificationLevel.Error); - } - newVersion(id: String, label: String) { this.router.navigate(['/plans/new_version/' + id, { dmpLabel: label }]); } @@ -571,14 +576,27 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { } reverse() { - this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed)) - .subscribe( - complete => { - this.dmp.status = DmpStatus.Draft; - this.onCallbackSuccess() - }, - error => this.onFinalizeCallbackError(error) - ); + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + restoreFocus: false, + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.UNFINALIZE-ITEM'), + confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), + cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE'), + isDeleteConfirmation: false + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + this.dmpService.unfinalize(this.dmp.id).pipe(takeUntil(this._destroyed)) + .subscribe( + complete => { + this.dmp.status = DmpStatus.Draft; + this.onUpdateCallbackSuccess() + }, + error => this.onUpdateCallbackError(error) + ); + } + }); } goBack(): void { @@ -595,10 +613,9 @@ export class DmpOverviewComponent extends BaseComponent implements OnInit { return this.dmpService.updateUsers(this.dmp.id, this.dmp.users).pipe(takeUntil(this._destroyed)) .subscribe( complete => { - this.onCallbackSuccess(); - this.reloadPage(); + this.onUpdateCallbackSuccess(); }, - error => this.onDeleteCallbackError(error) + error => this.onUpdateCallbackError(error) ); } diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 50e94b9d0..da85c1798 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -50,6 +50,7 @@ "DELETE-ITEM": "Delete this item?", "DELETE-USER": "Remove this collaborator?", "FINALIZE-ITEM": "Finalize this item?", + "UNFINALIZE-ITEM": "Undo Finalization?", "PUBLISH-ITEM": "Publish this item?", "ADD-DATASET": "Do you want to continue by adding a Dataset Description to your DMP? You can always add more Dataset Descriptions using \"Add Dataset Description (Wizard)\" menu.", "ZENODO-DOI": "Would you like to create digital object identifier (DOI) with {{username}} account for the DMP?", diff --git a/dmp-frontend/src/assets/i18n/es.json b/dmp-frontend/src/assets/i18n/es.json index c20619dea..94837b2f7 100644 --- a/dmp-frontend/src/assets/i18n/es.json +++ b/dmp-frontend/src/assets/i18n/es.json @@ -50,6 +50,7 @@ "DELETE-ITEM": "¿Borrar este item?", "DELETE-USER": "¿Borrar este colaborador?", "FINALIZE-ITEM": "¿Finalizar este item?", + "UNFINALIZE-ITEM": "Undo Finalization?", "PUBLISH-ITEM": "¿Publicar este item?", "ADD-DATASET": "¿Quiere continuar añadiendo una descripción al Dataset de su PGD? Siempre puede añadir más descripciones al Dataset utilizado el menú\"(Asistente) Añadir una decripción del Dataset\".", "ZENODO-DOI": "¿Quiere crear un Identificación de Objeto Digital (DOI) para el PGD?", diff --git a/dmp-frontend/src/assets/i18n/gr.json b/dmp-frontend/src/assets/i18n/gr.json index 5dd9b30f0..a14ef323f 100644 --- a/dmp-frontend/src/assets/i18n/gr.json +++ b/dmp-frontend/src/assets/i18n/gr.json @@ -50,6 +50,7 @@ "DELETE-ITEM": "Διαγραφή αυτού του στοιχείου;", "DELETE-USER": "Αφαίρεση αυτού του συνεργάτη;", "FINALIZE-ITEM": "Ολοκλήρωση αυτού του στοιχείου;", + "UNFINALIZE-ITEM": "Undo Finalization?", "PUBLISH-ITEM": "Δημοσίευση αυτού του στοιχείου;", "ADD-DATASET": "Θέλετε να συνεχίσετε προσθέτοντας μια Περιγραφή Συνόλου Δεδομένων στο Σχέδιο Διαχείρισης Δεδομένων σας; Μπορείτε πάντα να προσθέσετε περισσότερες Περιγραφές Συνόλων Δεδομένων χρησιμοποιώντας \"Add Dataset Description (Wizard)\" menu.", "ZENODO-DOI": "Θέλετε να δημιουργήσετε μονοσήμαντο αναγνωριστικό ψηφιακού αντικειμένου (DOI) για το Σχέδιο Διαχείρισης Δεδομένων σας;",