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 3b4d6e05f..d4aa3b3c9 100644 --- a/apps/red-ui/src/app/models/file/annotation.permissions.ts +++ b/apps/red-ui/src/app/models/file/annotation.permissions.ts @@ -4,33 +4,16 @@ import { isArray } from 'rxjs/internal-compatibility'; export class AnnotationPermissions { canUndo = true; - canAcceptRecommendation = true; - canMarkTextOnlyAsFalsePositive = true; canMarkAsFalsePositive = true; - canRemoveOrSuggestToRemoveOnlyHere = true; canRemoveOrSuggestToRemoveFromDictionary = true; - canAcceptSuggestion = true; canRejectSuggestion = true; - canForceRedaction = true; - canChangeLegalBasis = true; - canRecategorizeImage = true; - get canPerformMultipleRemoveActions() { - return ( - this.canMarkTextOnlyAsFalsePositive + - this.canMarkAsFalsePositive + - this.canRemoveOrSuggestToRemoveFromDictionary + - this.canRemoveOrSuggestToRemoveOnlyHere >= - 2 - ); - } - static forUser(isApprover: boolean, user: UserWrapper, annotations: AnnotationWrapper | AnnotationWrapper[]) { if (!isArray(annotations)) { annotations = [annotations]; @@ -45,18 +28,16 @@ export class AnnotationPermissions { permissions.canForceRedaction = annotation.isSkipped; permissions.canAcceptRecommendation = annotation.isRecommendation; - permissions.canMarkAsFalsePositive = annotation.canBeMarkedAsFalsePositive && !annotation.force; - permissions.canMarkTextOnlyAsFalsePositive = annotation.canBeMarkedAsFalsePositiveWithTextOnly && !annotation.force; + permissions.canMarkAsFalsePositive = annotation.canBeMarkedAsFalsePositive; - permissions.canRemoveOrSuggestToRemoveOnlyHere = annotation.isRedacted && !annotation.force; + permissions.canRemoveOrSuggestToRemoveOnlyHere = annotation.isRedacted; permissions.canRemoveOrSuggestToRemoveFromDictionary = - (annotation.isRedacted && !annotation.isManualRedaction && annotation.isModifyDictionary && !annotation.force) || - (annotation.isSkipped && annotation.isModifyDictionary); + annotation.isModifyDictionary && (annotation.isRedacted || annotation.isSkipped); permissions.canAcceptSuggestion = isApprover && (annotation.isSuggestion || annotation.isDeclinedSuggestion); permissions.canRejectSuggestion = isApprover && annotation.isSuggestion; - permissions.canChangeLegalBasis = !annotation.isManualRedaction && annotation.isRedacted; + permissions.canChangeLegalBasis = annotation.isRedacted; permissions.canRecategorizeImage = annotation.isImage; 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 6ea89801f..048b570b5 100644 --- a/apps/red-ui/src/app/models/file/annotation.wrapper.ts +++ b/apps/red-ui/src/app/models/file/annotation.wrapper.ts @@ -60,10 +60,6 @@ export class AnnotationWrapper { constructor() {} - get isUndoableActionForApprover() { - return this.manual; - } - get isChangeLogRemoved() { return this.changeLogType === 'REMOVED'; } @@ -81,11 +77,7 @@ export class AnnotationWrapper { } get canBeMarkedAsFalsePositive() { - return (this.isRecommendation || this.superType === 'redaction') && (this.hasTextAfter || this.hasTextBefore) && !this.isImage; - } - - get canBeMarkedAsFalsePositiveWithTextOnly() { - return !this.canBeMarkedAsFalsePositive && (this.isRecommendation || this.superType === 'redaction') && !this.isImage; + return (this.isRecommendation || this.superType === 'redaction') && !this.isImage; } get isSuperTypeBasedColor() { @@ -104,6 +96,10 @@ export class AnnotationWrapper { return this.dictionary?.toLowerCase() === 'ocr'; } + get isManuallySkipped() { + return this.isSkipped && this.manual; + } + get isFalsePositive() { return ( this.dictionary?.toLowerCase() === 'false_positive' && @@ -259,6 +255,32 @@ export class AnnotationWrapper { return; } + if (annotationWrapper.dictionary?.toLowerCase() === 'false_positive') { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add-dictionary'; + return; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'add-dictionary'; + return; + } + if (!redactionLogEntryWrapper.manual) { + annotationWrapper.superType = 'skipped'; + } + return; + } + + if (redactionLogEntryWrapper.type?.toLowerCase() === 'manual') { + if (redactionLogEntryWrapper.status === 'REQUESTED') { + annotationWrapper.superType = 'suggestion-add'; + return; + } + if (redactionLogEntryWrapper.status === 'APPROVED') { + annotationWrapper.superType = 'manual-redaction'; + return; + } + } + if (redactionLogEntryWrapper.manualRedactionType === 'LEGAL_BASIS_CHANGE') { if (redactionLogEntryWrapper.status === 'REQUESTED') { annotationWrapper.superType = 'suggestion-change-legal-basis'; @@ -279,21 +301,6 @@ export class AnnotationWrapper { } } - if (annotationWrapper.dictionary?.toLowerCase() === 'false_positive') { - if (redactionLogEntryWrapper.status === 'REQUESTED') { - annotationWrapper.superType = 'suggestion-add-dictionary'; - return; - } - if (redactionLogEntryWrapper.status === 'APPROVED') { - annotationWrapper.superType = 'add-dictionary'; - return; - } - if (!redactionLogEntryWrapper.manual) { - annotationWrapper.superType = 'skipped'; - } - return; - } - if (redactionLogEntryWrapper.manualRedactionType === 'ADD') { if (redactionLogEntryWrapper.dictionaryEntry) { if (redactionLogEntryWrapper.status === 'REQUESTED') { diff --git a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html index 1be35c2eb..751745088 100644 --- a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html @@ -53,15 +53,6 @@ icon="red:thumb-down" > - - ) { $event?.stopPropagation(); annotations.forEach(annotation => { - console.log('Accept ', annotation); this._processObsAndEmit( this._manualAnnotationService.approveRequest(annotation.id, annotation.isModifyDictionary), annotation, @@ -89,14 +88,7 @@ export class AnnotationActionsService { markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[], annotationsChanged: EventEmitter) { annotations.forEach(annotation => { - const permissions = AnnotationPermissions.forUser( - this._permissionsService.isApprover(), - this._userService.currentUser, - annotation - ); - const value = permissions.canMarkTextOnlyAsFalsePositive ? annotation.value : this._getFalsePositiveText(annotation); - - this._markAsFalsePositive($event, annotation, value, annotationsChanged); + this._markAsFalsePositive($event, annotation, this._getFalsePositiveText(annotation), annotationsChanged); }); } @@ -212,10 +204,7 @@ export class AnnotationActionsService { }); } - const canMarkAsFalsePositive = annotationPermissions.reduce( - (acc, next) => acc && (next.permissions.canMarkAsFalsePositive || next.permissions.canMarkTextOnlyAsFalsePositive), - true - ); + const canMarkAsFalsePositive = annotationPermissions.reduce((acc, next) => acc && next.permissions.canMarkAsFalsePositive, true); if (canMarkAsFalsePositive) { availableActions.push({ type: 'actionButton', @@ -293,10 +282,13 @@ export class AnnotationActionsService { let text; if (annotation.hasTextAfter) { text = getFirstRelevantTextPart(annotation.textAfter, 'FORWARD'); - return (annotation.value + text).trim(); - } else { + return text ? (annotation.value + text).trim() : annotation.value; + } + if (annotation.hasTextAfter) { text = getFirstRelevantTextPart(annotation.textBefore, 'BACKWARD'); - return (text + annotation.value).trim(); + return text ? (text + annotation.value).trim() : annotation.value; + } else { + return annotation.value; } } } diff --git a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts index 550db6f80..da8078b92 100644 --- a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts @@ -169,7 +169,7 @@ export class ManualAnnotationService { if (this._permissionsService.isApprover()) { // if it was something manual simply decline the existing request if (annotationWrapper.dictionary === 'manual') { - mode = 'decline'; + mode = 'undo'; body = annotationWrapper.id; } else { mode = 'remove'; @@ -218,7 +218,6 @@ export class ManualAnnotationService { private _getMessage(mode: AnnotationActionMode, modifyDictionary?: boolean, error: boolean = false) { const type = modifyDictionary ? 'dictionary' : 'manual-redaction'; const resultType = error ? 'error' : 'success'; - console.log(type, mode, resultType); return annotationActionsTranslations[type][mode][resultType]; } } diff --git a/libs/common-ui b/libs/common-ui index 360ef9bd6..1d46b21c7 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 360ef9bd6c87ec2ebb22554253e9ce9390775f09 +Subproject commit 1d46b21c74c07d6811a99b9de6c940c740bc8ceb