diff --git a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html index a225f4a8c..f69402da4 100644 --- a/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html +++ b/apps/red-ui/src/app/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.html @@ -8,12 +8,18 @@ {{ manualRedactionEntryWrapper.manualRedactionEntry.value }} -
+
- + + + {{ option.label }} + + +
+ +
+ +
@@ -21,32 +27,18 @@
-
+
- - - {{ dictionary.label }} - - - + - + {{ dictionary.label }} - + {{ dictionary.label }} @@ -55,13 +47,7 @@
- +
- @@ -17,29 +17,24 @@ - + + - - - -
- -
-
-
- -
-
-
+ + + +
+ +
+
+
+ +
+
+
+
diff --git a/apps/red-ui/src/app/screens/file/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/screens/file/annotation-actions/annotation-actions.component.ts index 8244f9289..929dd4b08 100644 --- a/apps/red-ui/src/app/screens/file/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/screens/file/annotation-actions/annotation-actions.component.ts @@ -74,13 +74,6 @@ export class AnnotationActionsComponent implements OnInit { this.menuOpen = false; } - canUndoAnnotation() { - const isSuggestionOfCurrentUser = this.annotation.isSuggestion && this.annotation.userId === this.permissionsService.currentUserId; - const isManualAnnotationOfCurrentUser = - this.annotation.manual && this.annotation.userId === this.permissionsService.currentUserId && this.permissionsService.isManagerAndOwner(); - return isSuggestionOfCurrentUser || isManualAnnotationOfCurrentUser; - } - get suggestionColor() { return this.appStateService.getDictionaryColor('suggestion'); } @@ -88,4 +81,31 @@ export class AnnotationActionsComponent implements OnInit { get dictionaryColor() { return this.appStateService.getDictionaryColor('suggestion-dictionary'); } + + showSimpleSuggestRemove() { + return this._canRemove() && !this._showComplexMenu(); + } + + showMenuSuggestRemove() { + return this._canRemove() && this._showComplexMenu(); + } + + private _showComplexMenu() { + // we can show the complex dialog only for redactions that are not manual, but this is already checked via canUndo + return this.annotation.superType === 'redaction' && this.annotation.dictionary !== 'manual'; + } + + canUndoAnnotation() { + // suggestions of current user can be undone + const isSuggestionOfCurrentUser = this.annotation.isSuggestion && this.annotation.userId === this.permissionsService.currentUserId; + // or any performed manual actions and you are the manager, provided that it is not a suggestion + const isActionOfManger = this.permissionsService.isManagerAndOwner() && this.annotation.userId === this.permissionsService.currentUserId; + return isSuggestionOfCurrentUser || isActionOfManger; + } + + private _canRemove() { + const canUndo = this.canUndoAnnotation(); + // you can do a simple remove for anything you cannot undo, that is not ignored + return !canUndo && !this.annotation.isIgnored; + } } diff --git a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts index ee126563d..3249d77bb 100644 --- a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts +++ b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts @@ -56,16 +56,6 @@ export class AnnotationWrapper { annotationWrapper.userId = manualRedactionEntry?.user || idRemoval?.user; if (redactionLogEntry) { - if (redactionLogEntry.manual) { - if (!manualRedactionEntry && redactionLogEntry.manualRedactionType === 'ADD') { - // do not draw if it is no longer in the manual redactions - annotationWrapper.shouldDraw = false; - } - if (manualRedactionEntry) { - annotationWrapper.shouldDraw = manualRedactionEntry.status === 'REQUESTED' || manualRedactionEntry.status === 'APPROVED'; - } - } - annotationWrapper.id = redactionLogEntry.id; annotationWrapper.redaction = redactionLogEntry.redacted; annotationWrapper.hint = redactionLogEntry.hint; @@ -77,7 +67,26 @@ export class AnnotationWrapper { // either marked as manual or idRemove or manualRedactionEntry exists annotationWrapper.manual = redactionLogEntry.manual; annotationWrapper.modifyDictionary = !!manualRedactionEntry?.addToDictionary || !!idRemoval?.removeFromDictionary; + + if (redactionLogEntry.manual) { + // marked as add but the entryToAdd has been undone + if (!manualRedactionEntry && redactionLogEntry.manualRedactionType === 'ADD') { + // do not draw if it is no longer in the manual redactions + annotationWrapper.shouldDraw = false; + } + if (manualRedactionEntry) { + annotationWrapper.shouldDraw = manualRedactionEntry.status === 'REQUESTED' || manualRedactionEntry.status === 'APPROVED'; + } + + // marked as remove but the idRemoval has been undone + if (redactionLogEntry.manualRedactionType === 'REMOVE' && !idRemoval) { + const dictionary = dictionaryData[redactionLogEntry.type]; + annotationWrapper.redaction = !dictionary.hint; + annotationWrapper.hint = dictionary.hint; + } + } } else { + // no redaction log entry - not yet processed const dictionary = dictionaryData[manualRedactionEntry.type]; annotationWrapper.id = manualRedactionEntry.id; annotationWrapper.redaction = !dictionary.hint; diff --git a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts index 283f72a04..9362e3db3 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts @@ -13,7 +13,6 @@ export class AnnotationDrawService { public drawAnnotations(activeViewer: WebViewerInstance, annotationWrappers: AnnotationWrapper[]) { annotationWrappers.forEach((annotation) => { - console.log('draw', annotation); this.drawAnnotation(activeViewer, annotation); }); } diff --git a/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts b/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts index 4fc86e54f..aad86fb91 100644 --- a/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts +++ b/apps/red-ui/src/app/screens/file/service/manual-annotation.service.ts @@ -124,24 +124,38 @@ export class ManualAnnotationService { // /manualRedaction/request/remove/ removeOrSuggestRemoveAnnotation(annotationWrapper: AnnotationWrapper, removeFromDictionary: boolean = false) { if (this._permissionsService.isManagerAndOwner()) { - return this._manualRedactionControllerService - .removeRedaction( - { - annotationId: annotationWrapper.id, - removeFromDictionary: removeFromDictionary, - comment: 'Auto' - }, - this._appStateService.activeProjectId, - this._appStateService.activeFileId - ) - .pipe( - tap( - () => this._notify('manual-annotation.remove-redaction-request.success'), - () => { - this._notify('manual-annotation.remove-redaction-request.error', NotificationType.ERROR); - } + // if it was something manual simply decline the existing request + if (annotationWrapper.dictionary === 'manual') { + return this._manualRedactionControllerService + .declineRequest(this._appStateService.activeProjectId, this._appStateService.activeFileId, annotationWrapper.id) + .pipe( + tap( + () => this._notify('manual-annotation.undo-request.success'), + () => { + this._notify('manual-annotation.undo-request.error', NotificationType.ERROR); + } + ) + ); + } else { + return this._manualRedactionControllerService + .removeRedaction( + { + annotationId: annotationWrapper.id, + removeFromDictionary: removeFromDictionary, + comment: 'Auto' + }, + this._appStateService.activeProjectId, + this._appStateService.activeFileId ) - ); + .pipe( + tap( + () => this._notify('manual-annotation.remove-redaction-request.success'), + () => { + this._notify('manual-annotation.remove-redaction-request.error', NotificationType.ERROR); + } + ) + ); + } } else { return this._manualRedactionControllerService .requestRemoveRedaction( diff --git a/apps/red-ui/src/app/state/app-state.service.ts b/apps/red-ui/src/app/state/app-state.service.ts index de94a3c7a..05af2ef8a 100644 --- a/apps/red-ui/src/app/state/app-state.service.ts +++ b/apps/red-ui/src/app/state/app-state.service.ts @@ -370,7 +370,11 @@ export class AppStateService { type: 'suggestion', virtual: true }; - + this._dictionaryData['manual'] = { + hexColor: colors.defaultColor, + type: 'manual', + virtual: true + }; this._dictionaryData['suggestion-dictionary'] = { hexColor: '#5B97DB', type: 'suggestion-dictionary', diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 76e93226f..3e85110d8 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -33,6 +33,7 @@ "text": "Selected text:", "dictionary": "Type", "reason": "Reason", + "legalBasis": "Legal Basis", "comment": "Comment" } }