From 8f55db227947743ba3402e16071b971737b98e8f Mon Sep 17 00:00:00 2001 From: Nicoleta Panaghiu Date: Tue, 23 Apr 2024 15:55:40 +0300 Subject: [PATCH] RED-9045: made the current type always available. --- .../edit-redaction-dialog.component.ts | 8 ++++++-- .../app/services/entity-services/dictionary.service.ts | 10 ++++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts index 484b22a26..92c997acf 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/edit-redaction-dialog/edit-redaction-dialog.component.ts @@ -112,6 +112,10 @@ export class EditRedactionDialogComponent return DialogHelpModeKeys.REDACTION_EDIT; } + get sameType() { + return this.annotations.every(annotation => annotation.type === this.annotations[0].type); + } + async ngOnInit() { this.#setTypes(); const data = await firstValueFrom(this._justificationsService.loadAll(this.#dossier.dossierTemplateId)); @@ -167,6 +171,7 @@ export class EditRedactionDialogComponent this.isImage, this.isHint, this.annotations.every(annotation => annotation.isOCR), + this.sameType ? this.annotations[0].type : null, ); this.typeSelectOptions = this.dictionaries.map(dictionary => ({ @@ -198,13 +203,12 @@ export class EditRedactionDialogComponent } #getForm() { - const sameType = this.annotations.every(annotation => annotation.type === this.annotations[0].type); const sameSection = this.annotations.every(annotation => annotation.section === this.annotations[0].section); return new FormGroup({ reason: new FormControl({ value: null, disabled: this.someSkipped }), comment: new FormControl(null), type: new FormControl({ - value: sameType ? this.annotations[0].type : null, + value: this.sameType ? this.annotations[0].type : null, disabled: this.isImported, }), section: new FormControl({ value: sameSection ? this.annotations[0].section : null, disabled: this.isImported }), diff --git a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts index 5b3af3cb0..f664bc8a9 100644 --- a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts +++ b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts @@ -162,7 +162,13 @@ export class DictionaryService extends EntitiesService .sort((a, b) => a.label.localeCompare(b.label)); } - getEditableRedactionTypes(dossierId: string, isImage: boolean, isHint: boolean, isOCR: boolean): Dictionary[] { + getEditableRedactionTypes( + dossierId: string, + isImage: boolean, + isHint: boolean, + isOCR: boolean, + currentlySelectedType: string, + ): Dictionary[] { return this.#extractDossierLevelTypes(dossierId) .filter( d => @@ -170,7 +176,7 @@ export class DictionaryService extends EntitiesService (isImage ? (isOCR ? [...IMAGE_CATEGORIES, 'ocr'] : IMAGE_CATEGORIES).includes(d.type) : (isHint ? d.hint : !d.hint) && - d.addToDictionaryAction && + (d.addToDictionaryAction || currentlySelectedType === d.type) && !d.virtual && !d.systemManaged && ![...IMAGE_CATEGORIES, 'ocr'].includes(d.type)),