WIP on VM/RED-7345
RED-7345 - adapted "force redaction" and "accept recommendation" dialogs to use new bulk-local api
This commit is contained in:
parent
1b9128a68f
commit
f52a378280
@ -145,6 +145,7 @@ export class ForceAnnotationDialogComponent extends BaseDialogComponent implemen
|
||||
|
||||
request.legalBasis = !this.isDocumine ? this.form.get('reason').value.legalBasis : DOCUMINE_LEGAL_BASIS;
|
||||
request.comment = this.form.get('comment').value;
|
||||
request.reason = this.form.get('reason').value.description;
|
||||
request.option = this.form.get('option').value.value;
|
||||
|
||||
return request;
|
||||
|
||||
@ -23,6 +23,7 @@ import { SystemDefaultOption, SystemDefaults } from '../../../account/utils/dial
|
||||
import { getRedactOrHintOptions } from '../../utils/dialog-options';
|
||||
import { RedactOrHintOption, RedactOrHintOptions, RedactTextData, RedactTextResult, ResizeOptions } from '../../utils/dialog-types';
|
||||
import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
import { enhanceManualRedactionRequest, EnhanceRequestData } from '../../utils/enhance-manual-redaction-request.utils';
|
||||
|
||||
const MAXIMUM_TEXT_AREA_WIDTH = 421;
|
||||
|
||||
@ -170,8 +171,8 @@ export class RedactTextDialogComponent
|
||||
}
|
||||
|
||||
save(): void {
|
||||
this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
|
||||
const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry;
|
||||
enhanceManualRedactionRequest(redaction, this.#enhanceRequestData);
|
||||
this.close({
|
||||
redaction,
|
||||
dictionary: this.dictionaries.find(d => d.type === this.form.controls.dictionary.value),
|
||||
@ -227,33 +228,6 @@ export class RedactTextDialogComponent
|
||||
}
|
||||
}
|
||||
|
||||
#enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) {
|
||||
addRedactionRequest.type = this.form.controls.dictionary.value;
|
||||
addRedactionRequest.section = null;
|
||||
addRedactionRequest.value = this.form.controls.selectedText.value;
|
||||
|
||||
const legalOption: LegalBasisOption = this.form.controls.reason.value;
|
||||
if (legalOption) {
|
||||
addRedactionRequest.reason = legalOption.description;
|
||||
addRedactionRequest.legalBasis = legalOption.legalBasis;
|
||||
}
|
||||
|
||||
const selectedType = this.dictionaries.find(d => d.type === addRedactionRequest.type);
|
||||
|
||||
if (selectedType) {
|
||||
addRedactionRequest.addToDictionary = selectedType.hasDictionary;
|
||||
} else {
|
||||
addRedactionRequest.addToDictionary = this.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction';
|
||||
}
|
||||
|
||||
if (!addRedactionRequest.reason) {
|
||||
addRedactionRequest.reason = 'Dictionary Request';
|
||||
}
|
||||
const commentValue = this.form.controls.comment.value;
|
||||
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
|
||||
addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers;
|
||||
}
|
||||
|
||||
#resetValues() {
|
||||
this.#applyToAllDossiers = this.applyToAll;
|
||||
this.options[2].extraOption.checked = this.#applyToAllDossiers;
|
||||
@ -268,4 +242,17 @@ export class RedactTextDialogComponent
|
||||
#getOption(option: RedactOrHintOption): DetailsRadioOption<RedactOrHintOption> {
|
||||
return this.options.find(o => o.value === option);
|
||||
}
|
||||
|
||||
get #enhanceRequestData(): EnhanceRequestData {
|
||||
return {
|
||||
type: this.form.controls.dictionary.value,
|
||||
selectedText: this.form.controls.selectedText.value,
|
||||
reason: this.form.controls.reason.value,
|
||||
dictionaries: this.dictionaries,
|
||||
dictionaryRequest: this.dictionaryRequest,
|
||||
comment: this.form.controls.comment.value,
|
||||
isApprover: this.data.isApprover,
|
||||
applyToAllDossiers: this.#applyToAllDossiers,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,8 +90,15 @@ export class AnnotationActionsService {
|
||||
annotations[0].isIgnoredHint,
|
||||
);
|
||||
} else {
|
||||
console.log('annotation: ', annotations[0]);
|
||||
obs$ = this._manualRedactionService.addAnnotation(annotations, dossierId, fileId, {
|
||||
const addAnnotationRequest = annotations.map(a => ({
|
||||
comment: { text: request.comment },
|
||||
legalBasis: request.legalBasis,
|
||||
reason: request.reason,
|
||||
positions: a.positions,
|
||||
type: a.type,
|
||||
value: a.value,
|
||||
}));
|
||||
obs$ = this._manualRedactionService.addAnnotation(addAnnotationRequest, dossierId, fileId, {
|
||||
hint,
|
||||
bulkLocal: true,
|
||||
});
|
||||
@ -210,7 +217,13 @@ export class AnnotationActionsService {
|
||||
this.cancelResize(recommendations[0]).then();
|
||||
}
|
||||
|
||||
const request$ = this._manualRedactionService.addRecommendation(recommendations, result.redaction, dossierId, fileId);
|
||||
const request$ = this._manualRedactionService.addRecommendation(
|
||||
recommendations,
|
||||
result.redaction,
|
||||
dossierId,
|
||||
fileId,
|
||||
result.bulkLocal,
|
||||
);
|
||||
return this.#processObsAndEmit(request$);
|
||||
}
|
||||
|
||||
|
||||
@ -49,7 +49,13 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
||||
super();
|
||||
}
|
||||
|
||||
addRecommendation(annotations: AnnotationWrapper[], redaction: IAddRedactionRequest, dossierId: string, fileId: string) {
|
||||
addRecommendation(
|
||||
annotations: AnnotationWrapper[],
|
||||
redaction: IAddRedactionRequest,
|
||||
dossierId: string,
|
||||
fileId: string,
|
||||
bulkLocal: boolean = false,
|
||||
) {
|
||||
const recommendations: List<IAddRedactionRequest> = annotations.map(annotation => ({
|
||||
addToDictionary: redaction.addToDictionary,
|
||||
addToAllDossiers: redaction.addToAllDossiers,
|
||||
@ -60,7 +66,7 @@ export class ManualRedactionService extends GenericService<IManualAddResponse> {
|
||||
type: redaction.type ?? annotation.type,
|
||||
comment: redaction.comment,
|
||||
}));
|
||||
return this.addAnnotation(recommendations, dossierId, fileId);
|
||||
return this.addAnnotation(recommendations, dossierId, fileId, { bulkLocal });
|
||||
}
|
||||
|
||||
recategorizeRedactions(
|
||||
|
||||
@ -224,7 +224,6 @@ export class PdfProxyService {
|
||||
const selectedQuads: Record<string, Quad[]> = this._pdf.documentViewer.getSelectedTextQuads();
|
||||
const text = this._documentViewer.selectedText;
|
||||
const manualRedactionEntry = this.#getManualRedaction(selectedQuads, text, true);
|
||||
console.log('manualRedactionEntry: ', manualRedactionEntry);
|
||||
this.redactTextRequested$.next({ manualRedactionEntry, type });
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
import { Dictionary, IAddRedactionRequest, SuperType } from '@red/domain';
|
||||
import { LegalBasisOption } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||
|
||||
export interface EnhanceRequestData {
|
||||
readonly type: SuperType | null;
|
||||
readonly selectedText: string;
|
||||
readonly reason: LegalBasisOption;
|
||||
readonly dictionaries: Dictionary[];
|
||||
readonly dictionaryRequest: boolean;
|
||||
readonly comment: string;
|
||||
readonly isApprover: boolean;
|
||||
readonly applyToAllDossiers: boolean;
|
||||
}
|
||||
|
||||
export const enhanceManualRedactionRequest = (addRedactionRequest: IAddRedactionRequest, data: EnhanceRequestData) => {
|
||||
addRedactionRequest.type = data.type;
|
||||
addRedactionRequest.section = null;
|
||||
addRedactionRequest.value = data.selectedText;
|
||||
|
||||
const legalOption: LegalBasisOption = data.reason;
|
||||
if (legalOption) {
|
||||
addRedactionRequest.reason = legalOption.description;
|
||||
addRedactionRequest.legalBasis = legalOption.legalBasis;
|
||||
}
|
||||
|
||||
const selectedType = data.dictionaries.find(d => d.type === addRedactionRequest.type);
|
||||
|
||||
if (selectedType) {
|
||||
addRedactionRequest.addToDictionary = selectedType.hasDictionary;
|
||||
} else {
|
||||
addRedactionRequest.addToDictionary = data.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction';
|
||||
}
|
||||
|
||||
if (!addRedactionRequest.reason) {
|
||||
addRedactionRequest.reason = 'Dictionary Request';
|
||||
}
|
||||
const commentValue = data.comment;
|
||||
addRedactionRequest.comment = commentValue ? { text: commentValue } : null;
|
||||
addRedactionRequest.addToAllDossiers = data.isApprover && data.dictionaryRequest && data.applyToAllDossiers;
|
||||
};
|
||||
@ -4,5 +4,6 @@ export interface ILegalBasisChangeRequest {
|
||||
annotationId?: string;
|
||||
comment?: string;
|
||||
legalBasis?: string;
|
||||
reason?: string;
|
||||
option?: ForceAnnotationOption;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user