From 4d731984658f6a47dda2c867b6775b77997cc372 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Fri, 6 Jan 2023 17:02:34 +0200 Subject: [PATCH] RED-5907 - Remove Rotate-Buttons in DELTA- and PREVIEW-View --- .../file-preview-screen.component.ts | 9 +++++++ .../services/viewer-header.service.ts | 27 ++++++++++++------- .../app/modules/pdf-viewer/utils/constants.ts | 1 + 3 files changed, 28 insertions(+), 9 deletions(-) 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 012ab37aa..3b60d84a5 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 @@ -685,6 +685,15 @@ export class FilePreviewScreenComponent .subscribe(); this.addActiveScreenSubscription = this._readableRedactionsService.active$.pipe(switchMap(() => this.updateViewMode())).subscribe(); + this.addActiveScreenSubscription = this._viewModeService.viewMode$ + .pipe( + tap(viewMode => + viewMode === 'STANDARD' || viewMode === 'TEXT_HIGHLIGHTS' + ? this._viewerHeaderService.enableRotationButtons() + : this._viewerHeaderService.disableRotationButtons(), + ), + ) + .subscribe(); } private _handleDeletedDossier(): void { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts index a0ea2375f..eb26ada51 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/viewer-header.service.ts @@ -6,7 +6,7 @@ import { BASE_HREF_FN, BaseHrefFn, IqserPermissionsService } from '@iqser/common import { TooltipsService } from './tooltips.service'; import { PageRotationService } from './page-rotation.service'; import { PdfViewer } from './pdf-viewer.service'; -import { ROTATION_ACTION_BUTTONS, ViewerEvents } from '../utils/constants'; +import { ROTATION_ACTION_BUTTONS, ROTATION_BUTTONS, ViewerEvents } from '../utils/constants'; import { FilesMapService } from '@services/files/files-map.service'; import { REDDocumentViewer } from './document-viewer.service'; import { UserPreferenceService } from '@users/user-preference.service'; @@ -161,15 +161,17 @@ export class ViewerHeaderService { cursor: pointer; opacity: 0.7; `; - paragraph.addEventListener('click', () => { - this._rotationService.discardRotation(); - this.disable(ROTATION_ACTION_BUTTONS); - }); + paragraph.addEventListener('click', () => this.#discardRotation()); return paragraph; }, }; } + #discardRotation(): void { + this._rotationService.discardRotation(); + this.disable(ROTATION_ACTION_BUTTONS); + } + private get _rotateRight(): IHeaderElement { return { type: 'actionButton', @@ -214,10 +216,6 @@ export class ViewerHeaderService { this.updateElements(); - if (this._iqserPermissionsService.has(ROLES.files.rotatePage)) { - this.enable([HeaderElements.ROTATE_LEFT_BUTTON, HeaderElements.ROTATE_RIGHT_BUTTON]); - } - if (this._userPreferenceService.areDevFeaturesEnabled) { this.enable([HeaderElements.LOAD_ALL_ANNOTATIONS]); } @@ -269,6 +267,17 @@ export class ViewerHeaderService { }); } + enableRotationButtons(): void { + if (this._iqserPermissionsService.has(ROLES.files.rotatePage)) { + this.enable(ROTATION_BUTTONS); + } + } + + disableRotationButtons(): void { + this.disable(ROTATION_BUTTONS); + this.#discardRotation(); + } + resetCompareButtons() { this.disable([HeaderElements.CLOSE_COMPARE_BUTTON]); this.enable([HeaderElements.COMPARE_BUTTON]); diff --git a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts index 606fe6926..53eaff074 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts @@ -2,6 +2,7 @@ import { CustomError, List } from '@iqser/common-ui'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { HeaderElements, TextPopups } from '../../file-preview/utils/constants'; +export const ROTATION_BUTTONS = [HeaderElements.ROTATE_LEFT_BUTTON, HeaderElements.ROTATE_RIGHT_BUTTON]; export const ROTATION_ACTION_BUTTONS = [HeaderElements.APPLY_ROTATION, HeaderElements.DISCARD_ROTATION]; export const TEXT_POPUPS_TO_TOGGLE = [TextPopups.ADD_REDACTION, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE];