RED-8375: backport watermark and border fix.

This commit is contained in:
Nicoleta Panaghiu 2024-01-26 17:21:46 +02:00
parent 65cdc056a8
commit 19fffc3102
2 changed files with 24 additions and 7 deletions

View File

@ -597,7 +597,18 @@ export class FilePreviewScreenComponent
.pipe(tap(() => this._handleDeletedFile()))
.subscribe();
const viewModeChanged$ = this._viewModeService.viewMode$.pipe(tap(() => this._stampService.stampPDF().then()));
const viewModeChanged$ = combineLatest([
this._documentViewer.loaded$,
this._viewModeService.viewMode$,
this.state.updateExcludedPagesStyle$,
]).pipe(
map(([loaded, viewMode, shouldUpdate]) => {
if (loaded) {
this._stampService.stampPDF().then();
}
return viewMode;
}),
);
this.addActiveScreenSubscription = combineLatest([viewModeChanged$, this.state.file$])
.pipe(
@ -606,9 +617,9 @@ export class FilePreviewScreenComponent
)
.subscribe();
this.addActiveScreenSubscription = this._documentViewer.pageComplete$.subscribe(() => {
this._setExcludedPageStyles();
});
this.addActiveScreenSubscription = combineLatest([this._documentViewer.pageComplete$, this.state.updateExcludedPagesStyle$])
.pipe(tap(() => this._setExcludedPageStyles()))
.subscribe();
this.addActiveScreenSubscription = this._documentViewer.keyUp$.subscribe($event => {
this.handleKeyEvent($event);

View File

@ -1,5 +1,5 @@
import { Injectable, Injector } from '@angular/core';
import { combineLatest, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
import { BehaviorSubject, combineLatest, firstValueFrom, from, merge, Observable, of, pairwise, Subject, switchMap } from 'rxjs';
import { Dictionary, Dossier, DOSSIER_ID, DOSSIER_TEMPLATE_ID, File, FILE_ID } from '@red/domain';
import { Router } from '@angular/router';
import { FilesMapService } from '@services/files/files-map.service';
@ -37,6 +37,7 @@ export class FilePreviewStateService {
readonly dossierFileChange$: Observable<File[]>;
readonly isReadonly$: Observable<boolean>;
readonly isWritable$: Observable<boolean>;
readonly updateExcludedPagesStyle$: Observable<number[]>;
readonly dossierId: string = getParam(DOSSIER_ID);
readonly dossierTemplateId: string = getParam(DOSSIER_TEMPLATE_ID);
@ -46,12 +47,13 @@ export class FilePreviewStateService {
file: File;
#dossierDictionary: Dictionary;
readonly #reloadBlob$ = new Subject();
readonly #updateExcludedPagesStyle$ = new BehaviorSubject([]);
constructor(
router: Router,
filesMapService: FilesMapService,
private readonly _injector: Injector,
permissionsService: PermissionsService,
private readonly _injector: Injector,
private readonly _filesService: FilesService,
private readonly _dossiersService: DossiersService,
private readonly _fileManagementService: FileManagementService,
@ -61,8 +63,12 @@ export class FilePreviewStateService {
private readonly _loadingService: LoadingService,
) {
const dossiersService = dossiersServiceResolver(_injector, router);
this.updateExcludedPagesStyle$ = this.#updateExcludedPagesStyle$.asObservable();
this.dossier$ = dossiersService.getEntityChanged$(this.dossierId).pipe(tap(dossier => (this.dossier = dossier)));
this.file$ = filesMapService.watch$(this.dossierId, this.fileId).pipe(tap(file => (this.file = file)));
this.file$ = filesMapService.watch$(this.dossierId, this.fileId).pipe(
tap(file => (this.file = file)),
tap(file => this.#updateExcludedPagesStyle$.next(file.excludedPages)),
);
[this.isReadonly$, this.isWritable$] = boolFactory(
combineLatest([this.file$, this.dossier$]),
([file, dossier]) => !permissionsService.canPerformAnnotationActions(file, dossier),