From 509db85b897cb518d65eb375aa7753628d06210d Mon Sep 17 00:00:00 2001 From: Timo Bejan Date: Tue, 11 Jan 2022 17:23:08 +0200 Subject: [PATCH] cleanup and i18n --- .../file-preview-screen.component.html | 4 ++-- .../file-preview-screen.component.ts | 21 ++++++++++++------- apps/red-ui/src/assets/i18n/en.json | 8 +++---- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html index ddcaa05a7..9e859f0f8 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.html @@ -72,7 +72,7 @@ (pageChanged)="viewerPageChanged($event)" (viewerReady)="viewerReady($event)" *ngIf="displayPdfViewer" - [annotations]="annotations" + [annotations]="visibleAnnotations" [canPerformActions]="canPerformAnnotationActions$ | async" [class.hidden]="!ready" [dossier]="dossier" @@ -107,7 +107,7 @@ [(shouldDeselectAnnotationsOnPageChange)]="shouldDeselectAnnotationsOnPageChange" [activeViewerPage]="activeViewerPage" [annotationActionsTemplate]="annotationActionsTemplate" - [annotations]="annotations" + [annotations]="visibleAnnotations" [dialogRef]="dialogRef" [file]="file" [hideSkipped]="hideSkipped" diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index 23550fee4..89d93bed1 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -132,10 +132,14 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni }); } - get annotations(): AnnotationWrapper[] { + get visibleAnnotations(): AnnotationWrapper[] { return this.fileData ? this.fileData.getVisibleAnnotations(this.viewModeService.viewMode) : []; } + get allAnnotations(): AnnotationWrapper[] { + return this.fileData ? this.fileData.allAnnotations : []; + } + get activeViewer(): WebViewerInstance { return this._instance; } @@ -244,7 +248,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } const processStartTime = new Date().getTime(); - const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this.annotations); + const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this.visibleAnnotations); const primaryFilters = this._filterService.getGroup('primaryFilters')?.filters; this._filterService.addFilterGroup({ slug: 'primaryFilters', @@ -265,7 +269,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni handleAnnotationSelected(annotationIds: string[]) { // TODO: use includes() here this.selectedAnnotations = annotationIds - .map(id => this.annotations.find(annotationWrapper => annotationWrapper.id === id)) + .map(id => this.visibleAnnotations.find(annotationWrapper => annotationWrapper.id === id)) .filter(ann => ann !== undefined); if (this.selectedAnnotations.length > 1) { this.multiSelectService.activate(); @@ -552,11 +556,12 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni private async _reloadAnnotations() { this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise(); - await this._cleanupAndRedrawAnnotations(this.annotations); + this._instance.Core.annotationManager.deleteAnnotations(this._instance.Core.annotationManager.getAnnotationsList()); + await this._cleanupAndRedrawAnnotations(); } private async _reloadAnnotationsForPage(page: number) { - const currentPageAnnotations = this.annotations.filter(a => a.pageNumber === page); + const currentPageAnnotations = this.visibleAnnotations.filter(a => a.pageNumber === page); this.fileData.file = await this._filesService.reload(this.dossierId, this.fileId).toPromise(); this.fileData.redactionLog = await this._fileDownloadService.loadRedactionLogFor(this.dossierId, this.fileId).toPromise(); @@ -565,7 +570,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } private async _cleanupAndRedrawAnnotations( - annotationsToDelete: AnnotationWrapper[], + annotationsToDelete?: AnnotationWrapper[], newAnnotationsFilter?: (annotation: AnnotationWrapper) => boolean, ) { this.rebuildFilters(); @@ -575,7 +580,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni annotationsToDelete?.forEach(annotation => { this._findAndDeleteAnnotation(annotation.id); }); - const newAnnotations = newAnnotationsFilter ? this.annotations.filter(newAnnotationsFilter) : this.annotations; + const newAnnotations = newAnnotationsFilter ? this.allAnnotations.filter(newAnnotationsFilter) : this.allAnnotations; this._handleDeltaAnnotationFilters(annotationsToDelete ?? [], newAnnotations); await this._redrawAnnotations(newAnnotations); console.log( @@ -584,7 +589,7 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } } - private _redrawAnnotations(annotations = this.fileData.allAnnotations) { + private _redrawAnnotations(annotations = this.allAnnotations) { return this._annotationDrawService.drawAnnotations( this._instance, annotations, diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 535aba2ac..0b40d292e 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -355,10 +355,10 @@ "to": "to" }, "auth-error": { - "heading": "Your user doesn't have the required RED-* roles to access this application. Please contact your admin for access!", - "heading-with-link": "Your user doesn't have the required RED-* roles to access this application. Please contact your admin for access!", - "heading-with-name": "Your user doesn't have the required RED-* roles to access this application. Please contact {adminName} for access!", - "heading-with-name-and-link": "Your user doesn't have the required RED-* roles to access this application. Please contact {adminName} for access!", + "heading": "Your user is successfully logged in but has no role assigned yet. Please contact your RedactManager administrator to assign appropriate roles.", + "heading-with-link": "Your user is successfully logged in but has no role assigned yet. Please contact your RedactManager administrator to assign appropriate roles!", + "heading-with-name": "Your user is successfully logged in but has no role assigned yet. Please contact {adminName} to assign appropriate roles.", + "heading-with-name-and-link": "Your user is successfully logged in but has no role assigned yet. Please contact {adminName} to assign appropriate roles.", "logout": "Logout" }, "by": "by",