From 5b5a01de4d0c38670b6f7f891618984e578b7fed Mon Sep 17 00:00:00 2001 From: Timo Date: Thu, 21 Jan 2021 12:05:49 +0200 Subject: [PATCH] approval --- .../file-actions/file-actions.component.html | 5 +++-- .../app/common/service/permissions.service.ts | 17 +++++++++++------ .../bulk-actions/bulk-actions.component.html | 9 ++++++--- .../bulk-actions/bulk-actions.component.ts | 4 ++++ apps/red-ui/src/assets/i18n/en.json | 1 + 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/apps/red-ui/src/app/common/file-actions/file-actions.component.html b/apps/red-ui/src/app/common/file-actions/file-actions.component.html index 59bcae55b..d4e5d31df 100644 --- a/apps/red-ui/src/app/common/file-actions/file-actions.component.html +++ b/apps/red-ui/src/app/common/file-actions/file-actions.component.html @@ -86,11 +86,12 @@ diff --git a/apps/red-ui/src/app/common/service/permissions.service.ts b/apps/red-ui/src/app/common/service/permissions.service.ts index 7b4d35139..b6daeaaa0 100644 --- a/apps/red-ui/src/app/common/service/permissions.service.ts +++ b/apps/red-ui/src/app/common/service/permissions.service.ts @@ -120,6 +120,16 @@ export class PermissionsService { return fileStatus.status === 'UNDER_APPROVAL' && this.isManagerAndOwner(); } + isReadyForApproval(fileStatus?: FileStatusWrapper) { + if (!fileStatus) { + fileStatus = this._appStateService.activeFile; + } + if (!fileStatus) { + return false; + } + return this.canSetUnderReview(fileStatus); + } + canApprove(fileStatus?: FileStatusWrapper) { if (!fileStatus) { fileStatus = this._appStateService.activeFile; @@ -127,12 +137,7 @@ export class PermissionsService { if (!fileStatus) { return false; } - return ( - this.canSetUnderReview(fileStatus) && - !fileStatus.hasRequests && - !fileStatus.hasUnappliedSuggestions && - this._appStateService.isFileUpToDateWithDictionaryAndRules(fileStatus) - ); + return !fileStatus.hasRequests && !fileStatus.hasUnappliedSuggestions && this._appStateService.isFileUpToDateWithDictionaryAndRules(fileStatus); } canSetUnderApproval(fileStatus?: FileStatusWrapper) { diff --git a/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.html b/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.html index 3e9b4e80d..61856eb3a 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.html +++ b/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.html @@ -29,13 +29,16 @@ + + [tooltip]="canApprove ? 'project-overview.approve' : 'project-overview.approve-disabled'" + > + diff --git a/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.ts b/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.ts index 196951b45..56b903be8 100644 --- a/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.ts +++ b/apps/red-ui/src/app/screens/project-overview-screen/bulk-actions/bulk-actions.component.ts @@ -106,6 +106,10 @@ export class BulkActionsComponent { } // Approve + public get isReadyForApproval() { + return this.selectedFiles.reduce((acc, file) => acc && this._permissionsService.isReadyForApproval(file), true); + } + public get canApprove() { return this.selectedFiles.reduce((acc, file) => acc && this._permissionsService.canApprove(file), true); } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 274f5f7c5..07fd7934b 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -202,6 +202,7 @@ "download-redacted-file-preview": "Download Redacted File(s) Preview", "under-approval": "For Approval", "approve": "Approve", + "approve-disabled": "File can only be approved once it has been analysed with the latest dictionaries and all suggestions have been processed", "under-review": "Under Review", "no-files-match": "No File match your current filters", "upload-files": "Drag & Drop files anywhere",