RED-10132: save comment value for bulkLocal as well.

This commit is contained in:
Nicoleta Panaghiu 2024-10-14 13:21:49 +03:00
parent bf7fab3600
commit 16a8d91815
10 changed files with 43 additions and 26 deletions

View File

@ -105,14 +105,6 @@ export class EditRedactionDialogComponent
super(); super();
} }
extraOptionChanged(option: DetailsRadioOption<EditRedactionOption | RectangleRedactOption>): void {
if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) {
setTimeout(() => {
this.form.get('option')?.updateValueAndValidity();
}, 0);
}
}
get displayedDictionaryLabel() { get displayedDictionaryLabel() {
const selectedDictionaryType = this.form.controls.type.value; const selectedDictionaryType = this.form.controls.type.value;
if (selectedDictionaryType) { if (selectedDictionaryType) {
@ -164,6 +156,14 @@ export class EditRedactionDialogComponent
return this.annotations.every(annotation => annotation.type === this.annotations[0].type); return this.annotations.every(annotation => annotation.type === this.annotations[0].type);
} }
extraOptionChanged(option: DetailsRadioOption<EditRedactionOption | RectangleRedactOption>): void {
if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) {
setTimeout(() => {
this.form.get('option')?.updateValueAndValidity();
}, 0);
}
}
async ngOnInit() { async ngOnInit() {
this.#setTypes(); this.#setTypes();
const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId)); const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId));

View File

@ -77,7 +77,7 @@ export class RectangleAnnotationDialog
private readonly _toaster: Toaster, private readonly _toaster: Toaster,
) { ) {
super(); super();
this.#dossier = activeDossiersService.find(this.data.dossierId); this.#dossier = this.activeDossiersService.find(this.data.dossierId);
this.options = getRectangleRedactOptions(); this.options = getRectangleRedactOptions();
@ -85,6 +85,10 @@ export class RectangleAnnotationDialog
this.initialFormValue = this.form.getRawValue(); this.initialFormValue = this.form.getRawValue();
} }
get #isMultiplePages() {
return this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES;
}
extraOptionChanged(option: DetailsRadioOption<RectangleRedactOption>): void { extraOptionChanged(option: DetailsRadioOption<RectangleRedactOption>): void {
if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) { if (option.value === RectangleRedactOptions.MULTIPLE_PAGES) {
setTimeout(() => { setTimeout(() => {
@ -109,11 +113,8 @@ export class RectangleAnnotationDialog
save() { save() {
this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
try { try {
const annotation = ( const annotation = (this.#isMultiplePages ? this.#multiplePagesRectangle : this.data.manualRedactionEntryWrapper)
this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES .manualRedactionEntry;
? this.#multiplePagesRectangle
: this.data.manualRedactionEntryWrapper
).manualRedactionEntry;
super.close({ super.close({
annotation, annotation,
}); });
@ -143,7 +144,7 @@ export class RectangleAnnotationDialog
addRedactionRequest.addToDictionary = false; addRedactionRequest.addToDictionary = false;
const commentValue = this.form.get('comment').value; const commentValue = this.form.get('comment').value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null; addRedactionRequest.comment = commentValue ? (this.#isMultiplePages ? commentValue : { text: commentValue }) : null;
addRedactionRequest.section = this.form.get('section').value; addRedactionRequest.section = this.form.get('section').value;
addRedactionRequest.value = this.form.get('classification').value; addRedactionRequest.value = this.form.get('classification').value;
} }

View File

@ -102,6 +102,10 @@ export class RedactRecommendationDialogComponent
this.form.controls.option.setValue(this.options[0]); this.form.controls.option.setValue(this.options[0]);
} }
get isBulkLocal(): boolean {
return this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT;
}
get displayedDictionaryLabel() { get displayedDictionaryLabel() {
const dictType = this.form.controls.dictionary.value; const dictType = this.form.controls.dictionary.value;
if (dictType) { if (dictType) {
@ -153,7 +157,7 @@ export class RedactRecommendationDialogComponent
this.close({ this.close({
redaction, redaction,
isMulti: this.isMulti, isMulti: this.isMulti,
bulkLocal: this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT, bulkLocal: this.isBulkLocal,
}); });
} }
@ -181,7 +185,7 @@ export class RedactRecommendationDialogComponent
} }
const commentValue = this.form.controls.comment.value; const commentValue = this.form.controls.comment.value;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null; addRedactionRequest.comment = commentValue ? (this.isBulkLocal ? commentValue : { text: commentValue }) : null;
addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers; addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers;
return addRedactionRequest; return addRedactionRequest;
} }

View File

@ -10,7 +10,7 @@ import { DetailsRadioOption } from '@common-ui/inputs/details-radio/details-radi
import { DetailsRadioComponent } from '@common-ui/inputs/details-radio/details-radio.component'; import { DetailsRadioComponent } from '@common-ui/inputs/details-radio/details-radio.component';
import { CircleButtonComponent, HasScrollbarDirective, IconButtonComponent, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; import { CircleButtonComponent, HasScrollbarDirective, IconButtonComponent, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui';
import { TranslateModule } from '@ngx-translate/core'; import { TranslateModule } from '@ngx-translate/core';
import { Dictionary, IAddRedactionRequest, SuperTypes } from '@red/domain'; import { Dictionary, SuperTypes } from '@red/domain';
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
import { DictionaryService } from '@services/entity-services/dictionary.service'; import { DictionaryService } from '@services/entity-services/dictionary.service';
import { JustificationsService } from '@services/entity-services/justifications.service'; import { JustificationsService } from '@services/entity-services/justifications.service';
@ -116,6 +116,10 @@ export class RedactTextDialogComponent
); );
} }
get isBulkLocal() {
return this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT;
}
get isSystemDefault(): boolean { get isSystemDefault(): boolean {
return this._userPreferences.getAddRedactionDefaultOption() === SystemDefaultOption.SYSTEM_DEFAULT; return this._userPreferences.getAddRedactionDefaultOption() === SystemDefaultOption.SYSTEM_DEFAULT;
} }
@ -182,7 +186,7 @@ export class RedactTextDialogComponent
this.close({ this.close({
redaction, redaction,
dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value), dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value),
bulkLocal: this.form.controls.option.value.value === ResizeOptions.IN_DOCUMENT, bulkLocal: this.isBulkLocal,
}); });
} }
@ -259,6 +263,7 @@ export class RedactTextDialogComponent
comment: this.form.controls.comment.value, comment: this.form.controls.comment.value,
isApprover: this.data.isApprover, isApprover: this.data.isApprover,
applyToAllDossiers: this.#applyToAllDossiers, applyToAllDossiers: this.#applyToAllDossiers,
bulkLocal: this.isBulkLocal,
}; };
} }
} }

View File

@ -26,7 +26,6 @@ import {
} from '../../components/selected-annotations-table/selected-annotations-table.component'; } from '../../components/selected-annotations-table/selected-annotations-table.component';
import { getRectangleRedactOptions, getRemoveRedactionOptions } from '../../utils/dialog-options'; import { getRectangleRedactOptions, getRemoveRedactionOptions } from '../../utils/dialog-options';
import { import {
EditRedactionOption,
RectangleRedactOption, RectangleRedactOption,
RectangleRedactOptions, RectangleRedactOptions,
RemoveRedactionData, RemoveRedactionData,
@ -35,6 +34,7 @@ import {
RemoveRedactionResult, RemoveRedactionResult,
ResizeOptions, ResizeOptions,
} from '../../utils/dialog-types'; } from '../../utils/dialog-types';
import { isJustOne } from '@common-ui/utils';
import { validatePageRange } from '../../utils/form-validators'; import { validatePageRange } from '../../utils/form-validators';
import { parseRectanglePosition, parseSelectedPageNumbers } from '../../utils/enhance-manual-redaction-request.utils'; import { parseRectanglePosition, parseSelectedPageNumbers } from '../../utils/enhance-manual-redaction-request.utils';
@ -157,7 +157,7 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
} }
get isBulk() { get isBulk() {
return this.data.redactions.length > 1; return !isJustOne(this.data.redactions);
} }
get redactedTextsAreaHeight() { get redactedTextsAreaHeight() {

View File

@ -51,7 +51,6 @@ import { FilePreviewStateService } from './file-preview-state.service';
import { ManualRedactionService } from './manual-redaction.service'; import { ManualRedactionService } from './manual-redaction.service';
import { SkippedService } from './skipped.service'; import { SkippedService } from './skipped.service';
import { NON_READABLE_CONTENT } from '../dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component'; import { NON_READABLE_CONTENT } from '../dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component';
import { result } from 'lodash-es';
@Injectable() @Injectable()
export class AnnotationActionsService { export class AnnotationActionsService {
@ -86,7 +85,7 @@ export class AnnotationActionsService {
const { dossierId, fileId } = this._state; const { dossierId, fileId } = this._state;
const data = { dossier: this._state.dossier(), annotations, hint }; const data = { dossier: this._state.dossier(), annotations, hint };
this._dialogService.openDialog('forceAnnotation', data, (request: ILegalBasisChangeRequest) => { this._dialogService.openDialog('forceAnnotation', data, (request: ILegalBasisChangeRequest) => {
let obs$; let obs$: Observable<unknown>;
if (request.option === ForceAnnotationOptions.ONLY_HERE) { if (request.option === ForceAnnotationOptions.ONLY_HERE) {
obs$ = this._manualRedactionService.bulkForce( obs$ = this._manualRedactionService.bulkForce(
annotations.map(a => ({ ...request, annotationId: a.id })), annotations.map(a => ({ ...request, annotationId: a.id })),
@ -158,6 +157,7 @@ export class AnnotationActionsService {
rectangle: annotations[0].AREA, rectangle: annotations[0].AREA,
pageNumbers: result.pageNumbers, pageNumbers: result.pageNumbers,
position: result.position, position: result.position,
comment: result.comment,
}; };
} }
@ -487,7 +487,9 @@ export class AnnotationActionsService {
for (let i = 0; i < splitNumber; i++) { for (let i = 0; i < splitNumber; i++) {
splitRequests.push(requests.slice(i * maximumNumberEntries, (i + 1) * maximumNumberEntries)); splitRequests.push(requests.slice(i * maximumNumberEntries, (i + 1) * maximumNumberEntries));
} }
splitRequests.push(requests.slice(splitNumber * maximumNumberEntries, splitNumber * maximumNumberEntries + remainder)); if (remainder) {
splitRequests.push(requests.slice(splitNumber * maximumNumberEntries, splitNumber * maximumNumberEntries + remainder));
}
const promises = []; const promises = [];
for (const split of splitRequests) { for (const split of splitRequests) {
@ -601,12 +603,14 @@ export class AnnotationActionsService {
originTypes: [redaction.entry.type], originTypes: [redaction.entry.type],
pageNumbers: dialogResult.pageNumbers, pageNumbers: dialogResult.pageNumbers,
position: dialogResult.position, position: dialogResult.position,
comment: dialogResult.comment,
}; };
} }
return { return {
value: redaction.value, value: redaction.value,
rectangle: false, rectangle: false,
comment: dialogResult.comment,
}; };
} }

View File

@ -12,6 +12,7 @@ export interface EnhanceRequestData {
readonly comment: string; readonly comment: string;
readonly isApprover: boolean; readonly isApprover: boolean;
readonly applyToAllDossiers: boolean; readonly applyToAllDossiers: boolean;
readonly bulkLocal: boolean;
} }
interface MultiplePagesRectangleData { interface MultiplePagesRectangleData {
@ -43,7 +44,7 @@ export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedaction
addRedactionRequest.reason = 'Dictionary Request'; addRedactionRequest.reason = 'Dictionary Request';
} }
const commentValue = data.comment; const commentValue = data.comment;
addRedactionRequest.comment = commentValue ? { text: commentValue } : null; addRedactionRequest.comment = commentValue ? (data.bulkLocal ? commentValue : { text: commentValue }) : null;
addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers; addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers;
}; };

View File

@ -5,7 +5,7 @@ import { DictionaryEntryType } from './dictionary-entry-types';
export interface IAddRedactionRequest { export interface IAddRedactionRequest {
addToDictionary?: boolean; addToDictionary?: boolean;
dictionaryEntryType?: DictionaryEntryType; dictionaryEntryType?: DictionaryEntryType;
comment?: { text: string }; comment?: { text: string } | string;
legalBasis?: string; legalBasis?: string;
positions?: List<IRectangle>; positions?: List<IRectangle>;
reason?: string; reason?: string;

View File

@ -19,4 +19,5 @@ export interface IBulkRecategorizationRequest {
readonly rectangle: boolean; readonly rectangle: boolean;
readonly position?: IEntityLogEntryPosition; readonly position?: IEntityLogEntryPosition;
readonly pageNumbers?: number[]; readonly pageNumbers?: number[];
readonly comment?: string;
} }

View File

@ -16,4 +16,5 @@ export interface IBulkLocalRemoveRequest {
originTypes?: string[]; originTypes?: string[];
originLegalBases?: string[]; originLegalBases?: string[];
pageNumbers?: number[]; pageNumbers?: number[];
comment?: string;
} }