RED-3224 fix
This commit is contained in:
parent
ebfc9e8926
commit
94839668a4
@ -86,8 +86,8 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.annotations[0]?.typeLabel?.split('.')[1];
|
||||
}
|
||||
|
||||
async ngOnChanges(): Promise<void> {
|
||||
await this._setPermissions();
|
||||
ngOnChanges(): void {
|
||||
this._setPermissions();
|
||||
this._changeRef.markForCheck();
|
||||
}
|
||||
|
||||
@ -130,8 +130,8 @@ export class AnnotationActionsComponent implements OnChanges {
|
||||
return this.annotationActionsService.cancelResize($event, this.annotations[0]);
|
||||
}
|
||||
|
||||
private async _setPermissions() {
|
||||
const dossier = await this._state.dossier;
|
||||
private _setPermissions() {
|
||||
const dossier = this._state.dossier;
|
||||
this.annotationPermissions = AnnotationPermissions.forUser(
|
||||
this._permissionsService.isApprover(dossier),
|
||||
this._userService.currentUser,
|
||||
|
||||
@ -25,7 +25,7 @@ import {
|
||||
shareDistinctLast,
|
||||
shareLast,
|
||||
} from '@iqser/common-ui';
|
||||
import { combineLatest, Observable } from 'rxjs';
|
||||
import { combineLatest, firstValueFrom, Observable } from 'rxjs';
|
||||
import { map, tap } from 'rxjs/operators';
|
||||
import { File } from '@red/domain';
|
||||
import { ExcludedPagesService } from '../../services/excluded-pages.service';
|
||||
@ -252,7 +252,7 @@ export class FileWorkloadComponent {
|
||||
}
|
||||
|
||||
scrollQuickNavLast(): Promise<void> {
|
||||
return this.state.file.then(file => this.selectPage.emit(file.numberOfPages));
|
||||
return firstValueFrom(this.state.file$).then(file => this.selectPage.emit(file.numberOfPages));
|
||||
}
|
||||
|
||||
pageSelectedByClick($event: number): void {
|
||||
|
||||
@ -53,7 +53,7 @@ export class PageExclusionComponent {
|
||||
async excludePagesRange(inputValue: string): Promise<void> {
|
||||
this._loadingService.start();
|
||||
const value = inputValue.replace(/[^0-9-,]/g, '');
|
||||
const file = await this._state.file;
|
||||
const file = this._state.file;
|
||||
try {
|
||||
const pageRanges = value.split(',').map(range => {
|
||||
const splitted = range.split('-');
|
||||
@ -78,7 +78,7 @@ export class PageExclusionComponent {
|
||||
|
||||
async includePagesRange(range: IPageRange): Promise<void> {
|
||||
this._loadingService.start();
|
||||
const file = await this._state.file;
|
||||
const file = this._state.file;
|
||||
const includePages$ = this._reanalysisService.includePages(
|
||||
{
|
||||
pageRanges: [range],
|
||||
|
||||
@ -69,11 +69,11 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy
|
||||
|
||||
ngOnChanges() {
|
||||
this._setReadState();
|
||||
return this.handlePageRead();
|
||||
this.handlePageRead();
|
||||
}
|
||||
|
||||
async toggleReadState() {
|
||||
const file = await this._stateService.file;
|
||||
const file = this._stateService.file;
|
||||
if (this._permissionService.canMarkPagesAsViewed(file)) {
|
||||
if (this.read) {
|
||||
await this._markPageUnread();
|
||||
@ -83,8 +83,8 @@ export class PageIndicatorComponent extends AutoUnsubscribe implements OnDestroy
|
||||
}
|
||||
}
|
||||
|
||||
async handlePageRead() {
|
||||
const file = await this._stateService.file;
|
||||
handlePageRead(): void {
|
||||
const file = this._stateService.file;
|
||||
if (!this._permissionService.canMarkPagesAsViewed(file)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -104,13 +104,13 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
.subscribe();
|
||||
}
|
||||
|
||||
async ngOnChanges(changes: SimpleChanges): Promise<void> {
|
||||
ngOnChanges(changes: SimpleChanges): void {
|
||||
if (!this.instance) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (changes.canPerformActions) {
|
||||
await this._handleCustomActions();
|
||||
this._handleCustomActions();
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
const loadCompareDocument = async () => {
|
||||
this._loadingService.start();
|
||||
const mergedDocument = await pdfNet.PDFDoc.create();
|
||||
const file = await this.stateService.file;
|
||||
const file = this.stateService.file;
|
||||
await loadCompareDocumentWrapper(
|
||||
currentDocument,
|
||||
compareDocument,
|
||||
@ -256,11 +256,11 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
}
|
||||
});
|
||||
|
||||
this.documentViewer.addEventListener('textSelected', async (quads, selectedText, pageNumber: number) => {
|
||||
this.documentViewer.addEventListener('textSelected', (quads, selectedText, pageNumber: number) => {
|
||||
this._selectedText = selectedText;
|
||||
const textActions = [TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE];
|
||||
|
||||
const file = await this.stateService.file;
|
||||
const file = this.stateService.file;
|
||||
|
||||
if (this.viewModeService.isCompare && pageNumber % 2 === 0) {
|
||||
this.instance.UI.disableElements(['textPopup']);
|
||||
@ -391,7 +391,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
]);
|
||||
}
|
||||
|
||||
const actions = this._annotationActionsService.getViewerAvailableActions(this.dossier, annotationWrappers);
|
||||
const actions = this._annotationActionsService.getViewerAvailableActions();
|
||||
this.instance.UI.annotationPopup.add(actions);
|
||||
}
|
||||
|
||||
@ -487,7 +487,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
this.manualAnnotationRequested.emit({ manualRedactionEntry, type });
|
||||
}
|
||||
|
||||
private async _handleCustomActions() {
|
||||
private _handleCustomActions() {
|
||||
this.instance.UI.setToolMode('AnnotationEdit');
|
||||
const textPopupsToToggle = [TextPopups.ADD_REDACTION, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE];
|
||||
const headerItemsToToggle = [
|
||||
@ -496,7 +496,7 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
|
||||
HeaderElements.ROTATE_RIGHT_BUTTON,
|
||||
];
|
||||
|
||||
const isCurrentPageExcluded = this.pdfViewer.isCurrentPageExcluded(await this.stateService.file);
|
||||
const isCurrentPageExcluded = this.pdfViewer.isCurrentPageExcluded(this.stateService.file);
|
||||
|
||||
if (this.canPerformActions && !isCurrentPageExcluded) {
|
||||
try {
|
||||
|
||||
@ -197,7 +197,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
async ngOnAttach(previousRoute: ActivatedRouteSnapshot): Promise<boolean> {
|
||||
const file = await this.state.file;
|
||||
const file = this.state.file;
|
||||
if (!file.canBeOpened) {
|
||||
this._navigateToDossier();
|
||||
return;
|
||||
@ -212,7 +212,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
const file = await this.state.file;
|
||||
const file = this.state.file;
|
||||
|
||||
if (!file) {
|
||||
this._handleDeletedFile();
|
||||
@ -247,8 +247,8 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
}
|
||||
|
||||
openManualAnnotationDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) {
|
||||
return this._ngZone.run(async () => {
|
||||
const file = await this.state.file;
|
||||
return this._ngZone.run(() => {
|
||||
const file = this.state.file;
|
||||
|
||||
this.dialogRef = this._dialogService.openDialog(
|
||||
'manualAnnotation',
|
||||
@ -333,7 +333,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni
|
||||
const pageNumber: string = this._lastPage || this._activatedRoute.snapshot.queryParams.page;
|
||||
if (pageNumber) {
|
||||
setTimeout(async () => {
|
||||
const file = await this.state.file;
|
||||
const file = this.state.file;
|
||||
let page = parseInt(pageNumber, 10);
|
||||
|
||||
if (page < 1 || Number.isNaN(page)) {
|
||||
|
||||
@ -27,7 +27,7 @@ import {
|
||||
AcceptRecommendationDialogComponent,
|
||||
AcceptRecommendationReturnType,
|
||||
} from '../dialogs/accept-recommendation-dialog/accept-recommendation-dialog.component';
|
||||
import { defaultDialogConfig, List } from '@iqser/common-ui';
|
||||
import { defaultDialogConfig, List, ListingService } from '@iqser/common-ui';
|
||||
import { filter } from 'rxjs/operators';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FilePreviewStateService } from './file-preview-state.service';
|
||||
@ -54,6 +54,7 @@ export class AnnotationActionsService {
|
||||
private readonly _dictionariesMapService: DictionariesMapService,
|
||||
private readonly _state: FilePreviewStateService,
|
||||
private readonly _fileDataService: FileDataService,
|
||||
private readonly _listingService: ListingService<AnnotationWrapper>,
|
||||
) {}
|
||||
|
||||
private get _dossier(): Dossier {
|
||||
@ -190,7 +191,10 @@ export class AnnotationActionsService {
|
||||
});
|
||||
}
|
||||
|
||||
getViewerAvailableActions(dossier: Dossier, annotations: AnnotationWrapper[]): Record<string, unknown>[] {
|
||||
getViewerAvailableActions(): Record<string, unknown>[] {
|
||||
const dossier = this._state.dossier;
|
||||
const annotations = this._listingService.selected;
|
||||
|
||||
const availableActions = [];
|
||||
const annotationPermissions = annotations.map(annotation => ({
|
||||
annotation,
|
||||
|
||||
@ -105,7 +105,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper> {
|
||||
|
||||
async annotationsChanged() {
|
||||
this._multiSelectService.deactivate();
|
||||
const file = await this._state.file;
|
||||
const file = this._state.file;
|
||||
const fileReloaded = await firstValueFrom(this._filesService.reload(file.dossierId, file));
|
||||
if (!fileReloaded) {
|
||||
await this.loadAnnotations(file);
|
||||
|
||||
@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router';
|
||||
import { FilesMapService } from '@services/entity-services/files-map.service';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { boolFactory } from '@iqser/common-ui';
|
||||
import { filter, startWith } from 'rxjs/operators';
|
||||
import { filter, startWith, tap } from 'rxjs/operators';
|
||||
import { FileManagementService } from '@services/entity-services/file-management.service';
|
||||
import { DOSSIER_ID, FILE_ID } from '@utils/constants';
|
||||
import { dossiersServiceResolver } from '@services/entity-services/dossiers.service.provider';
|
||||
@ -26,6 +26,9 @@ export class FilePreviewStateService {
|
||||
readonly dossierTemplateId: string;
|
||||
readonly fileId: string;
|
||||
|
||||
dossier: Dossier;
|
||||
file: File;
|
||||
|
||||
constructor(
|
||||
private readonly _fileManagementService: FileManagementService,
|
||||
private readonly _injector: Injector,
|
||||
@ -41,8 +44,8 @@ export class FilePreviewStateService {
|
||||
this.dossierId = _route.snapshot.paramMap.get(DOSSIER_ID);
|
||||
this.dossierTemplateId = dossiersService.find(this.dossierId).dossierTemplateId;
|
||||
|
||||
this.dossier$ = dossiersService.getEntityChanged$(this.dossierId);
|
||||
this.file$ = _filesMapService.watch$(this.dossierId, this.fileId);
|
||||
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.isReadonly$, this.isWritable$] = boolFactory(
|
||||
combineLatest([this.file$, this.dossier$]),
|
||||
([file, dossier]) => !_permissionsService.canPerformAnnotationActions(file, dossier),
|
||||
@ -52,14 +55,6 @@ export class FilePreviewStateService {
|
||||
this.dossierFileChange$ = this.#dossierFilesChange$();
|
||||
}
|
||||
|
||||
get file(): Promise<File> {
|
||||
return firstValueFrom(this.file$);
|
||||
}
|
||||
|
||||
get dossier(): Promise<Dossier> {
|
||||
return firstValueFrom(this.dossier$);
|
||||
}
|
||||
|
||||
get blob(): Promise<Blob> {
|
||||
return firstValueFrom(this.blob$);
|
||||
}
|
||||
|
||||
@ -27,7 +27,7 @@ export class StampService {
|
||||
return;
|
||||
}
|
||||
|
||||
const file = await this._state.file;
|
||||
const file = this._state.file;
|
||||
const allPages = [...Array(file.numberOfPages).keys()].map(page => page + 1);
|
||||
|
||||
try {
|
||||
@ -38,7 +38,7 @@ export class StampService {
|
||||
}
|
||||
|
||||
if (this._viewModeService.isRedacted) {
|
||||
const dossier = await this._state.dossier;
|
||||
const dossier = this._state.dossier;
|
||||
if (dossier.watermarkPreviewEnabled) {
|
||||
await this._stampPreview(pdfDoc, dossier.dossierTemplateId);
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ export class ViewerHeaderConfigService {
|
||||
const blob = await this._stateService.blob;
|
||||
const currentDocument = await pdfNet.PDFDoc.createFromBuffer(await blob.arrayBuffer());
|
||||
|
||||
const filename = (await this._stateService.file).filename ?? 'document.pdf';
|
||||
const filename = this._stateService.file.filename ?? 'document.pdf';
|
||||
this._pdfViewer.instance.UI.loadDocument(currentDocument, { filename });
|
||||
|
||||
this.disable([HeaderElements.CLOSE_COMPARE_BUTTON]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user