RED-6316: Fixed showing rotation buttons

This commit is contained in:
Adina Țeudan 2023-03-16 20:14:27 +02:00
parent 5d3ca73b3e
commit bc549ab9a0
4 changed files with 27 additions and 23 deletions

View File

@ -268,7 +268,7 @@ export class FilePreviewScreenComponent
ngOnDetach() {
this._viewerHeaderService.resetCompareButtons();
this._viewerHeaderService.enableLoadAllAnnotations();
this._viewerHeaderService.enableLoadAllAnnotations(); // Reset the button state (since the viewer is reused between files)
super.ngOnDetach();
this._changeRef.markForCheck();
}
@ -690,12 +690,12 @@ export class FilePreviewScreenComponent
.subscribe();
this.addActiveScreenSubscription = this._readableRedactionsService.active$.pipe(switchMap(() => this.updateViewMode())).subscribe();
this.addActiveScreenSubscription = this._viewModeService.viewMode$
this.addActiveScreenSubscription = combineLatest([this._viewModeService.viewMode$, this._documentViewer.loaded$, this.state.file$])
.pipe(
tap(viewMode =>
tap(([viewMode]) =>
viewMode === 'STANDARD' || viewMode === 'TEXT_HIGHLIGHTS'
? this._viewerHeaderService.enableRotationButtons()
: this._viewerHeaderService.disableRotationButtons(),
? this._viewerHeaderService.updateRotationButtons(true)
: this._viewerHeaderService.updateRotationButtons(false),
),
)
.subscribe();

View File

@ -2,7 +2,7 @@ import { Inject, Injectable } from '@angular/core';
import { IHeaderElement, RotationTypes } from '@red/domain';
import { HeaderElements, HeaderElementType } from '../../file-preview/utils/constants';
import { TranslateService } from '@ngx-translate/core';
import { BASE_HREF_FN, BaseHrefFn, IqserPermissionsService } from '@iqser/common-ui';
import { BASE_HREF_FN, BaseHrefFn } from '@iqser/common-ui';
import { TooltipsService } from './tooltips.service';
import { PageRotationService } from './page-rotation.service';
import { PdfViewer } from './pdf-viewer.service';
@ -13,8 +13,8 @@ import { UserPreferenceService } from '@users/user-preference.service';
import { fromEvent, Observable, Subject } from 'rxjs';
import { ViewerEvent, VisibilityChangedEvent } from '../utils/types';
import { ReadableRedactionsService } from './readable-redactions.service';
import { ROLES } from '@users/roles';
import { filter, map, tap } from 'rxjs/operators';
import { PermissionsService } from '@services/permissions.service';
const divider: IHeaderElement = {
type: 'divider',
@ -23,6 +23,7 @@ const divider: IHeaderElement = {
@Injectable()
export class ViewerHeaderService {
readonly events$: Observable<ViewerEvent>;
toggleLoadAnnotations$: Observable<boolean>;
#buttons: Map<HeaderElementType, IHeaderElement>;
readonly #config = new Map<HeaderElementType, boolean>([
[HeaderElements.SHAPE_TOOL_GROUP_BUTTON, true],
@ -38,7 +39,6 @@ export class ViewerHeaderService {
]);
#docBeforeCompare: Blob;
readonly #events$ = new Subject<ViewerEvent>();
toggleLoadAnnotations$: Observable<boolean>;
constructor(
@Inject(BASE_HREF_FN) private readonly _convertPath: BaseHrefFn,
@ -50,7 +50,7 @@ export class ViewerHeaderService {
private readonly _tooltipsService: TooltipsService,
private readonly _readableRedactionsService: ReadableRedactionsService,
private readonly _userPreferenceService: UserPreferenceService,
private readonly _iqserPermissionsService: IqserPermissionsService,
private readonly _permissionsService: PermissionsService,
) {
this.events$ = this.#events$.asObservable();
}
@ -169,11 +169,6 @@ export class ViewerHeaderService {
};
}
#discardRotation(): void {
this._rotationService.discardRotation();
this.disable(ROTATION_ACTION_BUTTONS);
}
private get _rotateRight(): IHeaderElement {
return {
type: 'actionButton',
@ -304,22 +299,27 @@ export class ViewerHeaderService {
});
}
enableRotationButtons(): void {
if (this._iqserPermissionsService.has(ROLES.files.rotatePage)) {
updateRotationButtons(show: boolean): void {
const { dossierId, fileId } = this._pdf;
const file = this._filesMapService.get(dossierId, fileId);
if (show && this._permissionsService.canRotatePage(file)) {
this.enable(ROTATION_BUTTONS);
} else {
this.disable(ROTATION_BUTTONS);
this.#discardRotation();
}
}
disableRotationButtons(): void {
this.disable(ROTATION_BUTTONS);
this.#discardRotation();
}
resetCompareButtons() {
this.disable([HeaderElements.CLOSE_COMPARE_BUTTON]);
this.enable([HeaderElements.COMPARE_BUTTON]);
}
#discardRotation(): void {
this._rotationService.discardRotation();
this.disable(ROTATION_ACTION_BUTTONS);
}
#toggleRotationActionButtons() {
if (this._rotationService.hasRotations) {
this.enable(ROTATION_ACTION_BUTTONS);

View File

@ -349,6 +349,10 @@ export class PermissionsService {
);
}
canRotatePage(file: File) {
return this.isFileAssignee(file) && this._iqserPermissionsService.has(ROLES.files.rotatePage);
}
canDownloadRedactedFile() {
return this._iqserPermissionsService.has(ROLES.files.processDownload);
}

View File

@ -1,7 +1,7 @@
{
"ADMIN_CONTACT_NAME": null,
"ADMIN_CONTACT_URL": null,
"API_URL": "https://dev-04.iqser.cloud/redaction-gateway-v1",
"API_URL": "https://dev-08.iqser.cloud/redaction-gateway-v1",
"APP_NAME": "RedactManager",
"AUTO_READ_TIME": 3,
"BACKEND_APP_VERSION": "4.4.40",
@ -11,7 +11,7 @@
"MAX_RETRIES_ON_SERVER_ERROR": 3,
"OAUTH_CLIENT_ID": "redaction",
"OAUTH_IDP_HINT": null,
"OAUTH_URL": "https://dev-04.iqser.cloud/auth/realms/redaction",
"OAUTH_URL": "https://dev-08.iqser.cloud/auth/realms/redaction",
"RECENT_PERIOD_IN_HOURS": 24,
"SELECTION_MODE": "structural",
"MANUAL_BASE_URL": "https://docs.redactmanager.com/preview",