From f0ae6b659fd92ee76fe57d760ad2ac0e2e71b272 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 19 Jun 2023 11:42:31 +0300 Subject: [PATCH] RED-6774 - updates for remove here, remove in dossier and set as false positive --- .../annotation-actions.component.html | 2 +- .../remove-redaction-dialog.component.ts | 13 +++-- .../remove-redaction-dialog.html | 1 - .../services/annotation-actions.service.ts | 52 +++++++++++++++---- 4 files changed, 50 insertions(+), 18 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html index cf088d9bf..fb06ed7b0 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.html @@ -179,7 +179,7 @@ ; } @Component({ @@ -28,20 +33,18 @@ export class RemoveRedactionDialogComponent extends BaseDialogComponent { readonly #translations = removeRedactionTranslations; constructor( - protected readonly _dialogRef: MatDialogRef, + protected readonly _dialogRef: MatDialogRef, @Inject(MAT_DIALOG_DATA) readonly data: RemoveRedactionData, ) { super(_dialogRef); - this.#redaction = data.redaction; - console.log('redaction: ', this.#redaction); this.options = this.#options(); this.form = this.#getForm(); this.initialFormValue = this.form.getRawValue(); } save(): void { - console.log('test'); + this._dialogRef.close(this.form.getRawValue()); } #getForm(): UntypedFormGroup { diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.html b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.html index 9ef3350bd..5cdedd715 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.html @@ -20,7 +20,6 @@
{ - const body = { - annotationId: redaction.id, - comment: result.comment, - }; - const { dossierId, fileId } = this._state; - this.#processObsAndEmit( - this._manualRedactionService.removeOrSuggestRemove([body], dossierId, fileId, true, redaction.isHint), - ).then(); + + this._dialogService.openDialog('removeRedaction', data, (result: RemoveRedactionResult) => { + if (result.option.value === RemoveRedactionOptions.FALSE_POSITIVE) { + this.#setAsFalsePositive(redaction, result.comment); + } else { + const removeFromDictionary = result.option.value === RemoveRedactionOptions.IN_DOSSIER; + this.#removeRedaction(redaction, result.comment, removeFromDictionary); + } }); } @@ -394,4 +394,34 @@ export class AnnotationActionsService { } return words; } + + #setAsFalsePositive(redaction: AnnotationWrapper, comment: string) { + const request = { + sourceId: redaction.id, + value: this._getFalsePositiveText(redaction), + type: redaction.type, + positions: redaction.positions, + addToDictionary: true, + reason: 'False Positive', + dictionaryEntryType: redaction.isRecommendation + ? DictionaryEntryTypes.FALSE_RECOMMENDATION + : DictionaryEntryTypes.FALSE_POSITIVE, + comment: comment ? { text: comment } : null, + }; + const { dossierId, fileId } = this._state; + + this.#processObsAndEmit(this._manualRedactionService.addAnnotation([request], dossierId, fileId)).then(); + } + + #removeRedaction(redaction: AnnotationWrapper, comment: string, removeFromDictionary: boolean) { + const body = { + annotationId: redaction.id, + comment: comment, + removeFromDictionary, + }; + const { dossierId, fileId } = this._state; + this.#processObsAndEmit( + this._manualRedactionService.removeOrSuggestRemove([body], dossierId, fileId, removeFromDictionary, redaction.isHint), + ).then(); + } }