From 2377fbff55ce620ff10e5a393dc6912094343ea4 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Sat, 5 Oct 2024 22:55:28 +0300 Subject: [PATCH] RED-7340 - removed dictionary & false positive logic from rectangle annotation dialog --- ...rectangle-annotation-dialog.component.html | 41 +++--------- .../rectangle-annotation-dialog.component.ts | 66 +++---------------- .../file-preview-screen.component.ts | 4 +- .../services/manual-redaction.service.ts | 4 +- 4 files changed, 21 insertions(+), 94 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.html index 57cb3dbf3..deeeb9113 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.html @@ -1,6 +1,6 @@
-
+
-
- - - - - - {{ displayedDictionaryLabel }} - - {{ dictionary.label }} - - - -
- -
+
- - {{ option.label }} - + @for (option of legalOptions; track option) { + + {{ option.label }} + + }
-
+
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts index 7aaf1072c..4e565ff06 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/rectangle-annotation-dialog/rectangle-annotation-dialog.component.ts @@ -7,13 +7,11 @@ import { IconButtonComponent, IqserDenyDirective, IqserDialogComponent, - IqserPermissionsService, Toaster, } from '@iqser/common-ui'; import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry.wrapper'; -import { Dictionary, Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain'; +import { Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; -import { DictionaryService } from '@services/entity-services/dictionary.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; import { Roles } from '@users/roles'; import { firstValueFrom } from 'rxjs'; @@ -39,7 +37,6 @@ interface RectangleDialogData { } export interface RectangleDialogResult { annotation: IManualRedactionEntry; - dictionary: Dictionary; } export const NON_READABLE_CONTENT = 'non-readable content'; @@ -74,30 +71,19 @@ export class RectangleAnnotationDialog readonly #dossier: Dossier; protected readonly roles = Roles; protected readonly options: DetailsRadioOption[]; - protected isDictionaryRequest: boolean; - protected isFalsePositiveRequest: boolean; - protected manualRedactionTypeExists = true; - protected possibleDictionaries: Dictionary[] = []; protected legalOptions: LegalBasisOption[] = []; + readonly form: UntypedFormGroup; constructor( - private readonly iqserPermissionsService: IqserPermissionsService, - private readonly _justificationsService: JustificationsService, - private readonly _manualRedactionService: ManualRedactionService, private readonly activeDossiersService: ActiveDossiersService, - private readonly _dictionaryService: DictionaryService, + private readonly _justificationsService: JustificationsService, private readonly _formBuilder: FormBuilder, private readonly _toaster: Toaster, ) { super(); this.#dossier = activeDossiersService.find(this.data.dossierId); - this.isFalsePositiveRequest = this.data.manualRedactionEntryWrapper.type === 'FALSE_POSITIVE'; - this.isDictionaryRequest = this.data.manualRedactionEntryWrapper.type === 'DICTIONARY' || this.isFalsePositiveRequest; - - this.manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); - this.options = getRectangleRedactOptions(); this.form = this.#getForm(); @@ -112,27 +98,7 @@ export class RectangleAnnotationDialog } } - get title() { - return this._manualRedactionService.getTitle(this.data.manualRedactionEntryWrapper.type); - } - - get displayedDictionaryLabel() { - const dictType = this.form.get('dictionary').value; - if (dictType) { - return this.possibleDictionaries.find(d => d.type === dictType).label; - } - return null; - } - - get disabled() { - return this.form.invalid; - } - async ngOnInit() { - this.possibleDictionaries = this.isDictionaryRequest - ? this._dictionaryService.getDictionariesOptions(this.#dossier.dossierTemplateId) - : this._dictionaryService.getRedactionTypes(this.#dossier.dossierTemplateId); - const data = await firstValueFrom(this._justificationsService.getForDossierTemplate(this.#dossier.dossierTemplateId)); this.legalOptions = data.map(lbm => ({ legalBasis: lbm.reason, @@ -148,13 +114,13 @@ export class RectangleAnnotationDialog save() { this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry); try { - const annotation = + const annotation = ( this.form.get('option').value.value === RectangleRedactOptions.MULTIPLE_PAGES - ? getMultiplePagesRectangle(this.#multiplePagesRectangleData).manualRedactionEntry - : this.data.manualRedactionEntryWrapper; + ? getMultiplePagesRectangle(this.#multiplePagesRectangleData) + : this.data.manualRedactionEntryWrapper + ).manualRedactionEntry; super.close({ annotation, - dictionary: this.possibleDictionaries.find(d => d.type === this.form.get('dictionary').value), }); } catch (e) { this._toaster.error(_('manual-annotation.dialog.error')); @@ -173,10 +139,7 @@ export class RectangleAnnotationDialog return this._formBuilder.group({ selectedText: this.data?.manualRedactionEntryWrapper?.manualRedactionEntry?.value, section: [null], - reason: this.isDictionaryRequest ? [null] : [null, Validators.required], - dictionary: this.isDictionaryRequest - ? [this.isFalsePositiveRequest ? 'false_positive' : null, Validators.required] - : [this.manualRedactionTypeExists ? SuperTypes.ManualRedaction : null, Validators.required], + reason: [null, Validators.required], comment: [null], classification: [NON_READABLE_CONTENT], option: [this.#getOption(SystemDefaults.RECTANGLE_REDACT_DEFAULT), validatePageRange()], @@ -185,22 +148,13 @@ export class RectangleAnnotationDialog #enhanceManualRedaction(addRedactionRequest: IAddRedactionRequest) { const legalOption: LegalBasisOption = this.form.get('reason').value; - addRedactionRequest.type = this.form.get('dictionary').value; + addRedactionRequest.type = SuperTypes.ManualRedaction; if (legalOption) { addRedactionRequest.reason = legalOption.description; addRedactionRequest.legalBasis = legalOption.legalBasis; } - if (this.iqserPermissionsService.has(Roles.getRss)) { - const selectedType = this.possibleDictionaries.find(d => d.type === addRedactionRequest.type); - addRedactionRequest.addToDictionary = selectedType.hasDictionary; - } else { - addRedactionRequest.addToDictionary = this.isDictionaryRequest && addRedactionRequest.type !== 'dossier_redaction'; - } - - if (!addRedactionRequest.reason) { - addRedactionRequest.reason = 'Dictionary Request'; - } + addRedactionRequest.addToDictionary = false; const commentValue = this.form.get('comment').value; addRedactionRequest.comment = commentValue ? { text: commentValue } : null; addRedactionRequest.section = this.form.get('section').value; diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index e51db9282..512f783bd 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -324,9 +324,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni this._annotationManager.delete([selectedAnnotations[0].Id]); } - const add$ = this._manualRedactionService.addAnnotation([result.annotation], this.dossierId, this.fileId, { - dictionaryLabel: result.dictionary?.label, - }); + const add$ = this._manualRedactionService.addAnnotation([result.annotation], this.dossierId, this.fileId); const addAndReload$ = add$.pipe(switchMap(() => this._filesService.reload(this.dossierId, file))); return firstValueFrom(addAndReload$.pipe(catchError(() => of(undefined)))); diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 675ad5407..e8017d6df 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -97,7 +97,7 @@ export class ManualRedactionService extends GenericService { : this.#showToast(options?.hint ? 'force-hint' : 'add'); const canAddRedaction = this._iqserPermissionsService.has(Roles.redactions.write); if (canAddRedaction) { - return this.add(requests, dossierId, fileId, options.bulkLocal).pipe(toast); + return this.add(requests, dossierId, fileId, options?.bulkLocal).pipe(toast); } return of(undefined); @@ -139,7 +139,7 @@ export class ManualRedactionService extends GenericService { } add(body: List, dossierId: string, fileId: string, bulkLocal = false) { - bulkLocal = bulkLocal || !!body[0].pageNumbers.length; + bulkLocal = bulkLocal || !!body[0].pageNumbers?.length; const bulkPath = bulkLocal ? this.#bulkLocal : this.#bulkRedaction; return this._post(bulkLocal ? body[0] : body, `${bulkPath}/add/${dossierId}/${fileId}`).pipe(this.#log('Add', body));