RED-10373 - remove redaction dialog updates to be able to create multiple bulk requests for rectangle annotations

This commit is contained in:
Valentin Mihai 2024-11-12 18:45:44 +02:00
parent 0d639b96a2
commit d673348def
7 changed files with 41 additions and 28 deletions

View File

@ -214,11 +214,7 @@ export class EditRedactionDialogComponent
const value = this.form.value; const value = this.form.value;
const initialReason: LegalBasisOption = this.initialFormValue.reason; const initialReason: LegalBasisOption = this.initialFormValue.reason;
const initialLegalBasis = initialReason?.legalBasis ?? ''; const initialLegalBasis = initialReason?.legalBasis ?? '';
const pageNumbers = parseSelectedPageNumbers( const pageNumbers = parseSelectedPageNumbers(this.form.get('option').value?.additionalInput?.value, this.data.file);
this.form.get('option').value?.additionalInput?.value,
this.data.file,
this.data.annotations[0],
);
const position = parseRectanglePosition(this.annotations[0]); const position = parseRectanglePosition(this.annotations[0]);
this.close({ this.close({

View File

@ -103,7 +103,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
: this.optionByType[this.annotationsType].main; : this.optionByType[this.annotationsType].main;
readonly extraOptionPreference = stringToBoolean(this.optionByType[this.annotationsType].extra); readonly extraOptionPreference = stringToBoolean(this.optionByType[this.annotationsType].extra);
readonly options: DetailsRadioOption<RectangleRedactOption | RemoveRedactionOption>[] = this.#allRectangles readonly options: DetailsRadioOption<RectangleRedactOption | RemoveRedactionOption>[] = this.#allRectangles
? getRectangleRedactOptions('remove') ? getRectangleRedactOptions('remove', this.data)
: getRemoveRedactionOptions( : getRemoveRedactionOptions(
this.data, this.data,
this.isSystemDefault || this.isExtraOptionSystemDefault ? this.#applyToAllDossiers : this.extraOptionPreference, this.isSystemDefault || this.isExtraOptionSystemDefault ? this.#applyToAllDossiers : this.extraOptionPreference,
@ -187,14 +187,17 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
save(): void { save(): void {
const optionValue = this.form.controls.option?.value?.value; const optionValue = this.form.controls.option?.value?.value;
const optionInputValue = this.form.controls.option?.value?.additionalInput?.value; const optionInputValue = this.form.controls.option?.value?.additionalInput?.value;
const pageNumbers = parseSelectedPageNumbers(optionInputValue, this.data.file, this.data.redactions[0]); const pageNumbers = parseSelectedPageNumbers(optionInputValue, this.data.file);
const position = parseRectanglePosition(this.data.redactions[0]); const positions = [];
for (const redaction of this.data.redactions) {
positions.push(parseRectanglePosition(redaction));
}
this.close({ this.close({
...this.form.getRawValue(), ...this.form.getRawValue(),
bulkLocal: optionValue === ResizeOptions.IN_DOCUMENT || optionValue === RectangleRedactOptions.MULTIPLE_PAGES, bulkLocal: optionValue === ResizeOptions.IN_DOCUMENT || optionValue === RectangleRedactOptions.MULTIPLE_PAGES,
pageNumbers, pageNumbers,
position, positions,
}); });
} }

View File

@ -479,6 +479,7 @@ export class AnnotationActionsService {
const isHint = redactions.every(r => r.isHint); const isHint = redactions.every(r => r.isHint);
const { dossierId, fileId } = this._state; const { dossierId, fileId } = this._state;
const maximumNumberEntries = 100; const maximumNumberEntries = 100;
const bulkLocal = dialogResult.bulkLocal || !!dialogResult.pageNumbers.length;
if (removeFromDictionary && (body as List<IRemoveRedactionRequest>).length > maximumNumberEntries) { if (removeFromDictionary && (body as List<IRemoveRedactionRequest>).length > maximumNumberEntries) {
const requests = body as List<IRemoveRedactionRequest>; const requests = body as List<IRemoveRedactionRequest>;
const splitNumber = Math.floor(requests.length / maximumNumberEntries); const splitNumber = Math.floor(requests.length / maximumNumberEntries);
@ -493,15 +494,28 @@ export class AnnotationActionsService {
const promises = []; const promises = [];
for (const split of splitRequests) { for (const split of splitRequests) {
promises.push(
firstValueFrom(
this._manualRedactionService.removeRedaction(split, dossierId, fileId, removeFromDictionary, isHint, bulkLocal),
),
);
}
Promise.all(promises).finally(() => this._fileDataService.annotationsChanged());
return;
}
if (redactions[0].AREA && bulkLocal) {
const promises = [];
for (const request of body) {
promises.push( promises.push(
firstValueFrom( firstValueFrom(
this._manualRedactionService.removeRedaction( this._manualRedactionService.removeRedaction(
split, request as IBulkLocalRemoveRequest,
dossierId, dossierId,
fileId, fileId,
removeFromDictionary, removeFromDictionary,
isHint, isHint,
dialogResult.bulkLocal, bulkLocal,
), ),
), ),
); );
@ -509,15 +523,9 @@ export class AnnotationActionsService {
Promise.all(promises).finally(() => this._fileDataService.annotationsChanged()); Promise.all(promises).finally(() => this._fileDataService.annotationsChanged());
return; return;
} }
this.#processObsAndEmit( this.#processObsAndEmit(
this._manualRedactionService.removeRedaction( this._manualRedactionService.removeRedaction(body, dossierId, fileId, removeFromDictionary, isHint, bulkLocal),
body,
dossierId,
fileId,
removeFromDictionary,
isHint,
dialogResult.bulkLocal || !!dialogResult.pageNumbers.length,
),
).then(); ).then();
} }
@ -577,16 +585,16 @@ export class AnnotationActionsService {
#getRemoveRedactionBody( #getRemoveRedactionBody(
redactions: AnnotationWrapper[], redactions: AnnotationWrapper[],
dialogResult: RemoveRedactionResult, dialogResult: RemoveRedactionResult,
): List<IRemoveRedactionRequest> | IBulkLocalRemoveRequest { ): List<IRemoveRedactionRequest | IBulkLocalRemoveRequest> {
if (dialogResult.bulkLocal || !!dialogResult.pageNumbers.length) { if (dialogResult.bulkLocal || !!dialogResult.pageNumbers.length) {
const redaction = redactions[0]; const redaction = redactions[0];
return { return dialogResult.positions.map(position => ({
value: redaction.value, value: redaction.value,
rectangle: redaction.AREA, rectangle: redaction.AREA,
pageNumbers: dialogResult.pageNumbers, pageNumbers: dialogResult.pageNumbers,
position: dialogResult.position, position: position,
comment: dialogResult.comment, comment: dialogResult.comment,
}; }));
} }
return redactions.map(redaction => ({ return redactions.map(redaction => ({

View File

@ -102,19 +102,25 @@ export const getRedactOrHintOptions = (
return options; return options;
}; };
export const getRectangleRedactOptions = (action: 'add' | 'edit' | 'remove' = 'add'): DetailsRadioOption<RectangleRedactOption>[] => { export const getRectangleRedactOptions = (
action: 'add' | 'edit' | 'remove' = 'add',
data?: RemoveRedactionData,
): DetailsRadioOption<RectangleRedactOption>[] => {
const translations = const translations =
action === 'add' ? rectangleRedactTranslations : action === 'edit' ? editRectangleTranslations : removeRectangleTranslations; action === 'add' ? rectangleRedactTranslations : action === 'edit' ? editRectangleTranslations : removeRectangleTranslations;
const redactions = data?.redactions ?? [];
return [ return [
{ {
label: translations.onlyThisPage.label, label: translations.onlyThisPage.label,
description: translations.onlyThisPage.description, description: translations.onlyThisPage.description,
descriptionParams: { length: redactions.length },
icon: PIN_ICON, icon: PIN_ICON,
value: RectangleRedactOptions.ONLY_THIS_PAGE, value: RectangleRedactOptions.ONLY_THIS_PAGE,
}, },
{ {
label: translations.multiplePages.label, label: translations.multiplePages.label,
description: translations.multiplePages.description, description: translations.multiplePages.description,
descriptionParams: { length: redactions.length },
icon: DOCUMENT_ICON, icon: DOCUMENT_ICON,
value: RectangleRedactOptions.MULTIPLE_PAGES, value: RectangleRedactOptions.MULTIPLE_PAGES,
additionalInput: { additionalInput: {

View File

@ -168,7 +168,7 @@ export interface RemoveRedactionResult {
applyToAllDossiers?: boolean; applyToAllDossiers?: boolean;
bulkLocal?: boolean; bulkLocal?: boolean;
pageNumbers?: number[]; pageNumbers?: number[];
position: IEntityLogEntryPosition; positions: IEntityLogEntryPosition[];
} }
export type RemoveAnnotationResult = RemoveRedactionResult; export type RemoveAnnotationResult = RemoveRedactionResult;

View File

@ -49,7 +49,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction
addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers; addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers;
}; };
export const parseSelectedPageNumbers = (inputValue: string, file: File, annotation: AnnotationWrapper) => { export const parseSelectedPageNumbers = (inputValue: string, file: File) => {
if (!inputValue) { if (!inputValue) {
return []; return [];
} }

View File

@ -2188,14 +2188,14 @@
"content": { "content": {
"options": { "options": {
"multiple-pages": { "multiple-pages": {
"description": "Remove redaction on a range of pages", "description": "Remove {length, plural, one{redaction} other {redactions}} on a range of pages",
"extraOptionDescription": "Minus(-) for range and comma(,) for enumeration", "extraOptionDescription": "Minus(-) for range and comma(,) for enumeration",
"extraOptionLabel": "Pages", "extraOptionLabel": "Pages",
"extraOptionPlaceholder": "e.g. 1-20,22,32", "extraOptionPlaceholder": "e.g. 1-20,22,32",
"label": "Remove on multiple pages" "label": "Remove on multiple pages"
}, },
"only-this-page": { "only-this-page": {
"description": "Remove redaction only at this position in this document", "description": "Remove {length, plural, one{redaction} other {redactions}} only at this position in this document",
"label": "Remove only on this page" "label": "Remove only on this page"
} }
} }