From 2d6831365266b9ced5ff24c6867b7086e25de8f9 Mon Sep 17 00:00:00 2001 From: Valentin Date: Wed, 22 Sep 2021 13:52:38 +0300 Subject: [PATCH] added modal to confirm the approval of the documents if there are unseen changes --- ...dossier-overview-bulk-actions.component.ts | 17 ++++++++++++- .../file-actions/file-actions.component.ts | 24 ++++++++++++++++--- apps/red-ui/src/assets/i18n/en.json | 14 ++++++++--- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts index 39a224b4c..adf787f8f 100644 --- a/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/bulk-actions/dossier-overview-bulk-actions.component.ts @@ -177,7 +177,22 @@ export class DossierOverviewBulkActionsComponent { } approveDocuments() { - this._performBulkAction(this._fileActionService.setFileApproved(this.selectedFiles)); + const foundUpdatedFile = this.selectedFiles.find(file => file.hasUpdates); + if (foundUpdatedFile) { + this._dialogService.openDialog( + 'confirm', + null, + new ConfirmationDialogInput({ + title: _('confirmation-dialog.approve-multiple-files.title'), + question: _('confirmation-dialog.approve-multiple-files.question') + }), + () => { + this._performBulkAction(this._fileActionService.setFileApproved(this.selectedFiles)); + } + ); + } else { + this._performBulkAction(this._fileActionService.setFileApproved(this.selectedFiles)); + } } assignToMe() { diff --git a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts index 63ef0cd50..25bf34f01 100644 --- a/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/file-actions/file-actions.component.ts @@ -154,9 +154,21 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD setFileApproved($event: MouseEvent) { $event.stopPropagation(); - this.addSubscription = this._fileActionService.setFileApproved(this.fileStatus).subscribe(() => { - this.reloadDossiers('set-approved'); - }); + if (this.fileStatus.hasUpdates) { + this._dialogService.openDialog( + 'confirm', + $event, + new ConfirmationDialogInput({ + title: _('confirmation-dialog.approve-file.title'), + question: _('confirmation-dialog.approve-file.question') + }), + () => { + this._setFileApproved(); + } + ); + } else { + this._setFileApproved(); + } } ocrFile($event: MouseEvent) { @@ -194,6 +206,12 @@ export class FileActionsComponent extends AutoUnsubscribe implements OnInit, OnD } } + private _setFileApproved() { + this.addSubscription = this._fileActionService.setFileApproved(this.fileStatus).subscribe(() => { + this.reloadDossiers('set-approved'); + }); + } + private _setup() { this.statusBarConfig = [{ color: this.fileStatus.status, length: 1 }]; this.tooltipPosition = this.screen === 'file-preview' ? 'below' : 'above'; diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index b9a9e5c17..9731a5f02 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -363,6 +363,14 @@ "warning": "Warning: this cannot be undone!" }, "confirmation-dialog": { + "approve-file": { + "question": "This document has unseen changes, do you wish to approve it anyway?", + "title": "Warning!" + }, + "approve-multiple-files": { + "question": "At least one of the files you selected has unseen changes, do you wish to approve them anyway?", + "title": "Warning!" + }, "assign-file-to-me": { "question": "This document is currently reviewed by someone else. Do you want to become the reviewer and assign yourself to this document?", "title": "Re-assign reviewer" @@ -861,13 +869,13 @@ "unsaved-changes": "You have unsaved changes. Save or revert before changing the tab." }, "error": { + "close": "Close", "http": { "generic": "Action failed with code {status}" }, - "reload": "Reload", - "title": "Oops! Something went wrong...", "offline": "You're offline", - "close": "Close" + "reload": "Reload", + "title": "Oops! Something went wrong..." }, "exact-date": "{day} {month} {year} at {hour}:{minute}", "file": "File",