From 01a7dc8abee002a37a7f1081593dfd6b1cc57019 Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Thu, 29 Oct 2020 14:26:58 +0200 Subject: [PATCH] added annotation wrapper class to reduce code clutter --- apps/red-ui/src/app/dialogs/dialog.service.ts | 15 +-- .../manual-redaction-dialog.component.ts | 4 +- .../file-preview-screen.component.html | 28 +++--- .../file-preview-screen.component.ts | 94 +++++++++---------- .../screens/file/model/annotation.wrapper.ts | 43 +++++++++ .../screens/file/service/filters.service.ts | 11 +-- .../red-ui/src/app/state/app-state.service.ts | 10 ++ apps/red-ui/src/app/utils/annotation-utils.ts | 51 ++++------ apps/red-ui/src/app/utils/functions.ts | 11 +++ 9 files changed, 151 insertions(+), 116 deletions(-) create mode 100644 apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts diff --git a/apps/red-ui/src/app/dialogs/dialog.service.ts b/apps/red-ui/src/app/dialogs/dialog.service.ts index 59e613ab9..6a3c0fb58 100644 --- a/apps/red-ui/src/app/dialogs/dialog.service.ts +++ b/apps/red-ui/src/app/dialogs/dialog.service.ts @@ -17,6 +17,7 @@ import { AssignOwnerDialogComponent } from './assign-owner-dialog/assign-owner-d import { ManualRedactionDialogComponent } from './manual-redaction-dialog/manual-redaction-dialog.component'; import { Annotations } from '@pdftron/webviewer'; import { ManualRedactionEntryWrapper } from '../screens/file/model/manual-redaction-entry.wrapper'; +import { AnnotationWrapper } from '../screens/file/model/annotation.wrapper'; const dialogConfig = { width: '600px', @@ -100,20 +101,17 @@ export class DialogService { public acceptSuggestionAnnotation( $event: MouseEvent, - annotation: Annotations.Annotation, + annotation: AnnotationWrapper, projectId: string, fileId: string ): MatDialogRef { $event.stopPropagation(); - const parts = annotation.Id.split(':'); - const annotationId = parts[parts.length - 1]; - const ref = this._dialog.open(ConfirmationDialogComponent, dialogConfig); ref.afterClosed().subscribe((result) => { if (result) { this._manualRedactionControllerService - .approveRequest(projectId, fileId, annotationId) + .approveRequest(projectId, fileId, annotation.uuid) .subscribe( () => { this._notificationService.showToastNotification( @@ -143,15 +141,12 @@ export class DialogService { public suggestRemoveAnnotation( $event: MouseEvent, - annotation: Annotations.Annotation, + annotation: AnnotationWrapper, projectId: string, fileId: string ): MatDialogRef { $event.stopPropagation(); - const parts = annotation.Id.split(':'); - const annotationId = parts[parts.length - 1]; - const ref = this._dialog.open(ConfirmationDialogComponent, { width: '400px', maxWidth: '90vw' @@ -160,7 +155,7 @@ export class DialogService { ref.afterClosed().subscribe((result) => { if (result) { this._manualRedactionControllerService - .undo(projectId, fileId, annotationId) + .undo(projectId, fileId, annotation.uuid) .subscribe( (ok) => { this._notificationService.showToastNotification( diff --git a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-redaction-dialog.component.ts b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-redaction-dialog.component.ts index ed8a0b73b..7542b5d23 100644 --- a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-redaction-dialog.component.ts @@ -36,9 +36,7 @@ export class ManualRedactionDialogComponent implements OnInit { ) {} async ngOnInit() { - this.isDocumentAdmin = - this._appStateService.isActiveProjectOwner && this._userService.user.isManager; - this.isDocumentAdmin = false; + this.isDocumentAdmin = this._appStateService.isActiveProjectOwner; const commentField = this.isDocumentAdmin ? [null] : [null, Validators.required]; this.redactionForm = this._formBuilder.group({ addToDictionary: [false], diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html index 9e41dc204..498320e93 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.html @@ -229,43 +229,41 @@
- {{ getType(annotation) | translate }} + {{ annotation.superType | humanize }}
-
+
: {{ getDictionary(annotation) }} + >{{ annotation.dictionary | humanize }}
-
+
: {{ annotation.getContents() }} + >{{ annotation.content }}
-
+
: - {{ comment.value }} + {{ comment }}
- {{ annotation.getPageNumber() }} + {{ annotation.pageNumber }}