RED-7069, treat ai/rule based redactions same as dict based, include ocr prefill for ocr hints.

This commit is contained in:
George 2023-08-18 10:57:06 +03:00
parent 75c4d111a0
commit dee37cfab2
3 changed files with 12 additions and 7 deletions

View File

@ -48,12 +48,12 @@ export class EditRedactionDialogComponent
this.#applyToAllDossiers = this.data.applyToAllDossiers;
const annotations = this.data.annotations;
const firstEntry = annotations[0];
this.isImage = IMAGE_CATEGORIES.includes(firstEntry.type);
this.isImage = [...IMAGE_CATEGORIES, 'ocr'].includes(firstEntry.type);
this.redactedText = annotations.length === 1 && !this.isImage ? firstEntry.value : null;
this.isModifyDictionary = firstEntry.isModifyDictionary;
this.isManualRedaction = firstEntry.type === SuperTypes.ManualRedaction;
this.isHint = firstEntry.isHint;
this.showExtras = this.isManualRedaction || ((firstEntry.isRedacted || firstEntry.isSkipped) && firstEntry.dictionaryOperation);
this.showExtras = !(this.isImage || this.isHint);
this.form = this.#getForm();
}
@ -102,7 +102,12 @@ export class EditRedactionDialogComponent
}
#setTypes() {
this.dictionaries = this._dictionaryService.getEditableRedactionTypes(this.#dossier.dossierTemplateId, this.isImage, this.isHint);
this.dictionaries = this._dictionaryService.getEditableRedactionTypes(
this.#dossier.dossierTemplateId,
this.isImage,
this.isHint,
this.data.annotations[0].isOCR,
);
}
#setOptions(type: string, reasonChanged = false) {

View File

@ -1,6 +1,6 @@
import { List, ValuesOf } from '@iqser/common-ui/lib/utils';
export const IMAGE_CATEGORIES: readonly string[] = ['signature', 'logo', 'formula', 'image', 'ocr'];
export const IMAGE_CATEGORIES: readonly string[] = ['signature', 'logo', 'formula', 'image'];
export const ActionsHelpModeKeys = {
redaction: 'redaction',
'manual-redaction': 'redaction',

View File

@ -166,14 +166,14 @@ export class DictionaryService extends EntitiesService<IDictionary, Dictionary>
return dictionaries.sort((a, b) => a.label.localeCompare(b.label));
}
getEditableRedactionTypes(dossierTemplateId: string, isImage: boolean, isHint: boolean): Dictionary[] {
getEditableRedactionTypes(dossierTemplateId: string, isImage: boolean, isHint: boolean, isOCR: boolean): Dictionary[] {
const types = [];
this._dictionariesMapService
.get(dossierTemplateId)
.filter(d =>
isImage
? IMAGE_CATEGORIES.includes(d.type)
: (isHint ? d.hint : !d.hint) && !d.virtual && !IMAGE_CATEGORIES.includes(d.type),
? (isOCR ? [...IMAGE_CATEGORIES, 'ocr'] : IMAGE_CATEGORIES).includes(d.type)
: (isHint ? d.hint : !d.hint) && !d.virtual && ![...IMAGE_CATEGORIES, 'ocr'].includes(d.type),
)
.forEach(d => !types.find(t => t.id === d.id) && types.push(d));
return types.sort((a, b) => a.label.localeCompare(b.label));