RED-7345 - added bulk local remove logic for "remove redaction" dialog

This commit is contained in:
Valentin Mihai 2024-09-23 17:23:15 +03:00
parent f52a378280
commit 0be67a8589
6 changed files with 61 additions and 29 deletions

View File

@ -32,6 +32,8 @@ export interface LegalBasisOption {
description?: string;
}
export const NON_READABLE_CONTENT = 'non-readable content';
@Component({
templateUrl: './manual-annotation-dialog.component.html',
styleUrls: ['./manual-annotation-dialog.component.scss'],
@ -196,7 +198,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme
? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required]
: [this.manualRedactionTypeExists ? SuperTypes.ManualRedaction : null, Validators.required],
comment: [null],
classification: ['non-readable content'],
classification: [NON_READABLE_CONTENT],
multiplePages: '',
});
}

View File

@ -134,19 +134,6 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
super();
}
get helpButtonKey() {
if (this.hint) {
return DialogHelpModeKeys.HINT_REMOVE;
}
if (this.recommendation) {
return DialogHelpModeKeys.RECOMMENDATION_REMOVE;
}
if (this.skipped) {
return DialogHelpModeKeys.SKIPPED_REMOVE;
}
return DialogHelpModeKeys.REDACTION_REMOVE;
}
get hasFalsePositiveOption() {
return !!this.options.find(option => option.value === RemoveRedactionOptions.FALSE_POSITIVE);
}

View File

@ -8,9 +8,11 @@ import { Core } from '@pdftron/webviewer';
import {
DictionaryEntryTypes,
EarmarkOperation,
type IBulkLocalRemoveRequest,
ILegalBasisChangeRequest,
IRecategorizationRequest,
IRectangle,
type IRemoveRedactionRequest,
IResizeRequest,
} from '@red/domain';
import { CommentsApiService } from '@services/comments-api.service';
@ -45,6 +47,7 @@ import { FilePreviewDialogService } from './file-preview-dialog.service';
import { FilePreviewStateService } from './file-preview-state.service';
import { ManualRedactionService } from './manual-redaction.service';
import { SkippedService } from './skipped.service';
import { NON_READABLE_CONTENT } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
@Injectable()
export class AnnotationActionsService {
@ -456,13 +459,7 @@ export class AnnotationActionsService {
#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,
value: redaction.value,
comment: dialogResult.comment,
removeFromDictionary,
removeFromAllDossiers: !!dialogResult.option.extraOption?.checked || !!dialogResult.applyToAllDossiers,
}));
const body = this.#getRemoveRedactionBody(redactions, dialogResult);
// todo: might not be correct, probably shouldn't get to this point if they are not all the same
const isHint = redactions.every(r => r.isHint);
const { dossierId, fileId } = this._state;
@ -545,4 +542,35 @@ export class AnnotationActionsService {
}
return false;
}
#getRemoveRedactionBody(
redactions: AnnotationWrapper[],
dialogResult: RemoveRedactionResult,
): List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest {
if (dialogResult.bulkLocal) {
const redaction = redactions[0];
if (redaction.value === NON_READABLE_CONTENT) {
return {
value: redaction.value,
rectangle: true,
position: redaction.entry.positions[0],
originTypes: [redaction.entry.type],
pageNumbers: [redaction.pageNumber],
};
}
return {
value: redaction.value,
rectangle: false,
};
}
return redactions.map(redaction => ({
annotationId: redaction.id,
value: redaction.value,
comment: dialogResult.comment,
removeFromDictionary: dialogResult.option.value === RemoveRedactionOptions.IN_DOSSIER,
removeFromAllDossiers: !!dialogResult.option.extraOption?.checked || !!dialogResult.applyToAllDossiers,
}));
}
}

View File

@ -8,6 +8,7 @@ import { type ManualRedactionEntryType } from '@models/file/manual-redaction-ent
import type {
DictionaryActions,
IAddRedactionRequest,
IBulkLocalRemoveRequest,
ILegalBasisChangeRequest,
IManualAddResponse,
IRecategorizationRequest,
@ -109,7 +110,7 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
}
removeRedaction(
body: List<IRemoveRedactionRequest>,
body: List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest,
dossierId: string,
fileId: string,
removeFromDictionary = false,
@ -151,13 +152,15 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
return super.delete(annotationIds, url).pipe(this.#log('Undo', annotationIds));
}
remove(body: List<IRemoveRedactionRequest>, dossierId: string, fileId: string, includeUnprocessed = false, bulkLocal = false) {
remove(
body: List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest,
dossierId: string,
fileId: string,
includeUnprocessed = false,
bulkLocal = false,
) {
const bulkPath = bulkLocal ? this.#bulkLocal : this.#bulkRedaction;
const newBody = {
value: body[0].value,
rectangle: false,
};
return this._post(newBody, `${bulkPath}/remove/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe(
return this._post(body, `${bulkPath}/remove/${dossierId}/${fileId}?includeUnprocessed=${includeUnprocessed}`).pipe(
this.#log('Remove', body),
);
}

View File

@ -151,7 +151,6 @@ export const getRemoveRedactionOptions = (
applyToAllDossiers: boolean,
isDocumine: boolean = false,
): DetailsRadioOption<RemoveRedactionOption>[] => {
console.log('TEST');
const translations = isDocumine ? removeAnnotationTranslations : removeRedactionTranslations;
const { permissions, redactions, isApprover, falsePositiveContext } = data;
const isBulk = redactions.length > 1;

View File

@ -1,6 +1,19 @@
import { IEntityLogEntryPosition } from './entity-log-entry';
export interface IRemoveRedactionRequest {
annotationId?: string;
comment?: string;
removeFromDictionary?: boolean;
removeFromAllDossiers?: boolean;
value?: string;
}
export interface IBulkLocalRemoveRequest {
rectangle: boolean;
value: string;
caseSensitive?: boolean;
position?: IEntityLogEntryPosition;
originTypes?: string[];
originLegalBases?: string[];
pageNumbers?: number[];
}