RED-6774 - added "Apply to all dossiers" extra option for detailed options component

This commit is contained in:
Valentin Mihai 2023-06-21 00:11:00 +03:00
parent 219b37f797
commit 14139ab405
10 changed files with 116 additions and 36 deletions

View File

@ -8,7 +8,11 @@
{{ form.get('selectedText').value }}
</div>
<iqser-details-radio [options]="options" formControlName="option"></iqser-details-radio>
<iqser-details-radio
[options]="options"
(extraOptionChanged)="extraOptionChanged($event)"
formControlName="option"
></iqser-details-radio>
<ng-container *deny="roles.getRss; if: !dictionaryRequest && type !== 'HINT'">
<div class="iqser-input-group required w-450">

View File

@ -1,6 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { DetailsRadioOption, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui';
import { Dictionary, Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain';
import { Dictionary, Dossier, DossierTemplate, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain';
import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { Roles } from '@users/roles';
import { firstValueFrom } from 'rxjs';
@ -19,6 +19,7 @@ import { RedactTextOption, RedactTextOptions } from './redact-text-options';
import { tap } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { IqserDialogComponent } from '../../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog-component.directive';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
const PIN_ICON = 'red:push-pin';
const FOLDER_ICON = 'red:folder';
@ -32,6 +33,7 @@ interface RedactTextData {
interface DialogResult {
redaction: IManualRedactionEntry;
dictionary: Dictionary;
applyToAllDossiers: boolean | null;
}
@Component({
@ -52,6 +54,7 @@ export class RedactTextDialogComponent
form!: UntypedFormGroup;
#manualRedactionTypeExists = true;
#applyToAllDossiers = true;
readonly #translations = redactTextTranslations;
readonly #dossier: Dossier;
@ -62,6 +65,7 @@ export class RedactTextDialogComponent
private readonly _activeDossiersService: ActiveDossiersService,
private readonly _dictionaryService: DictionaryService,
private readonly _iqserPermissionsService: IqserPermissionsService,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _formBuilder: FormBuilder,
) {
super();
@ -78,7 +82,6 @@ export class RedactTextDialogComponent
.valueChanges.pipe(
tap((option: DetailsRadioOption<RedactTextOption>) => {
this.dictionaryRequest = option.value === RedactTextOptions.IN_DOSSIER;
console.log('this.dictionaryRequest: ', this.dictionaryRequest);
this.#resetValues();
}),
takeUntilDestroyed(),
@ -116,12 +119,17 @@ export class RedactTextDialogComponent
this.#formatSelectedTextValue();
}
extraOptionChanged(option: DetailsRadioOption<RedactTextOption>): void {
this.#applyToAllDossiers = option.extraOption.checked;
}
save(): void {
this.#enhanceManualRedaction(this.data.manualRedactionEntryWrapper.manualRedactionEntry);
const redaction = this.data.manualRedactionEntryWrapper.manualRedactionEntry;
this.dialogRef.close({
redaction,
dictionary: this.dictionaries.find(d => d.type === this.form.get('dictionary').value),
applyToAllDossiers: this.dictionaryRequest ? this.#applyToAllDossiers : null,
});
}
@ -195,16 +203,18 @@ export class RedactTextDialogComponent
descriptionParams: { dossierName: this.#dossier.dossierName },
icon: FOLDER_ICON,
value: RedactTextOptions.IN_DOSSIER,
// extraOption: {
// label: this.#translations[this.type].inDossier.extraOptionLabel,
// checked: true,
// },
extraOption: {
label: this.#translations[this.type].inDossier.extraOptionLabel,
checked: true,
},
});
}
return options;
}
#resetValues() {
this.#applyToAllDossiers = true;
this.options[1].extraOption.checked = true;
if (this.dictionaryRequest) {
this.form.get('reason').setValue(null);
this.form.get('dictionary').setValue(null);

View File

@ -7,6 +7,8 @@ import { AnnotationWrapper } from '@models/file/annotation.wrapper';
import { Dossier } from '@red/domain';
import { IqserDialogComponent } from '../../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog-component.directive';
import { PermissionsService } from '@services/permissions.service';
import { tap } from 'rxjs/operators';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
const PIN_ICON = 'red:push-pin';
const FOLDER_ICON = 'red:folder';
@ -28,6 +30,7 @@ export interface RemoveRedactionData {
export interface RemoveRedactionResult {
comment: string;
option: DetailsRadioOption<RemoveRedactionOption>;
applyToAllDossiers: boolean | null;
}
@Component({
@ -54,6 +57,17 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
this.#permissions = this.data.permissions;
this.options = this.#options();
this.form = this.#getForm();
this.form
.get('option')
.valueChanges.pipe(
tap(() => {
this.options[1].extraOption.checked = true;
this.options[2].extraOption.checked = true;
}),
takeUntilDestroyed(),
)
.subscribe();
}
save(): void {
@ -85,6 +99,10 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
descriptionParams: { value: this.#redaction.value },
icon: FOLDER_ICON,
value: RemoveRedactionOptions.IN_DOSSIER,
extraOption: {
label: this.#translations.IN_DOSSIER.extraOptionLabel,
checked: true,
},
});
}
if (this.#permissions.canMarkAsFalsePositive) {
@ -94,6 +112,10 @@ export class RemoveRedactionDialogComponent extends IqserDialogComponent<
descriptionParams: { value: this.#redaction.value, type: this.#redaction.type, context: this.data.falsePositiveContext },
icon: REMOVE_FROM_DICT_ICON,
value: RemoveRedactionOptions.FALSE_POSITIVE,
extraOption: {
label: this.#translations.FALSE_POSITIVE.extraOptionLabel,
checked: true,
},
});
}
return options;

View File

@ -76,7 +76,7 @@ import { Roles } from '@users/roles';
import { SuggestionsService } from './services/suggestions.service';
import { IqserDialog } from '../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog.service';
import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
const textActions = [TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE];
@ -141,6 +141,7 @@ export class FilePreviewScreenComponent
private readonly _readableRedactionsService: ReadableRedactionsService,
private readonly _helpModeService: HelpModeService,
private readonly _suggestionsService: SuggestionsService,
private readonly _dossierTemplatesService: DossierTemplatesService,
private readonly _dialog: MatDialog,
) {
super();
@ -386,6 +387,13 @@ export class FilePreviewScreenComponent
result.dictionary?.label,
);
if (result.applyToAllDossiers !== null) {
const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId);
const { ...body } = dossierTemplate;
body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers;
await this._dossierTemplatesService.createOrUpdate(body);
}
const addAndReload$ = add$.pipe(switchMap(() => this._filesService.reload(this.dossierId, file)));
return firstValueFrom(addAndReload$.pipe(catchError(() => of(undefined))));
}

View File

@ -33,10 +33,11 @@ import { REDDocumentViewer } from '../../pdf-viewer/services/document-viewer.ser
import {
RemoveRedactionDialogComponent,
RemoveRedactionPermissions,
RemoveRedactionResult,
} from '../dialogs/remove-redaction-dialog/remove-redaction-dialog.component';
import { RemoveRedactionOptions } from '../dialogs/remove-redaction-dialog/remove-redaction-options';
import { IqserDialog } from '../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog.service';
import { AnnotationPermissions } from '@models/file/annotation.permissions';
import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service';
@Injectable()
export class AnnotationActionsService {
@ -52,6 +53,7 @@ export class AnnotationActionsService {
private readonly _state: FilePreviewStateService,
private readonly _fileDataService: FileDataService,
private readonly _skippedService: SkippedService,
private readonly _dossierTemplatesService: DossierTemplatesService,
) {}
acceptSuggestion(annotations: AnnotationWrapper[]) {
@ -144,7 +146,7 @@ export class AnnotationActionsService {
canMarkAsFalsePositive: permissions.canMarkAsFalsePositive,
};
const result = await this._iqserDialog
const result: RemoveRedactionResult = await this._iqserDialog
.openDefault(RemoveRedactionDialogComponent, {
data: {
redaction,
@ -163,6 +165,13 @@ export class AnnotationActionsService {
this.#removeRedaction(redaction, result.comment, removeFromDictionary);
}
}
if (result.option.extraOption) {
const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId);
const { ...body } = dossierTemplate;
body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers;
await this._dossierTemplatesService.createOrUpdate(body);
}
}
recategorizeImages(annotations: AnnotationWrapper[]) {

View File

@ -4,6 +4,7 @@ import { RemoveRedactionOption } from '../modules/file-preview/dialogs/remove-re
interface Option {
label: string;
description: string;
extraOptionLabel?: string;
}
export const removeRedactionTranslations: { [key in RemoveRedactionOption]: Option } = {
@ -14,9 +15,11 @@ export const removeRedactionTranslations: { [key in RemoveRedactionOption]: Opti
IN_DOSSIER: {
label: _('remove-redaction.dialog.content.options.in-dossier.label'),
description: _('remove-redaction.dialog.content.options.in-dossier.description'),
extraOptionLabel: _('remove-redaction.dialog.content.options.redact.in-dossier.extraOptionLabel'),
},
FALSE_POSITIVE: {
label: _('remove-redaction.dialog.content.options.false-positive.label'),
description: _('remove-redaction.dialog.content.options.false-positive.description'),
extraOptionLabel: _('remove-redaction.dialog.content.options.redact.false-positive.extraOptionLabel'),
},
};

View File

@ -43,6 +43,10 @@
"generic": "Fehler beim Erstellen der Dossiervorlage."
},
"form": {
"apply-updates-default": {
"description": "",
"heading": ""
},
"description": "Beschreibung",
"description-placeholder": "Beschreibung eingeben",
"hidden-text": {
@ -61,11 +65,7 @@
"title": ""
},
"valid-from": "Gültig ab",
"valid-to": "Gültig bis",
"apply-updates-default": {
"heading": "",
"description": ""
}
"valid-to": "Gültig bis"
},
"save": "Dossier-Vorlage speichern",
"title": "{type, select, edit{Dossier-Vorlage {name} bearbeiten} create{Dossier-Vorlage erstellen} clone{} other{}}"
@ -330,9 +330,6 @@
"recategorize-image": "neu kategorisieren",
"reject-suggestion": "Vorschlag ablehnen",
"remove-annotation": {
"false-positive": "Falsch positiv",
"only-here": "nur hier entfernen",
"remove-from-dict": "Aus dem Wörterbuch entfernen",
"remove-redaction": ""
},
"remove-highlights": {
@ -1945,7 +1942,6 @@
"type": "",
"type-placeholder": ""
},
"error": "",
"title": ""
}
},
@ -1987,6 +1983,14 @@
"only-here": {
"description": "",
"label": ""
},
"redact": {
"false-positive": {
"extraOptionLabel": ""
},
"in-dossier": {
"extraOptionLabel": ""
}
}
}
},

View File

@ -43,6 +43,10 @@
"generic": "Failed to create dossier template."
},
"form": {
"apply-updates-default": {
"description": "Apply dictionary updates to all dossiers by default",
"heading": "Entity configuration"
},
"description": "Description",
"description-placeholder": "Enter Description",
"hidden-text": {
@ -61,11 +65,7 @@
"title": "Keep overlapping elements"
},
"valid-from": "Valid from",
"valid-to": "Valid to",
"apply-updates-default": {
"heading": "Entity configuration",
"description": "Apply dictionary updates to all dossiers by default"
}
"valid-to": "Valid to"
},
"save": "Save Dossier Template",
"title": "{type, select, edit{Edit {name}} create{Create} clone{Clone} other{}} Dossier Template"
@ -330,9 +330,6 @@
"recategorize-image": "Recategorize",
"reject-suggestion": "Reject Suggestion",
"remove-annotation": {
"false-positive": "False Positive",
"only-here": "Remove only here",
"remove-from-dict": "Remove from dictionary",
"remove-redaction": "Remove"
},
"remove-highlights": {
@ -1945,7 +1942,6 @@
"type": "Type",
"type-placeholder": "Select type ..."
},
"error": "Error! Invalid page selection",
"title": "Redact text"
}
},
@ -1987,6 +1983,14 @@
"only-here": {
"description": "Do not redact \"{value}\" at this position in the current document.",
"label": "Remove here"
},
"redact": {
"false-positive": {
"extraOptionLabel": "Apply to all dossiers"
},
"in-dossier": {
"extraOptionLabel": "Apply to all dossiers"
}
}
}
},

View File

@ -43,6 +43,10 @@
"generic": "Fehler beim Erstellen der Dossiervorlage."
},
"form": {
"apply-updates-default": {
"description": "",
"heading": ""
},
"description": "Beschreibung",
"description-placeholder": "Beschreibung eingeben",
"hidden-text": {
@ -326,9 +330,6 @@
"recategorize-image": "neu kategorisieren",
"reject-suggestion": "Vorschlag ablehnen",
"remove-annotation": {
"false-positive": "Falsch positiv",
"only-here": "nur hier entfernen",
"remove-from-dict": "Aus dem Wörterbuch entfernen",
"remove-redaction": ""
},
"remove-highlights": {
@ -1941,7 +1942,6 @@
"type": "",
"type-placeholder": ""
},
"error": "",
"title": ""
}
},
@ -1983,6 +1983,14 @@
"only-here": {
"description": "",
"label": ""
},
"redact": {
"false-positive": {
"extraOptionLabel": ""
},
"in-dossier": {
"extraOptionLabel": ""
}
}
}
},

View File

@ -43,6 +43,10 @@
"generic": "Failed to create dossier template."
},
"form": {
"apply-updates-default": {
"description": "",
"heading": ""
},
"description": "Description",
"description-placeholder": "Enter Description",
"hidden-text": {
@ -326,9 +330,6 @@
"recategorize-image": "Recategorize",
"reject-suggestion": "Reject Suggestion",
"remove-annotation": {
"false-positive": "False Positive",
"only-here": "Remove only here",
"remove-from-dict": "Remove from dictionary",
"remove-redaction": "Remove"
},
"remove-highlights": {
@ -1941,7 +1942,6 @@
"type": "Type",
"type-placeholder": "Select type ..."
},
"error": "Error! Invalid page selection",
"title": "Redact text"
}
},
@ -1983,6 +1983,14 @@
"only-here": {
"description": "Do not redact \"{value}\" at this position in the current document.",
"label": "Remove here"
},
"redact": {
"false-positive": {
"extraOptionLabel": "Apply to all dossiers"
},
"in-dossier": {
"extraOptionLabel": "Apply to all dossiers"
}
}
}
},