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 initialReason: LegalBasisOption = this.initialFormValue.reason;
const initialLegalBasis = initialReason?.legalBasis ?? '';
const pageNumbers = parseSelectedPageNumbers(
this.form.get('option').value?.additionalInput?.value,
this.data.file,
this.data.annotations[0],
);
const pageNumbers = parseSelectedPageNumbers(this.form.get('option').value?.additionalInput?.value, this.data.file);
const position = parseRectanglePosition(this.annotations[0]);
this.close({

View File

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

View File

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

View File

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

View File

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

View File

@ -49,7 +49,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction
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) {
return [];
}

View File

@ -2188,14 +2188,14 @@
"content": {
"options": {
"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",
"extraOptionLabel": "Pages",
"extraOptionPlaceholder": "e.g. 1-20,22,32",
"label": "Remove on multiple pages"
},
"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"
}
}