RED-6774 - updates for remove here, remove in dossier and set as false positive

This commit is contained in:
Valentin Mihai 2023-06-19 11:42:31 +03:00
parent 2d76b6c1eb
commit f0ae6b659f
4 changed files with 50 additions and 18 deletions

View File

@ -179,7 +179,7 @@
<iqser-circle-button <iqser-circle-button
(action)="removeOrSuggestRemoveRedaction()" (action)="removeOrSuggestRemoveRedaction()"
*ngIf="annotationPermissions.canRemoveOrSuggestToRemoveOnlyHere" *ngIf="annotationPermissions.canRemoveOrSuggestToRemoveOnlyHere && annotations.length === 1"
[tooltipPosition]="tooltipPosition" [tooltipPosition]="tooltipPosition"
[tooltip]="'annotation-actions.remove-annotation.remove-redaction' | translate" [tooltip]="'annotation-actions.remove-annotation.remove-redaction' | translate"
[type]="buttonType" [type]="buttonType"

View File

@ -14,7 +14,12 @@ const REMOVE_FROM_DICT_ICON = 'red:remove-from-dict';
export interface RemoveRedactionData { export interface RemoveRedactionData {
redaction: AnnotationWrapper; redaction: AnnotationWrapper;
dossier: Dossier; dossier: Dossier;
hint: boolean; falsePositiveContext: string;
}
export interface RemoveRedactionResult {
comment: string;
option: DetailsRadioOption<RemoveRedactionOption>;
} }
@Component({ @Component({
@ -28,20 +33,18 @@ export class RemoveRedactionDialogComponent extends BaseDialogComponent {
readonly #translations = removeRedactionTranslations; readonly #translations = removeRedactionTranslations;
constructor( constructor(
protected readonly _dialogRef: MatDialogRef<RemoveRedactionDialogComponent>, protected readonly _dialogRef: MatDialogRef<RemoveRedactionDialogComponent, RemoveRedactionResult>,
@Inject(MAT_DIALOG_DATA) readonly data: RemoveRedactionData, @Inject(MAT_DIALOG_DATA) readonly data: RemoveRedactionData,
) { ) {
super(_dialogRef); super(_dialogRef);
this.#redaction = data.redaction; this.#redaction = data.redaction;
console.log('redaction: ', this.#redaction);
this.options = this.#options(); this.options = this.#options();
this.form = this.#getForm(); this.form = this.#getForm();
this.initialFormValue = this.form.getRawValue(); this.initialFormValue = this.form.getRawValue();
} }
save(): void { save(): void {
console.log('test'); this._dialogRef.close(this.form.getRawValue());
} }
#getForm(): UntypedFormGroup { #getForm(): UntypedFormGroup {

View File

@ -20,7 +20,6 @@
<div class="dialog-actions"> <div class="dialog-actions">
<iqser-icon-button <iqser-icon-button
[disabled]="disabled"
[label]="'remove-redaction.dialog.actions.save' | translate" [label]="'remove-redaction.dialog.actions.save' | translate"
[submit]="true" [submit]="true"
[type]="iconButtonTypes.primary" [type]="iconButtonTypes.primary"

View File

@ -30,7 +30,8 @@ import { PdfViewer } from '../../pdf-viewer/services/pdf-viewer.service';
import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service'; import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service';
import { SkippedService } from './skipped.service'; import { SkippedService } from './skipped.service';
import { REDDocumentViewer } from '../../pdf-viewer/services/document-viewer.service'; import { REDDocumentViewer } from '../../pdf-viewer/services/document-viewer.service';
import { RemoveRedactionData } from '../dialogs/remove-redaction-dialog/remove-redaction-dialog.component'; import { RemoveRedactionData, RemoveRedactionResult } from '../dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
import { RemoveRedactionOptions } from '../dialogs/remove-redaction-dialog/remove-redaction-options';
@Injectable() @Injectable()
export class AnnotationActionsService { export class AnnotationActionsService {
@ -134,17 +135,16 @@ export class AnnotationActionsService {
const data: RemoveRedactionData = { const data: RemoveRedactionData = {
redaction, redaction,
dossier: this._state.dossier(), dossier: this._state.dossier(),
hint: redaction.hintDictionary, falsePositiveContext: this._getFalsePositiveText(redaction),
}; };
this._dialogService.openDialog('removeRedaction', data, (result: { comment: string }) => {
const body = { this._dialogService.openDialog('removeRedaction', data, (result: RemoveRedactionResult) => {
annotationId: redaction.id, if (result.option.value === RemoveRedactionOptions.FALSE_POSITIVE) {
comment: result.comment, this.#setAsFalsePositive(redaction, result.comment);
}; } else {
const { dossierId, fileId } = this._state; const removeFromDictionary = result.option.value === RemoveRedactionOptions.IN_DOSSIER;
this.#processObsAndEmit( this.#removeRedaction(redaction, result.comment, removeFromDictionary);
this._manualRedactionService.removeOrSuggestRemove([body], dossierId, fileId, true, redaction.isHint), }
).then();
}); });
} }
@ -394,4 +394,34 @@ export class AnnotationActionsService {
} }
return words; 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();
}
} }