diff --git a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.html b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.html index 3927d5d70..c7515da50 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.html @@ -5,6 +5,6 @@ [activeSelection]="pageHasSelection(pageNumber)" [number]="pageNumber" [read]="!!getViewedPage(viewedPages, pageNumber)" - [showDottedIcon]="hasOnlyManualRedactionsAndIsExcluded(pageNumber)" + [showDottedIcon]="isPageExcluded(pageNumber)" > diff --git a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts index 43974fe89..892636f9a 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts @@ -49,9 +49,8 @@ export class PagesComponent implements AfterViewInit { return this.#multiSelectService.active() && !!this.#listingService.selected.find(a => a.pageNumber === page); } - hasOnlyManualRedactionsAndIsExcluded(pageNumber: number): boolean { - const hasOnlyManualRedactions = this.displayedAnnotations.get(pageNumber)?.every(annotation => annotation.manual); - return hasOnlyManualRedactions && this.#state.file().excludedPages.includes(pageNumber); + isPageExcluded(pageNumber: number): boolean { + return this.#state.file().excludedPages.includes(pageNumber); } getViewedPage(viewedPages: ViewedPage[], pageNumber: number) { 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 68f6444cd..0b7e5d1cc 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 @@ -75,12 +75,10 @@ import { SkippedService } from './services/skipped.service'; import { StampService } from './services/stamp.service'; import { TablesService } from './services/tables.service'; import { ViewModeService } from './services/view-mode.service'; -import { ALL_HOTKEYS, TextPopups } from './utils/constants'; +import { ALL_HOTKEYS } from './utils/constants'; import { RedactTextData } from './utils/dialog-types'; import { AnnotationActionsService } from './services/annotation-actions.service'; -const textActions = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE]; - @Component({ templateUrl: './file-preview-screen.component.html', styleUrls: ['./file-preview-screen.component.scss'], @@ -167,17 +165,20 @@ export class FilePreviewScreenComponent ); effect(() => { - this.state.shouldUpdate(); + this.state.updateExcludedPagesStyle(); if (this._documentViewer.pageComplete()) { this.#setExcludedPageStyles(); } }); effect(() => { + this.state.updateExcludedPagesStyle(); if (this._viewModeService.viewMode()) { this.updateViewMode().then(); - this._logger.info('[PDF] Stamp pdf'); - this._stampService.stampPDF().then(); + if (_documentViewer.loaded()) { + this._logger.info('[PDF] Stamp pdf'); + this._stampService.stampPDF().then(); + } } }); } @@ -767,20 +768,6 @@ export class FilePreviewScreenComponent ), ) .subscribe(); - - const selectedTextEffect = this._documentViewer.selectedText$.pipe( - tap(() => { - const canPerformActions = this.pdfProxyService.canPerformActions(); - const isCurrentPageExcluded = this.state.file().isPageExcluded(this.pdf.currentPage()); - - if (canPerformActions && !isCurrentPageExcluded) { - this.pdf.enable(textActions); - } else { - this.pdf.disable(textActions); - } - }), - ); - this.addActiveScreenSubscription = selectedTextEffect.subscribe(); } #handleDeletedDossier(): void { diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts index cff5a8ebf..e30892626 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-preview-state.service.ts @@ -44,7 +44,7 @@ export class FilePreviewStateService { readonly dossierId = getParam(DOSSIER_ID); readonly dossierTemplateId = getParam(DOSSIER_TEMPLATE_ID); readonly fileId = getParam(FILE_ID); - readonly shouldUpdate = computed(() => this.file().excludedPages); + readonly updateExcludedPagesStyle = computed(() => this.file().excludedPages); constructor( private readonly _permissionsService: PermissionsService, 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 2d4019d05..e8b7fc324 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 @@ -99,7 +99,6 @@ export class PdfProxyService { this._pdf.isCompareMode(); this.#configureTextPopup(); - this.#handleExcludedPageActions(); if (canPerformActions) { this.#enableActions(); @@ -107,6 +106,8 @@ export class PdfProxyService { this.#disableActions(); this.#deactivateMultiSelect(); } + + this.#handleExcludedPageActions(); }, { allowSignalWrites: true }, ); @@ -231,7 +232,7 @@ export class PdfProxyService { let textPopupElementsToDisable = [...TEXT_POPUPS_TO_TOGGLE]; let headerElementsToDisable = [...HEADER_ITEMS_TO_TOGGLE]; - if (this.canPerformActions()) { + if (this.canPerformActions() && !this.#isDocumine) { this._pdf.enable(ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED); this._viewerHeaderService.enable(ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED as HeaderElementType[]);