From 6923a00caf2ab959ef280caff7db4d2167eefb3a Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Fri, 27 Oct 2023 14:37:49 +0300 Subject: [PATCH 1/3] RED-7673 - Resize accept and decline actions not available in the document viewer --- .../file-preview/services/pdf-proxy.service.ts | 11 +++++------ .../modules/pdf-viewer/services/pdf-viewer.service.ts | 7 ------- package.json | 2 +- 3 files changed, 6 insertions(+), 14 deletions(-) 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 d75331b30..0e4305180 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 @@ -58,7 +58,6 @@ export class PdfProxyService { readonly currentUser = getCurrentUser(); readonly pageChanged$ = this._pdf.pageChanged$.pipe( tap(() => this.#handleExcludedPageActions()), - tap(() => this._pdf.resetAnnotationActions()), shareDistinctLast(), ); readonly canPerformActions = computed(() => { @@ -143,7 +142,7 @@ export class PdfProxyService { onClick: () => this._ngZone.run(() => this.#addRectangleManualRedaction()), }; - this._pdf.instance.UI.annotationPopup.add([addRectangleButton]); + this._pdf.instance.UI.annotationPopup.update([addRectangleButton]); } } @@ -280,7 +279,6 @@ export class PdfProxyService { #processSelectedAnnotations(annotations: Annotation[], action: string) { let nextAnnotations: Annotation[]; - this._pdf.resetAnnotationActions(); if (action === 'deselected') { this.#cancelResizeIfIsResizing(annotations); @@ -360,6 +358,7 @@ export class PdfProxyService { return this.#configureRectangleAnnotationPopup(viewerAnnotations[0]); } + let actions = []; // Add hide action as last item const allAreImage = annotationWrappers.reduce((acc, next) => acc && next.isImage, true); if (allAreImage && !this._annotationManager.resizingAnnotationId) { @@ -383,11 +382,11 @@ export class PdfProxyService { }, }; - this._pdf.instance.UI.annotationPopup.add([visibilityButton]); + actions.push(visibilityButton); } - const actions = this._pdfAnnotationActionsService.get(annotationWrappers); - this._pdf.instance.UI.annotationPopup.add(actions); + actions = [...actions, ...this._pdfAnnotationActionsService.get(annotationWrappers)]; + this._pdf.instance.UI.annotationPopup.update(actions); } #getTitle(type: ManualRedactionEntryType) { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts index c18823d15..5e31cd85a 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/pdf-viewer.service.ts @@ -124,13 +124,6 @@ export class PdfViewer { this.#instance.UI.closeElements(['searchPanel']); } - resetAnnotationActions() { - if (this.#instance.UI.annotationPopup.getItems().length) { - this.#logger.info('[PDF] Reset annotation actions'); - this.#instance.UI.annotationPopup.update([]); - } - } - navigateTo(page: string | number) { const parsedNumber = typeof page === 'string' ? parseInt(page, 10) : page; const paginationOffset = this.#paginationOffset; diff --git a/package.json b/package.json index 65fc01539..c051e8488 100644 --- a/package.json +++ b/package.json @@ -39,7 +39,7 @@ "@ngx-translate/core": "15.0.0", "@ngx-translate/http-loader": "8.0.0", "@nx/angular": "16.10.0", - "@pdftron/webviewer": "10.3.0", + "@pdftron/webviewer": "10.5.0", "chart.js": "4.4.0", "dayjs": "1.11.10", "file-saver": "^2.0.5", From 871ff5759e4a9fa3310eff1b998971ca9808fc9f Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Fri, 27 Oct 2023 16:23:43 +0300 Subject: [PATCH 2/3] RED-7673 - deselected annotation when page is changed instead of updating the actions with an empty list --- .../src/app/modules/file-preview/services/pdf-proxy.service.ts | 1 + 1 file changed, 1 insertion(+) 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 0e4305180..4fdb5b0bb 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 @@ -58,6 +58,7 @@ export class PdfProxyService { readonly currentUser = getCurrentUser(); readonly pageChanged$ = this._pdf.pageChanged$.pipe( tap(() => this.#handleExcludedPageActions()), + tap(() => this._annotationManager.deselect()), shareDistinctLast(), ); readonly canPerformActions = computed(() => { From 30058cdb5aac7b94616b2b29278c1b833a0de155 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 30 Oct 2023 14:47:12 +0200 Subject: [PATCH 3/3] RED-7673 - deselect annotations only if multi select mode is not active --- .../modules/file-preview/services/pdf-proxy.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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 4fdb5b0bb..efc7871cf 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 @@ -58,7 +58,11 @@ export class PdfProxyService { readonly currentUser = getCurrentUser(); readonly pageChanged$ = this._pdf.pageChanged$.pipe( tap(() => this.#handleExcludedPageActions()), - tap(() => this._annotationManager.deselect()), + tap(() => { + if (this._multiSelectService.inactive()) { + this._annotationManager.deselect(); + } + }), shareDistinctLast(), ); readonly canPerformActions = computed(() => { @@ -386,7 +390,7 @@ export class PdfProxyService { actions.push(visibilityButton); } - actions = [...actions, ...this._pdfAnnotationActionsService.get(annotationWrappers)]; + actions = this._multiSelectService.inactive() ? [...actions, ...this._pdfAnnotationActionsService.get(annotationWrappers)] : []; this._pdf.instance.UI.annotationPopup.update(actions); }