From e963e47709ecef7b66e204aa1ff0765e00882dc6 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 24 Jul 2023 23:44:18 +0300 Subject: [PATCH] RED-7155 - Resize redaction/hint dialogs --- .../resize-redaction-dialog.component.html | 2 +- .../resize-redaction-dialog.component.ts | 24 ++++++--- .../services/annotation-actions.service.ts | 9 +++- .../file-preview/utils/dialog-options.ts | 52 ++++++++----------- .../resize-redaction-translations.ts | 7 ++- apps/red-ui/src/assets/i18n/redact/de.json | 6 +-- apps/red-ui/src/assets/i18n/redact/en.json | 6 +-- apps/red-ui/src/assets/i18n/scm/de.json | 6 +-- apps/red-ui/src/assets/i18n/scm/en.json | 6 +-- libs/common-ui | 2 +- 10 files changed, 69 insertions(+), 51 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html index 0f12aab16..a64e7987e 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html @@ -33,7 +33,7 @@ -
+
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts index 80654e73f..5b2eb7ff4 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts @@ -3,11 +3,11 @@ import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermiss import { ResizeRedactionData, ResizeRedactionResult } from '../../utils/dialog-types'; import { FormBuilder, FormControl, UntypedFormGroup } from '@angular/forms'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { getRedactOrHintOptions, getResizeRedactionOptions, RedactOrHintOption, ResizeRedactionOption } from '../../utils/dialog-options'; +import { getResizeRedactionOptions, ResizeOptions, ResizeRedactionOption } from '../../utils/dialog-options'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { Dictionary, Dossier } from '@red/domain'; import { Roles } from '@users/roles'; -import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; @Component({ templateUrl: './resize-redaction-dialog.component.html', @@ -32,14 +32,20 @@ export class ResizeRedactionDialogComponent constructor( private readonly _activeDossiersService: ActiveDossiersService, private readonly _iqserPermissionsService: IqserPermissionsService, - private readonly _dictionaryService: DictionaryService, + private readonly _dictionariesMapService: DictionariesMapService, private readonly _formBuilder: FormBuilder, ) { super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.redaction = this.data.redaction; - this.options = getResizeRedactionOptions(this.#dossier, this.#isRss, false, this.#applyToAllDossiers, this.data.isApprover); + this.options = getResizeRedactionOptions( + this.redaction, + this.#dossier, + this.#isRss, + this.#applyToAllDossiers, + this.data.isApprover, + ); this.form = this.#getForm(); } @@ -60,7 +66,7 @@ export class ResizeRedactionDialogComponent } async ngOnInit() { - this.dictionaries = this._dictionaryService.getRedactionTypes(this.#dossier.dossierTemplateId); + this.dictionaries = this._dictionariesMapService.get(this.#dossier.dossierTemplateId); } #getForm(): UntypedFormGroup { @@ -72,6 +78,12 @@ export class ResizeRedactionDialogComponent } save(): void { - this.dialogRef.close(this.form.getRawValue()); + const formValue = this.form.getRawValue(); + const updateDictionary = formValue.option.value === ResizeOptions.IN_DOSSIER; + + this.dialogRef.close({ + comment: formValue.comment, + updateDictionary, + }); } } 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 c262c1d3b..99563135e 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 @@ -221,8 +221,15 @@ export class AnnotationActionsService { const isImageText = annotation.isImage ? 'Image' : textAndPositions.text; const text = annotation.rectangle ? annotation.value : isImageText; const isApprover = this._permissionsService.isApprover(dossier); + const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); - const data = { redaction: annotation, text, isApprover, dossierId: dossier.dossierId }; + const data = { + redaction: annotation, + text, + applyToAllDossiers: isApprover && dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault, + isApprover, + dossierId: dossier.dossierId, + }; const result = await this.#getResizeRedactionDialog(data).result(); diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 59601f10b..257e3f9b5 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -6,6 +6,7 @@ import { removeRedactionTranslations } from '@translations/remove-redaction-tran import { RemoveRedactionData } from './dialog-types'; import { removeAnnotationTranslations } from '@translations/remove-annotation-translations'; import { resizeRedactionTranslations } from '@translations/resize-redaction-translations'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -17,6 +18,8 @@ export const RedactOrHintOptions = { } as const; export type RedactOrHintOption = keyof typeof RedactOrHintOptions; + +export const ResizeOptions = RedactOrHintOptions; export type ResizeRedactionOption = RedactOrHintOption; export const RemoveRedactionOptions = { @@ -42,7 +45,7 @@ export const getRedactOrHintOptions = ( label: translations.onlyHere.label, description: translations.onlyHere.description, icon: PIN_ICON, - value: RedactOrHintOptions.ONLY_HERE, + value: ResizeOptions.ONLY_HERE, }, ]; if (!isRss) { @@ -51,7 +54,7 @@ export const getRedactOrHintOptions = ( description: translations.inDossier.description, descriptionParams: { dossierName: dossier.dossierName }, icon: FOLDER_ICON, - value: RedactOrHintOptions.IN_DOSSIER, + value: ResizeOptions.IN_DOSSIER, extraOption: { label: translations.inDossier.extraOptionLabel, checked: applyToAllDossiers, @@ -63,9 +66,9 @@ export const getRedactOrHintOptions = ( }; export const getResizeRedactionOptions = ( + redaction: AnnotationWrapper, dossier: Dossier, isRss: boolean, - hint: boolean, applyToAllDossiers: boolean, isApprover: boolean, ): DetailsRadioOption[] => { @@ -78,32 +81,23 @@ export const getResizeRedactionOptions = ( value: RedactOrHintOptions.ONLY_HERE, }, ]; - // if (!isRss) { - // options.push({ - // label: translations.inDossier.label, - // description: translations.inDossier.description, - // descriptionParams: { dossierName: dossier.dossierName }, - // icon: FOLDER_ICON, - // value: RedactOrHintOptions.IN_DOSSIER, - // extraOption: { - // label: translations.inDossier.extraOptionLabel, - // checked: applyToAllDossiers, - // hidden: !isApprover, - // }, - // }); - // } - options.push({ - label: translations.inDossier.label, - description: translations.inDossier.description, - descriptionParams: { dossierName: dossier.dossierName }, - icon: FOLDER_ICON, - value: RedactOrHintOptions.IN_DOSSIER, - extraOption: { - label: translations.inDossier.extraOptionLabel, - checked: applyToAllDossiers, - hidden: !isApprover, - }, - }); + if (!isRss) { + const dictBasedType = redaction.isModifyDictionary; + options.push({ + label: translations.inDossier.label, + description: translations.inDossier.description, + descriptionParams: { dossierName: dossier.dossierName }, + disabled: !dictBasedType, + tooltip: !dictBasedType ? translations.inDossier.tooltip : null, + icon: FOLDER_ICON, + value: RedactOrHintOptions.IN_DOSSIER, + extraOption: { + label: translations.inDossier.extraOptionLabel, + checked: applyToAllDossiers, + hidden: !isApprover, + }, + }); + } return options; }; diff --git a/apps/red-ui/src/app/translations/resize-redaction-translations.ts b/apps/red-ui/src/app/translations/resize-redaction-translations.ts index db339851c..efcda8cca 100644 --- a/apps/red-ui/src/app/translations/resize-redaction-translations.ts +++ b/apps/red-ui/src/app/translations/resize-redaction-translations.ts @@ -1,7 +1,11 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { DialogOption } from '@translations/redact-text-translations'; -export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', DialogOption> = { +interface ResizeDialogOption extends DialogOption { + tooltip?: string; +} + +export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', ResizeDialogOption> = { onlyHere: { label: _('resize-redaction.dialog.content.options.only-here.label'), description: _('resize-redaction.dialog.content.options.only-here.description'), @@ -10,5 +14,6 @@ export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', Dialo label: _('resize-redaction.dialog.content.options.in-dossier.label'), description: _('resize-redaction.dialog.content.options.in-dossier.description'), extraOptionLabel: _('resize-redaction.dialog.content.options.in-dossier.extraOptionLabel'), + tooltip: _('resize-redaction.dialog.content.options.in-dossier.tooltip'), }, } as const; diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 0b51eccc2..ae0b262ab 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "", "extraOptionLabel": "", - "label": "" + "label": "", + "tooltip": "" }, "only-here": { "description": "", @@ -2121,8 +2122,7 @@ }, "original-text": "", "resized-text": "", - "type": "", - "update-dictionary": "" + "type": "" }, "header": "" } diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 2206613f4..aa48b452c 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "Resize in every document in {dossierName}.", "extraOptionLabel": "Apply to all dossiers", - "label": "Resize in dossier" + "label": "Resize in dossier", + "tooltip": "Only available for dictionary-based types" }, "only-here": { "description": "Resize only at this position in this document.", @@ -2121,8 +2122,7 @@ }, "original-text": "Original text:", "resized-text": "Resized text:", - "type": "Type", - "update-dictionary": "Update dictionary: {text}" + "type": "Type" }, "header": "Resize {type}" } diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 0968d90e3..ca93efb54 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "", "extraOptionLabel": "", - "label": "" + "label": "", + "tooltip": "" }, "only-here": { "description": "", @@ -2121,8 +2122,7 @@ }, "original-text": "", "resized-text": "", - "type": "", - "update-dictionary": "" + "type": "" }, "header": "" } diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 36aa80a18..3d5173cc9 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "Resize in every document in {dossierName}.", "extraOptionLabel": "Apply to all dossiers", - "label": "Resize in dossier" + "label": "Resize in dossier", + "tooltip": "Only available for dictionary-based types" }, "only-here": { "description": "Resize only at this position in this document.", @@ -2121,8 +2122,7 @@ }, "original-text": "Original text:", "resized-text": "Resized text:", - "type": "Type", - "update-dictionary": "Update dictionary: {text}" + "type": "Type" }, "header": "Resize {type}" } diff --git a/libs/common-ui b/libs/common-ui index 2524896f4..8f4cc53d0 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 2524896f460594d7766a7c572b63cd3199eac7db +Subproject commit 8f4cc53d0f814d3f222801379497cff40d7801ee