From 7ae0a2fa5e83ba74bbc73d179edccf777dc80e83 Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 27 Nov 2020 10:36:46 +0200 Subject: [PATCH] unified rules for edit and delete of projects --- .../src/app/common/service/permissions.service.ts | 11 +++++++++-- .../project-listing-screen.component.html | 8 +++++--- .../project-overview-screen.component.html | 3 +++ 3 files changed, 17 insertions(+), 5 deletions(-) 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 69cf2cca2..ae87066d1 100644 --- a/apps/red-ui/src/app/common/service/permissions.service.ts +++ b/apps/red-ui/src/app/common/service/permissions.service.ts @@ -66,8 +66,8 @@ export class PermissionsService { return fileStatus.currentReviewer === this._userService.userId; } - canDeleteFile(fileStatus?: FileStatusWrapper) { - return this.isManagerAndOwner() || fileStatus.isUnassigned; + canDeleteFile(fileStatus?: FileStatusWrapper, project?: Project) { + return this.isManagerAndOwner(project) || fileStatus.isUnassigned; } isApprovedOrUnderApproval(fileStatus?: FileStatusWrapper) { @@ -189,4 +189,11 @@ export class PermissionsService { } return fileStatus.status === 'APPROVED' && this.isManagerAndOwner(); } + + canDeleteProject(project?: ProjectWrapper) { + if (!project) { + project = this._appStateService.activeProject; + } + return project.files.reduce((acc, file) => acc && this.canDeleteFile(file, project.project), true); + } } diff --git a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html index ee2c62b7f..1af711d76 100644 --- a/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html +++ b/apps/red-ui/src/app/screens/project-listing-screen/project-listing-screen.component.html @@ -23,7 +23,7 @@ >
- -
+