From 858d0bd5114d28c87700efc569c4ae951bcbcbcc Mon Sep 17 00:00:00 2001 From: Timo Date: Fri, 14 May 2021 11:34:40 +0300 Subject: [PATCH] finished approver assign --- .../file-actions/file-actions.component.html | 6 +++--- .../assign-reviewer-approver-dialog.component.html | 2 +- .../assign-reviewer-approver-dialog.component.ts | 9 ++++++--- .../file-preview-screen.component.html | 8 ++++---- .../file-preview-screen.component.ts | 10 ++++++++++ apps/red-ui/src/app/services/permissions.service.ts | 6 ++++-- 6 files changed, 28 insertions(+), 13 deletions(-) diff --git a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html index 75a7b8604..c15d51686 100644 --- a/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html +++ b/apps/red-ui/src/app/modules/projects/components/file-actions/file-actions.component.html @@ -30,7 +30,7 @@
-
+
{{ 'assign-' + data.mode + '-owner.dialog.single-user' | translate }} diff --git a/apps/red-ui/src/app/modules/projects/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts b/apps/red-ui/src/app/modules/projects/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts index 53cd464c7..2598162e4 100644 --- a/apps/red-ui/src/app/modules/projects/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts +++ b/apps/red-ui/src/app/modules/projects/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component.ts @@ -4,7 +4,7 @@ import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { AppStateService } from '@state/app-state.service'; import { UserService } from '@services/user.service'; import { NotificationService, NotificationType } from '@services/notification.service'; -import { FormBuilder, FormGroup } from '@angular/forms'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; import { FileStatusWrapper } from '@models/file/file-status.wrapper'; import { ProjectWrapper } from '@state/model/project.wrapper'; @@ -105,9 +105,12 @@ export class AssignReviewerApproverDialogComponent { uniqueReviewers.add(file.currentReviewer); } } - const singleUser = uniqueReviewers.size === 1 ? uniqueReviewers.values().next().value : this.userService.userId; + let singleUser = uniqueReviewers.size === 1 ? uniqueReviewers.values().next().value : this.userService.userId; + + singleUser = this.singleUsersSelectOptions.indexOf(singleUser) >= 0 ? singleUser : this.singleUsersSelectOptions[0]; + this.usersForm = this._formBuilder.group({ - singleUser: [singleUser] + singleUser: [singleUser, Validators.required] }); } } diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html index 6fbad582e..784a7edf3 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.html @@ -79,20 +79,20 @@ size="small" > - - + +
-
+
diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts index a1dd91afc..b45cb4c17 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts @@ -90,6 +90,14 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, }); } + get singleUsersSelectOptions() { + return this.appStateService.activeFile?.isUnderApproval ? this.appStateService.activeProject.approverIds : this.appStateService.activeProject.memberIds; + } + + get assignTooltip() { + return this.appStateService.activeFile.isUnderApproval ? 'project-overview.assign-approver' : 'project-overview.assign-reviewer'; + } + get annotations(): AnnotationWrapper[] { return this.annotationData ? this.annotationData.visibleAnnotations : []; } @@ -341,6 +349,8 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, } async fileActionPerformed(action: string) { + this.editingReviewer = false; + switch (action) { case 'delete': await this._router.navigate([`/main/projects/${this.projectId}`]); diff --git a/apps/red-ui/src/app/services/permissions.service.ts b/apps/red-ui/src/app/services/permissions.service.ts index ecaa1eb35..654e7f2ab 100644 --- a/apps/red-ui/src/app/services/permissions.service.ts +++ b/apps/red-ui/src/app/services/permissions.service.ts @@ -107,7 +107,7 @@ export class PermissionsService { const precondition = this.isProjectMember() && !fileStatus.isProcessing && !fileStatus.isError && !fileStatus.isExcluded && !fileStatus.isApproved; if (precondition) { - if (fileStatus.isUnassigned && !this.isApprover()) { + if ((fileStatus.isUnassigned || fileStatus.isUnderReview) && !this.isApprover()) { return true; } } @@ -122,7 +122,9 @@ export class PermissionsService { return false; } - const precondition = this.isProjectMember() && !fileStatus.isProcessing && !fileStatus.isError && !fileStatus.isExcluded && !fileStatus.isApproved; + const precondition = + this.isProjectMember() && !fileStatus.isProcessing && !fileStatus.isError && !fileStatus.isExcluded && !fileStatus.isApproved && this.isApprover(); + if (precondition) { if ((fileStatus.isUnassigned || fileStatus.isUnderReview) && this._appStateService.activeProject.hasMoreThanOneReviewer) { return true;