diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index 52775b2dd..566b20797 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -93,7 +93,7 @@ export class AnnotationActionsService { async editRedaction(annotations: AnnotationWrapper[]) { const { dossierId, dossierTemplateId, fileId, file } = this._state; - const isUnprocessed = annotations.every(annotation => annotation.pending); + const includeUnprocessed = annotations.every(annotation => this.#includeUnprocessed(annotation, true)); const dossierTemplate = this._dossierTemplatesService.find(dossierTemplateId); const data = { annotations, @@ -126,7 +126,7 @@ export class AnnotationActionsService { dossierId, fileId, this.#getChangedFields(annotations, result), - file().excludedFromAutomaticAnalysis && isUnprocessed, + includeUnprocessed, ) .pipe(log()), ); @@ -150,7 +150,6 @@ export class AnnotationActionsService { }; const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); const isApprover = this._permissionsService.isApprover(this._state.dossier()); - const isUnprocessed = redactions.every(annotation => annotation.pending); const data = { redactions, @@ -173,7 +172,7 @@ export class AnnotationActionsService { ) { this.#setAsFalsePositive(redactions, result); } else { - this.#removeRedaction(redactions, result, this._state.file().excludedFromAutomaticAnalysis && isUnprocessed); + this.#removeRedaction(redactions, result); } } @@ -225,6 +224,7 @@ export class AnnotationActionsService { async acceptResize(annotation: AnnotationWrapper, permissions: AnnotationPermissions): Promise { const textAndPositions = await this.#extractTextAndPositions(annotation.id); + const includeUnprocessed = this.#includeUnprocessed(annotation); if (annotation.isRecommendation) { const recommendation = { ...annotation, @@ -276,12 +276,7 @@ export class AnnotationActionsService { await this.cancelResize(annotation); const { fileId, dossierId, file } = this._state; - const request = this._manualRedactionService.resize( - [resizeRequest], - dossierId, - fileId, - isUnprocessed && file().excludedFromAutomaticAnalysis, - ); + const request = this._manualRedactionService.resize([resizeRequest], dossierId, fileId, includeUnprocessed); return this.#processObsAndEmit(request); } @@ -436,8 +431,9 @@ export class AnnotationActionsService { this.#processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId)).then(); } - #removeRedaction(redactions: AnnotationWrapper[], dialogResult: RemoveRedactionResult, includeUnprocessed = false) { + #removeRedaction(redactions: AnnotationWrapper[], dialogResult: RemoveRedactionResult) { const removeFromDictionary = dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER; + const includeUnprocessed = redactions.every(redaction => this.#includeUnprocessed(redaction, true)); const body = redactions.map(redaction => ({ annotationId: redaction.id, comment: dialogResult.comment, @@ -504,4 +500,18 @@ export class AnnotationActionsService { } return { changes: changedFields.join(', ') }; } + + //TODO this is temporary, based on RED-8950. Should be removed when a better solution will be found + #includeUnprocessed(annotation: AnnotationWrapper, isRemoveOrRecategorize = false) { + const processed = annotation.entry.manualChanges.at(-1)?.processed; + if (!processed) { + const autoAnalysisDisabled = this._state.file().excludedFromAutomaticAnalysis; + const addedLocallyWhileDisabled = annotation.manual; + if (autoAnalysisDisabled) { + return addedLocallyWhileDisabled; + } + return isRemoveOrRecategorize && addedLocallyWhileDisabled; + } + return false; + } }