From a7d5a6ec1311520ef8e02d3301520ef37cb914ea Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Mon, 3 Apr 2023 15:23:11 +0300 Subject: [PATCH] RED-6506: Added confirmation dialog for false positive action. --- .../false-positive-dialog.component.html | 31 ++++++++++++++++++ .../false-positive-dialog.component.scss | 0 .../false-positive-dialog.component.ts | 32 +++++++++++++++++++ .../file-preview/file-preview.module.ts | 2 ++ .../services/annotation-actions.service.ts | 32 +++++++++++-------- .../services/file-preview-dialog.service.ts | 7 +++- apps/red-ui/src/assets/i18n/redact/de.json | 11 +++++++ apps/red-ui/src/assets/i18n/redact/en.json | 11 +++++++ 8 files changed, 111 insertions(+), 15 deletions(-) create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.html create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.scss create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.ts diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.html new file mode 100644 index 000000000..4655e7d22 --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.html @@ -0,0 +1,31 @@ +
+
+
+ +
+
    +
  • +
+
+ + +
+
+ +
+ + +
+
+
+ + +
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.ts new file mode 100644 index 000000000..9b39d41b2 --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/false-positive-dialog/false-positive-dialog.component.ts @@ -0,0 +1,32 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { BaseDialogComponent } from '@iqser/common-ui'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; + +export interface FalsePositiveDialogInput { + text: string; + context: string; +} + +@Component({ + selector: 'redaction-false-positive-dialog', + templateUrl: './false-positive-dialog.component.html', + styleUrls: ['./false-positive-dialog.component.scss'], +}) +export class FalsePositiveDialogComponent extends BaseDialogComponent implements OnInit { + constructor( + protected readonly _dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) readonly data: FalsePositiveDialogInput[], + ) { + super(_dialogRef); + } + + ngOnInit() { + const controlsConfig = { comment: [null] }; + this.form = this._formBuilder.group(controlsConfig); + this.initialFormValue = this.form.getRawValue(); + } + + save(): void { + this._dialogRef.close(this.form.getRawValue()); + } +} diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts b/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts index 578db0e0e..0495a48c4 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts @@ -55,6 +55,7 @@ import { RssDialogComponent } from './dialogs/rss-dialog/rss-dialog.component'; import { ReadonlyBannerComponent } from './components/readonly-banner/readonly-banner.component'; import { SuggestionsService } from './services/suggestions.service'; import { PagesComponent } from './components/pages/pages.component'; +import { FalsePositiveDialogComponent } from './dialogs/false-positive-dialog/false-positive-dialog.component'; const routes: Routes = [ { @@ -78,6 +79,7 @@ const dialogs = [ DocumentInfoDialogComponent, ImportRedactionsDialogComponent, RssDialogComponent, + FalsePositiveDialogComponent, ]; const components = [ diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index 134622ea8..764417daf 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -251,21 +251,25 @@ export class AnnotationActionsService { markAsFalsePositive($event: MouseEvent, annotations: AnnotationWrapper[]) { $event?.stopPropagation(); + const data = annotations.map(annotation => ({ text: annotation.value, context: this._getFalsePositiveText(annotation) })); + this._dialogService.openDialog('falsePositive', null, data, (result: { comment: string }) => { + const requests: List = annotations.map(annotation => ({ + sourceId: annotation.id, + value: this._getFalsePositiveText(annotation), + type: annotation.type, + positions: annotation.positions, + addToDictionary: true, + reason: 'False Positive', + dictionaryEntryType: annotation.isRecommendation + ? DictionaryEntryTypes.FALSE_RECOMMENDATION + : DictionaryEntryTypes.FALSE_POSITIVE, + comment: result.comment ? { text: result.comment } : null, + })); + console.log(requests.map(req => req.value)); + const { dossierId, fileId } = this._state; - const requests: List = annotations.map(annotation => ({ - sourceId: annotation.id, - value: this._getFalsePositiveText(annotation), - type: annotation.type, - positions: annotation.positions, - addToDictionary: true, - reason: 'False Positive', - dictionaryEntryType: annotation.isRecommendation - ? DictionaryEntryTypes.FALSE_RECOMMENDATION - : DictionaryEntryTypes.FALSE_POSITIVE, - })); - const { dossierId, fileId } = this._state; - - this.#processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId)); + this.#processObsAndEmit(this._manualRedactionService.addAnnotation(requests, dossierId, fileId)); + }); } #generateRectangle(annotationWrapper: AnnotationWrapper) { diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts index 49a7df222..e8abdb76b 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts @@ -10,6 +10,7 @@ import { ConfirmationDialogComponent, DialogConfig, DialogService } from '@iqser import { ResizeAnnotationDialogComponent } from '../dialogs/resize-annotation-dialog/resize-annotation-dialog.component'; import { HighlightActionDialogComponent } from '../dialogs/highlight-action-dialog/highlight-action-dialog.component'; import { RssDialogComponent } from '../dialogs/rss-dialog/rss-dialog.component'; +import { FalsePositiveDialogComponent } from '../dialogs/false-positive-dialog/false-positive-dialog.component'; type DialogType = | 'confirm' @@ -21,7 +22,8 @@ type DialogType = | 'resizeAnnotation' | 'forceAnnotation' | 'manualAnnotation' - | 'highlightAction'; + | 'highlightAction' + | 'falsePositive'; @Injectable() export class FilePreviewDialogService extends DialogService { @@ -60,6 +62,9 @@ export class FilePreviewDialogService extends DialogService { component: RssDialogComponent, dialogConfig: { width: '90vw' }, }, + falsePositive: { + component: FalsePositiveDialogComponent, + }, }; constructor(protected readonly _dialog: MatDialog) { diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index ba2c6f114..3a80574ef 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1998,6 +1998,17 @@ "annotations": "", "title": "" }, + "false-positive-dialog": { + "actions": { + "cancel": "", + "save": "" + }, + "content": { + "comment": "", + "body-text": "" + }, + "header": "" + }, "rules-screen": { "error": { "generic": "Es ist ein Fehler aufgetreten ... Die Regeln konnten nicht aktualisiert werden!" diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index a6950c81d..cab00c746 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1998,6 +1998,17 @@ "annotations": "", "title": "Structured Component Management" }, + "false-positive-dialog": { + "actions": { + "cancel": "Cancel", + "save": "Yes, proceed" + }, + "content": { + "comment": "Comment", + "body-text": "''{value}'' is a false positive in this context: {context}" + }, + "header": "False Positive" + }, "rules-screen": { "error": { "generic": "Something went wrong... Rules update failed!"