From f26cbbaa1c4c6ff76c5c263b13383734a801f5b3 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 14 Jul 2021 11:52:46 +0300 Subject: [PATCH] minor fixes and - RED-1758 --- .../app/models/file/annotation.permissions.ts | 5 +- .../src/app/models/file/annotation.wrapper.ts | 165 ++++++++---------- .../src/app/models/file/file-data.model.ts | 8 +- .../file/redaction-log-entry.wrapper.ts | 5 +- .../src/app/modules/auth/red-role.guard.ts | 5 +- .../file-preview-screen.component.ts | 2 +- .../services/pdf-viewer-data.service.ts | 4 + 7 files changed, 87 insertions(+), 107 deletions(-) diff --git a/apps/red-ui/src/app/models/file/annotation.permissions.ts b/apps/red-ui/src/app/models/file/annotation.permissions.ts index bf2197b92..55dc11761 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -34,9 +34,8 @@ export class AnnotationPermissions { const permissions: AnnotationPermissions = new AnnotationPermissions(); permissions.canUndo = - annotation.isUndoableSuperType && - (annotation.userId === user.id || - (annotation.userId && isApprover && !annotation.isSuggestion)); + (!isApprover && annotation.isSuggestion) || + (isApprover && annotation.isUndoableActionForApprover); permissions.canForceRedaction = annotation.isSkipped && !permissions.canUndo; diff --git a/apps/red-ui/src/app/models/file/annotation.wrapper.ts b/apps/red-ui/src/app/models/file/annotation.wrapper.ts index e535be68f..46d25d634 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -6,10 +6,10 @@ export class AnnotationWrapper { | 'add-dictionary' | 'remove-dictionary' | 'remove-only-here' + | 'change-legal-basis' | 'suggestion-change-legal-basis' | 'suggestion-add-dictionary' | 'suggestion-force-redaction' - | 'change-legal-basis' | 'suggestion-remove-dictionary' | 'suggestion-add' | 'suggestion-remove' @@ -29,7 +29,6 @@ export class AnnotationWrapper { shortContent: string; content: string; value: string; - userId: string; typeLabel: string; pageNumber: number; hint: boolean; @@ -41,6 +40,8 @@ export class AnnotationWrapper { legalBasis: string; legalBasisChangeValue?: string; + manual?: boolean; + image?: boolean; force?: boolean; @@ -54,21 +55,8 @@ export class AnnotationWrapper { constructor() {} - get isUndoableSuperType() { - return ( - this.superType === 'add-dictionary' || - this.superType === 'remove-dictionary' || - this.superType === 'suggestion-add-dictionary' || - this.superType === 'suggestion-force-redaction' || - this.superType === 'suggestion-remove-dictionary' || - this.superType === 'suggestion-change-legal-basis' || - this.superType === 'suggestion-add' || - this.superType === 'change-legal-basis' || - this.superType === 'suggestion-remove' || - this.superType === 'skipped' || - this.superType === 'redaction' || - this.superType === 'manual-redaction' - ); + get isUndoableActionForApprover() { + return this.manual; } get isChangeLogRemoved() { @@ -219,7 +207,6 @@ export class AnnotationWrapper { annotationWrapper._origin = redactionLogEntry; annotationWrapper.annotationId = redactionLogEntry.id; - annotationWrapper.force = redactionLogEntry.force; annotationWrapper.isChangeLogEntry = redactionLogEntry.isChangeLogEntry; annotationWrapper.changeLogType = redactionLogEntry.changeLogType; annotationWrapper.redaction = redactionLogEntry.redacted; @@ -233,14 +220,14 @@ export class AnnotationWrapper { annotationWrapper.textBefore = redactionLogEntry.textBefore; annotationWrapper.textAfter = redactionLogEntry.textAfter; annotationWrapper.dictionaryOperation = redactionLogEntry.dictionaryEntry; - annotationWrapper.userId = redactionLogEntry.userId; annotationWrapper.image = redactionLogEntry.image; annotationWrapper.legalBasisChangeValue = redactionLogEntry.legalBasisChangeValue; annotationWrapper.comments = redactionLogEntry.comments || []; annotationWrapper.legalBasis = redactionLogEntry.legalBasis; + annotationWrapper.manual = redactionLogEntry.manual; + this._createContent(annotationWrapper, redactionLogEntry); this._setSuperType(annotationWrapper, redactionLogEntry); - this._handleSkippedState(annotationWrapper, redactionLogEntry); this._handleRecommendations(annotationWrapper, redactionLogEntry); annotationWrapper.typeLabel = 'annotation-type.' + annotationWrapper.superType; @@ -262,25 +249,35 @@ export class AnnotationWrapper { annotationWrapper: AnnotationWrapper, redactionLogEntryWrapper: RedactionLogEntryWrapper ) { - if (redactionLogEntryWrapper.legalBasisChangeValue) { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-change-legal-basis'; - } else if (redactionLogEntryWrapper.actionPendingReanalysis) { - annotationWrapper.superType = 'change-legal-basis'; + if (redactionLogEntryWrapper.recommendation) { + if (redactionLogEntryWrapper.redacted) { + annotationWrapper.superType = 'recommendation'; } else { - annotationWrapper.superType = 'redaction'; + annotationWrapper.superType = 'skipped'; } return; } - if (redactionLogEntryWrapper.recommendation) { - if (redactionLogEntryWrapper.redacted) { - annotationWrapper.superType = 'recommendation'; - return; + if (redactionLogEntryWrapper.manualRedactionType === 'FORCE_REDACT') { + annotationWrapper.force = true; + + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-force-redaction'; + } else if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'redaction'; } else { annotationWrapper.superType = 'skipped'; - return; } + return; + } + + if (redactionLogEntryWrapper.manualRedactionType === 'LEGAL_BASIS_CHANGE') { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-change-legal-basis'; + } else { + annotationWrapper.superType = 'redaction'; + } + return; } if (redactionLogEntryWrapper.status === 'DECLINED') { @@ -295,45 +292,53 @@ export class AnnotationWrapper { if (redactionLogEntryWrapper.status === 'APPROVED') { annotationWrapper.superType = 'add-dictionary'; } - } else { - if (redactionLogEntryWrapper.redacted) { - if (redactionLogEntryWrapper.force) { + return; + } + + if (redactionLogEntryWrapper.manualRedactionType === 'ADD') { + if (redactionLogEntryWrapper.dictionaryEntry) { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add-dictionary'; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'add-dictionary'; + } + } else { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add'; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'manual-redaction'; + } + } + } + + if (redactionLogEntryWrapper.redacted) { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + if (redactionLogEntryWrapper.dictionaryEntry) { annotationWrapper.superType = - redactionLogEntryWrapper.status === 'REQUESTED' - ? 'suggestion-add' - : 'redaction'; - } else if (redactionLogEntryWrapper.type === 'manual') { - annotationWrapper.superType = - redactionLogEntryWrapper.status === 'REQUESTED' - ? 'suggestion-add' - : 'manual-redaction'; + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'suggestion-add-dictionary' + : 'suggestion-remove-dictionary'; } else { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - if (redactionLogEntryWrapper.dictionaryEntry) { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'suggestion-add-dictionary' - : 'suggestion-remove-dictionary'; - } else { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'suggestion-add' - : 'suggestion-remove'; - } - } - if (redactionLogEntryWrapper.status === 'APPROVED') { - if (redactionLogEntryWrapper.dictionaryEntry) { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'add-dictionary' - : 'remove-dictionary'; - } else { - annotationWrapper.superType = - redactionLogEntryWrapper.manualRedactionType === 'ADD' - ? 'manual-redaction' - : 'remove-only-here'; - } - } + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'suggestion-add' + : 'suggestion-remove'; + } + } + + if (redactionLogEntryWrapper.status === 'APPROVED') { + if (redactionLogEntryWrapper.dictionaryEntry) { + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'add-dictionary' + : 'remove-dictionary'; + } else { + annotationWrapper.superType = + redactionLogEntryWrapper.manualRedactionType === 'ADD' + ? 'manual-redaction' + : 'remove-only-here'; } } } @@ -347,30 +352,6 @@ export class AnnotationWrapper { } } - private static _handleSkippedState( - annotationWrapper: AnnotationWrapper, - redactionLogEntryWrapper: RedactionLogEntryWrapper - ) { - if (annotationWrapper.superType !== 'skipped') return; - - if (!annotationWrapper.userId) { - if ( - redactionLogEntryWrapper.manualRedactionType === 'REMOVE' || - redactionLogEntryWrapper.manualRedactionType === 'UNDO' - ) { - annotationWrapper.superType = 'pending-analysis'; - return; - } - } else if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-force-redaction'; - return; - } - - if (redactionLogEntryWrapper.actionPendingReanalysis) { - annotationWrapper.superType = 'pending-analysis'; - } - } - private static _createContent( annotationWrapper: AnnotationWrapper, entry: RedactionLogEntryWrapper diff --git a/apps/red-ui/src/app/models/file/file-data.model.ts b/apps/red-ui/src/app/models/file/file-data.model.ts index 440c91025..2484090e8 100644 --- a/apps/red-ui/src/app/models/file/file-data.model.ts +++ b/apps/red-ui/src/app/models/file/file-data.model.ts @@ -64,9 +64,7 @@ export class FileDataModel { return; } - const redactionLogEntryWrapper: RedactionLogEntryWrapper = { - actionPendingReanalysis: false - }; + const redactionLogEntryWrapper: RedactionLogEntryWrapper = {}; Object.assign(redactionLogEntryWrapper, changeLogEntry); @@ -94,9 +92,7 @@ export class FileDataModel { ); // copy the redactionLog Entry - const redactionLogEntryWrapper: RedactionLogEntryWrapper = { - actionPendingReanalysis: false - }; + const redactionLogEntryWrapper: RedactionLogEntryWrapper = {}; Object.assign(redactionLogEntryWrapper, redactionLogEntry); redactionLogEntryWrapper.isChangeLogEntry = !!existingChangeLogEntry; redactionLogEntryWrapper.changeLogType = 'ADDED'; diff --git a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts index 26253f957..a9592e82e 100644 --- a/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts +++ b/apps/red-ui/src/app/models/file/redaction-log-entry.wrapper.ts @@ -8,7 +8,7 @@ export interface RedactionLogEntryWrapper { legalBasis?: string; legalBasisMapping?: Array; manual?: boolean; - manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE'; + manualRedactionType?: 'ADD' | 'REMOVE' | 'UNDO' | 'LEGAL_BASIS_CHANGE' | 'FORCE_REDACT'; matchedRule?: number; positions?: Array; reason?: string; @@ -20,14 +20,11 @@ export interface RedactionLogEntryWrapper { textBefore?: string; type?: string; value?: string; - force?: boolean; image?: boolean; recommendation?: boolean; recommendationAnnotationId?: string; - actionPendingReanalysis?: boolean; - hidden?: boolean; userId?: string; diff --git a/apps/red-ui/src/app/modules/auth/red-role.guard.ts b/apps/red-ui/src/app/modules/auth/red-role.guard.ts index 6ce704eb7..5c9c0d5d5 100644 --- a/apps/red-ui/src/app/modules/auth/red-role.guard.ts +++ b/apps/red-ui/src/app/modules/auth/red-role.guard.ts @@ -27,7 +27,10 @@ export class RedRoleGuard implements CanActivate { if ( this._userService.user.isUserAdmin && !this._userService.user.isAdmin && - !state.url.startsWith('/main/admin/users') + !( + state.url.startsWith('/main/admin/users') || + state.url.startsWith('/main/my-profile') + ) ) { this._router.navigate(['/main/admin/users']); obs.next(false); diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 121bc8298..feb5bbb22 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -78,7 +78,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, @ViewChild(PdfViewerComponent) viewerComponent: PdfViewerComponent; private _instance: WebViewerInstance; private _lastPage: string; - private _reloadFileOnReanalysis: boolean = false; + private _reloadFileOnReanalysis = false; @ViewChild('fileWorkloadComponent') private _workloadComponent: FileWorkloadComponent; diff --git a/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts b/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts index 6f2aa7f80..64a9e00d5 100644 --- a/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/pdf-viewer-data.service.ts @@ -3,6 +3,7 @@ import { forkJoin, Observable, of } from 'rxjs'; import { catchError, map } from 'rxjs/operators'; import { FileManagementControllerService, + ManualRedactionControllerService, RedactionLogControllerService, ViewedPagesControllerService } from '@redaction/red-ui-http'; @@ -16,6 +17,7 @@ export class PdfViewerDataService { constructor( private readonly _appStateService: AppStateService, private readonly _permissionsService: PermissionsService, + private readonly _man: ManualRedactionControllerService, private readonly _fileManagementControllerService: FileManagementControllerService, private readonly _redactionLogControllerService: RedactionLogControllerService, private readonly _viewedPagesControllerService: ViewedPagesControllerService @@ -32,6 +34,8 @@ export class PdfViewerDataService { const dossierId = this._appStateService.activeDossierId; const fileId = this._appStateService.activeFileId; + this._man.getManualRedaction(dossierId, fileId).subscribe(); + const file$ = this.downloadOriginalFile(this._appStateService.activeFile); const reactionLog$ = this._redactionLogControllerService .getRedactionLogPreview(dossierId, fileId)