From cf6cbb92dabfbed8ede54f86af01531d718e7b88 Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Thu, 31 Aug 2023 11:26:27 +0300 Subject: [PATCH] RED-7155 fix resize recommendations --- .../add-hint-dialog.component.ts | 21 ++-- ...edact-recommendation-dialog.component.html | 2 +- .../redact-recommendation-dialog.component.ts | 97 ++++++++----------- .../redact-text-dialog.component.ts | 19 ++-- .../resize-redaction-dialog.component.ts | 25 ++--- .../file-preview-screen.component.ts | 8 +- .../services/annotation-actions.service.ts | 20 ++-- .../services/pdf-proxy.service.ts | 7 +- .../file-preview/utils/dialog-options.ts | 88 +++++++++-------- .../services/annotation-manager.service.ts | 13 ++- 10 files changed, 141 insertions(+), 159 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts index ef76bca54..516be0efc 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts @@ -1,14 +1,13 @@ import { Component, OnInit } from '@angular/core'; -import { DetailsRadioOption, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { FormBuilder, UntypedFormGroup } from '@angular/forms'; -import { Roles } from '@users/roles'; -import { JustificationsService } from '@services/entity-services/justifications.service'; +import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; +import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { JustificationsService } from '@services/entity-services/justifications.service'; +import { Roles } from '@users/roles'; import { tap } from 'rxjs/operators'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { IqserDialogComponent } from '@iqser/common-ui'; import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options'; import { AddHintData, AddHintResult } from '../../utils/dialog-types'; @@ -16,6 +15,9 @@ import { AddHintData, AddHintResult } from '../../utils/dialog-types'; templateUrl: './add-hint-dialog.component.html', }) export class AddHintDialogComponent extends IqserDialogComponent implements OnInit { + #applyToAllDossiers: boolean; + readonly #dossier: Dossier; + readonly #isRss = this._iqserPermissionsService.has(Roles.getRss); readonly roles = Roles; readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; @@ -23,11 +25,6 @@ export class AddHintDialogComponent extends IqserDialogComponent
-
+
{{ selectedText }}
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts index dbeb80b71..f7640c6d4 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-recommendation-dialog/redact-recommendation-dialog.component.ts @@ -1,18 +1,17 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; +import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; +import { FormBuilder } from '@angular/forms'; import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; -import { FormBuilder, UntypedFormGroup } from '@angular/forms'; -import { Roles } from '@users/roles'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { Dictionary, IAddRedactionRequest, SuperTypes } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; -import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { JustificationsService } from '@services/entity-services/justifications.service'; +import { firstValueFrom } from 'rxjs'; +import { tap } from 'rxjs/operators'; import { getRedactOrHintOptions, RedactOrHintOption, RedactOrHintOptions } from '../../utils/dialog-options'; import { RedactRecommendationData, RedactRecommendationResult } from '../../utils/dialog-types'; -import { JustificationsService } from '@services/entity-services/justifications.service'; -import { tap } from 'rxjs/operators'; -import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { firstValueFrom } from 'rxjs'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { LegalBasisOption } from '../manual-redaction-dialog/manual-annotation-dialog.component'; @Component({ templateUrl: './redact-recommendation-dialog.component.html', @@ -21,40 +20,33 @@ export class RedactRecommendationDialogComponent extends IqserDialogComponent implements OnInit { - readonly roles = Roles; + readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId); + readonly #manualRedactionTypeExists = inject(DictionaryService).hasManualType(this.#dossier.dossierTemplateId); + #applyToAllDossiers = this.data.applyToAllDossiers ?? true; readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; - readonly firstEntry: AnnotationWrapper; - readonly isMulti: boolean; + readonly firstEntry = this.data.annotations[0]; + readonly isMulti = this.data.annotations.length > 1; dictionaryRequest = false; legalOptions: LegalBasisOption[] = []; dictionaries: Dictionary[] = []; - form!: UntypedFormGroup; - - #manualRedactionTypeExists = true; - #applyToAllDossiers: boolean; - - readonly #dossier: Dossier; + readonly form = inject(FormBuilder).group({ + selectedText: this.isMulti ? null : this.firstEntry.value, + comment: [null], + dictionary: [null], + option: [null], + reason: [null], + }); constructor( private readonly _justificationsService: JustificationsService, - private readonly _activeDossiersService: ActiveDossiersService, private readonly _dictionaryService: DictionaryService, - private readonly _formBuilder: FormBuilder, ) { super(); - this.#dossier = this._activeDossiersService.find(this.data.dossierId); - this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; - this.options = getRedactOrHintOptions(this.#dossier, false, false, this.#applyToAllDossiers, this.data.isApprover); - this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); - this.firstEntry = this.data.annotations[0]; - this.isMulti = this.data.annotations.length > 1; + this.options = getRedactOrHintOptions(this.#dossier, this.#applyToAllDossiers, this.data.isApprover, true); - this.form = this.#getForm(); - - this.form - .get('option') - .valueChanges.pipe( + this.form.controls.option.valueChanges + .pipe( tap((option: DetailsRadioOption) => { this.dictionaryRequest = option.value === RedactOrHintOptions.IN_DOSSIER; this.#setDictionaries(); @@ -64,11 +56,11 @@ export class RedactRecommendationDialogComponent ) .subscribe(); - this.form.get('option').setValue(this.options[1]); + this.form.controls.option.setValue(this.options[0]); } get displayedDictionaryLabel() { - const dictType = this.form.get('dictionary').value; + const dictType = this.form.controls.dictionary.value; if (dictType) { return this.dictionaries.find(d => d.type === dictType)?.label ?? null; } @@ -76,7 +68,7 @@ export class RedactRecommendationDialogComponent } get disabled() { - return this.dictionaryRequest && !this.form.get('dictionary').value; + return this.dictionaryRequest && !this.form.controls.dictionary.value; } async ngOnInit(): Promise { @@ -96,26 +88,26 @@ export class RedactRecommendationDialogComponent this.#applyToAllDossiers = option.extraOption.checked; this.#setDictionaries(); - if (this.#applyToAllDossiers && this.form.get('dictionary').value) { - const selectedDictionaryLabel = this.form.get('dictionary').value; + if (this.#applyToAllDossiers && this.form.controls.dictionary.value) { + const selectedDictionaryLabel = this.form.controls.dictionary.value; const selectedDictionary = this.dictionaries.find(d => d.type === selectedDictionaryLabel); if (!selectedDictionary) { - this.form.get('dictionary').setValue(null); + this.form.controls.dictionary.setValue(null); } } } typeChanged() { if (!this.#applyToAllDossiers) { - const selectedDictionaryType = this.form.get('dictionary').value; + const selectedDictionaryType = this.form.controls.dictionary.value; const selectedDictionary = this.dictionaries.find(d => d.type === selectedDictionaryType); - this.options[1].extraOption.disabled = selectedDictionary.dossierDictionaryOnly; + this.options[0].extraOption.disabled = selectedDictionary.dossierDictionaryOnly; } } - save(): void { + save() { const redaction = this.#convertRecommendationToRedaction(this.firstEntry); - this.dialogRef.close({ + this.close({ redaction, isMulti: this.isMulti, }); @@ -125,25 +117,16 @@ export class RedactRecommendationDialogComponent this.dictionaries = this._dictionaryService.getRedactTextDictionaries(this.#dossier.dossierTemplateId, !this.#applyToAllDossiers); } - #getForm(): UntypedFormGroup { - return this._formBuilder.group({ - selectedText: this.isMulti ? null : this.firstEntry.value, - comment: [null], - dictionary: [null], - option: [null], - }); - } - #selectReason() { if (this.legalOptions.length === 1) { - this.form.get('reason').setValue(this.legalOptions[0]); + this.form.controls.reason.setValue(this.legalOptions[0]); } } #convertRecommendationToRedaction(recommendation: AnnotationWrapper): IAddRedactionRequest { const addRedactionRequest: IAddRedactionRequest = { ...recommendation }; - addRedactionRequest.type = this.form.get('dictionary').value; - addRedactionRequest.value = this.form.get('selectedText').value; + addRedactionRequest.type = this.form.controls.dictionary.value; + addRedactionRequest.value = this.form.controls.selectedText.value; const selectedType = this.dictionaries.find(d => d.type === addRedactionRequest.type); @@ -153,7 +136,7 @@ export class RedactRecommendationDialogComponent addRedactionRequest.addToDictionary = this.dictionaryRequest && addRedactionRequest.type !== 'dossier_redaction'; } - const commentValue = this.form.get('comment').value; + const commentValue = this.form.controls.comment.value; addRedactionRequest.comment = commentValue ? { text: commentValue } : null; addRedactionRequest.addToAllDossiers = this.data.isApprover && this.dictionaryRequest && this.#applyToAllDossiers; return addRedactionRequest; @@ -162,9 +145,9 @@ export class RedactRecommendationDialogComponent #resetValues() { this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; if (this.dictionaryRequest) { - this.form.get('dictionary').setValue(this.firstEntry.type); + this.form.controls.dictionary.setValue(this.firstEntry.type); return; } - this.form.get('dictionary').setValue(this.#manualRedactionTypeExists ? SuperTypes.ManualRedaction : null); + this.form.controls.dictionary.setValue(this.#manualRedactionTypeExists ? SuperTypes.ManualRedaction : null); } } diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts index d35be1ccf..c0c5abb6b 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts @@ -1,8 +1,8 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; -import { FormBuilder, UntypedFormGroup } from '@angular/forms'; +import { FormBuilder } from '@angular/forms'; import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { Dictionary, IAddRedactionRequest, SuperTypes } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { DictionaryService } from '@services/entity-services/dictionary.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; @@ -21,28 +21,25 @@ export class RedactTextDialogComponent extends IqserDialogComponent implements OnInit { - #manualRedactionTypeExists = true; - #applyToAllDossiers: boolean; - readonly #dossier: Dossier; + readonly #manualRedactionTypeExists: boolean; + #applyToAllDossiers = this.data.applyToAllDossiers ?? true; + readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId); readonly roles = Roles; readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; dictionaryRequest = false; legalOptions: LegalBasisOption[] = []; dictionaries: Dictionary[] = []; - form!: UntypedFormGroup; + readonly form; constructor( private readonly _justificationsService: JustificationsService, - private readonly _activeDossiersService: ActiveDossiersService, private readonly _dictionaryService: DictionaryService, private readonly _formBuilder: FormBuilder, ) { super(); - this.#dossier = _activeDossiersService.find(this.data.dossierId); - this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); - this.options = getRedactOrHintOptions(this.#dossier, false, false, this.#applyToAllDossiers, this.data.isApprover); + this.options = getRedactOrHintOptions(this.#dossier, this.#applyToAllDossiers, this.data.isApprover); this.form = this.#getForm(); 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 527720627..a17d04958 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 @@ -1,11 +1,9 @@ -import { Component, OnInit } from '@angular/core'; +import { Component, inject, OnInit } from '@angular/core'; import { FormBuilder, FormControl, FormGroup } from '@angular/forms'; -import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { Dictionary, Dossier } from '@red/domain'; +import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; +import { Dictionary } from '@red/domain'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; -import { Roles } from '@users/roles'; import { getResizeRedactionOptions, ResizeOptions, ResizeRedactionOption } from '../../utils/dialog-options'; import { ResizeRedactionData, ResizeRedactionResult } from '../../utils/dialog-types'; @@ -17,12 +15,11 @@ export class ResizeRedactionDialogComponent implements OnInit { readonly #applyToAllDossiers = this.data.applyToAllDossiers ?? true; - readonly #dossier: Dossier; - readonly #isRss = this._iqserPermissionsService.has(Roles.getRss); + readonly #dossier = inject(ActiveDossiersService).find(this.data.dossierId); readonly iconButtonTypes = IconButtonTypes; readonly options: DetailsRadioOption[]; dictionaries: Dictionary[] = []; - redaction: AnnotationWrapper; + readonly redaction = this.data.redaction; form: FormGroup<{ comment: FormControl; dictionary: FormControl; @@ -30,21 +27,11 @@ export class ResizeRedactionDialogComponent }>; constructor( - private readonly _activeDossiersService: ActiveDossiersService, - private readonly _iqserPermissionsService: IqserPermissionsService, private readonly _dictionariesMapService: DictionariesMapService, private readonly _formBuilder: FormBuilder, ) { super(); - this.#dossier = _activeDossiersService.find(this.data.dossierId); - this.redaction = this.data.redaction; - this.options = getResizeRedactionOptions( - this.redaction, - this.#dossier, - this.#isRss, - this.#applyToAllDossiers, - this.data.isApprover, - ); + this.options = getResizeRedactionOptions(this.redaction, this.#dossier, false, this.#applyToAllDossiers, this.data.isApprover); this.form = this.#getForm(); } diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 44fb634fc..7b93ef488 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -523,15 +523,15 @@ export class FilePreviewScreenComponent async #openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) { const file = this.state.file(); - const hint = manualRedactionEntryWrapper.type === ManualRedactionEntryTypes.HINT; const data = this.#getRedactTextDialogData(manualRedactionEntryWrapper, file); - const result = await this.#getRedactTextDialog(hint, data).result(); + const result = await this.#getRedactTextDialog(data).result(); if (!result) { return; } + const hint = manualRedactionEntryWrapper.type === ManualRedactionEntryTypes.HINT; const add$ = this._manualRedactionService.addAnnotation([result.redaction], this.dossierId, this.fileId, { hint, dictionaryLabel: result.dictionary?.label, @@ -868,10 +868,12 @@ export class FilePreviewScreenComponent } } - #getRedactTextDialog(hint: boolean, data: RedactTextData) { + #getRedactTextDialog(data: RedactTextData) { if (this.#isDocumine) { return this._iqserDialog.openDefault(AddAnnotationDialogComponent, { data }); } + + const hint = data.manualRedactionEntryWrapper.type === ManualRedactionEntryTypes.HINT; if (hint) { return this._iqserDialog.openDefault(AddHintDialogComponent, { data }); } 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 7a129a0fa..8579ae9eb 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 @@ -171,14 +171,13 @@ export class AnnotationActionsService { undoDirectAction(annotations: AnnotationWrapper[]) { const { dossierId, fileId } = this._state; const modifyDictionary = annotations[0].isModifyDictionary; - this.#processObsAndEmit( - this._manualRedactionService.undoRequest( - annotations.map(a => a.id), - dossierId, - fileId, - modifyDictionary, - ), - ).then(); + const request$ = this._manualRedactionService.undoRequest( + annotations.map(a => a.id), + dossierId, + fileId, + modifyDictionary, + ); + this.#processObsAndEmit(request$).then(); } async convertRecommendationToAnnotation(recommendations: AnnotationWrapper[]) { @@ -194,9 +193,8 @@ export class AnnotationActionsService { this.cancelResize(recommendations[0]).then(); } - return this.#processObsAndEmit( - this._manualRedactionService.addRecommendation(recommendations, result.redaction, dossierId, fileId), - ); + const request$ = this._manualRedactionService.addRecommendation(recommendations, result.redaction, dossierId, fileId); + return this.#processObsAndEmit(request$); } resize(annotationWrapper: AnnotationWrapper) { diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index badf12fdf..ce5b804d2 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -288,6 +288,7 @@ export class PdfProxyService { #processSelectedAnnotations(annotations: Annotation[], action: string) { let nextAnnotations: Annotation[]; + this._pdf.resetAnnotationActions(); if (action === 'deselected') { this.#cancelResizeIfIsResizing(annotations); @@ -295,11 +296,11 @@ export class PdfProxyService { nextAnnotations = this._annotationManager.selected.filter(ann => !annotations.some(a => a.Id === ann.Id)); this._pdf.disable(TextPopups.ADD_RECTANGLE); const currentPage = this._pdf.currentPage(); + if (nextAnnotations.some(a => a.getPageNumber() === currentPage)) { this.#configureAnnotationSpecificActions(nextAnnotations); - } else { - this._pdf.resetAnnotationActions(); } + return nextAnnotations.map(ann => ann.Id); } @@ -361,8 +362,6 @@ export class PdfProxyService { } #configureAnnotationSpecificActions(viewerAnnotations: Annotation[]) { - this._pdf.resetAnnotationActions(); - if (!this.canPerformActions()) { return; } 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 6375b9dc0..cf41c03c1 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 @@ -1,12 +1,12 @@ import { DetailsRadioOption } from '@iqser/common-ui'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { Dossier } from '@red/domain'; import { addHintTranslations } from '@translations/add-hint-translations'; import { editRedactionTranslations, redactTextTranslations } from '@translations/redact-text-translations'; -import { Dossier } from '@red/domain'; -import { removeRedactionTranslations } from '@translations/remove-redaction-translations'; -import { RemoveRedactionData } from './dialog-types'; import { removeAnnotationTranslations } from '@translations/remove-annotation-translations'; +import { removeRedactionTranslations } from '@translations/remove-redaction-translations'; import { resizeRedactionTranslations } from '@translations/resize-redaction-translations'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { RemoveRedactionData } from './dialog-types'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -67,34 +67,41 @@ export const getEditRedactionOptions = ( export const getRedactOrHintOptions = ( dossier: Dossier, - isRss: boolean, - hint: boolean, applyToAllDossiers: boolean, isApprover: boolean, + isRecommendation = false, + isHint = false, + isRss = false, ): DetailsRadioOption[] => { - const translations = hint ? addHintTranslations : redactTextTranslations; - const options: DetailsRadioOption[] = [ - { + const translations = isHint ? addHintTranslations : redactTextTranslations; + const options: DetailsRadioOption[] = []; + + if (!isRecommendation) { + options.push({ label: translations.onlyHere.label, description: translations.onlyHere.description, icon: PIN_ICON, value: ResizeOptions.ONLY_HERE, - }, - ]; - if (!isRss) { - options.push({ - label: translations.inDossier.label, - description: translations.inDossier.description, - descriptionParams: { dossierName: dossier.dossierName }, - icon: FOLDER_ICON, - value: ResizeOptions.IN_DOSSIER, - extraOption: { - label: translations.inDossier.extraOptionLabel, - checked: applyToAllDossiers, - hidden: !isApprover, - }, }); } + + if (isRss) { + return options; + } + + options.push({ + label: translations.inDossier.label, + description: translations.inDossier.description, + descriptionParams: { dossierName: dossier.dossierName }, + icon: FOLDER_ICON, + value: ResizeOptions.IN_DOSSIER, + extraOption: { + label: translations.inDossier.extraOptionLabel, + checked: applyToAllDossiers, + hidden: !isApprover, + }, + }); + return options; }; @@ -114,23 +121,26 @@ export const getResizeRedactionOptions = ( value: RedactOrHintOptions.ONLY_HERE, }, ]; - 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, - }, - }); + + if (isRss) { + return options; } + + 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/modules/pdf-viewer/services/annotation-manager.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts index 79f250bbd..8aa406601 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts @@ -60,7 +60,7 @@ export class REDAnnotationManager { get(annotations: List | List): Annotation[]; - get(predicate?: (value: Annotation) => boolean): Annotation[]; + get(predicate?: AnnotationPredicate): Annotation[]; get(argument?: AnnotationPredicate | List | List | AnnotationWrapper | string): Annotation | Annotation[] { if (isStringOrWrapper(argument)) { @@ -68,7 +68,16 @@ export class REDAnnotationManager { } const isList = argument instanceof Array; - return isList ? this.#getByIds(argument) : this.#get(argument); + if (isList) { + return this.#getByIds(argument); + } + + const isNotPredicate = typeof argument !== 'function'; + if (isNotPredicate) { + return this.#getById(argument); + } + + return this.#get(argument); } deselect(annotation: string | AnnotationWrapper): void;