diff --git a/apps/red-ui/src/app/modules/app-config/app-config.service.ts b/apps/red-ui/src/app/modules/app-config/app-config.service.ts index cf68cbd88..b5520c68d 100644 --- a/apps/red-ui/src/app/modules/app-config/app-config.service.ts +++ b/apps/red-ui/src/app/modules/app-config/app-config.service.ts @@ -16,6 +16,7 @@ export enum AppConfigKey { ADMIN_CONTACT_NAME = 'ADMIN_CONTACT_NAME', ADMIN_CONTACT_URL = 'ADMIN_CONTACT_URL', AUTO_READ_TIME = 'AUTO_READ_TIME', + SELECTION_MODE = 'SELECTION_MODE', MAX_FILE_SIZE_MB = 'MAX_FILE_SIZE_MB', RECENT_PERIOD_IN_HOURS = 'RECENT_PERIOD_IN_HOURS', DELETE_RETENTION_HOURS = 'DELETE_RETENTION_HOURS', diff --git a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts index 39e403ab9..1214932e8 100644 --- a/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts +++ b/apps/red-ui/src/app/modules/dossier/components/pdf-viewer/pdf-viewer.component.ts @@ -25,7 +25,8 @@ import { AnnotationActionsService } from '../../services/annotation-actions.serv import { UserPreferenceService } from '@services/user-preference.service'; import { translateQuads } from '@utils/pdf-coordinates'; import { BASE_HREF } from '../../../../tokens'; -import Tool = Tools.Tool; +import { AppConfigKey, AppConfigService } from '../../../app-config/app-config.service'; +import TextTool = Tools.TextTool; @Component({ selector: 'redaction-pdf-viewer', @@ -49,7 +50,6 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { @ViewChild('viewer', { static: true }) viewer: ElementRef; instance: WebViewerInstance; private _selectedText = ''; - private _defaultTool: Tool; private readonly _allowedKeyboardShortcuts = ['+', '-', 'p', 'r', 'Escape']; constructor( @@ -59,7 +59,8 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { private readonly _ngZone: NgZone, private readonly _userPreferenceService: UserPreferenceService, private readonly _annotationDrawService: AnnotationDrawService, - private readonly _annotationActionsService: AnnotationActionsService + private readonly _annotationActionsService: AnnotationActionsService, + private readonly _appConfigService: AppConfigService ) {} ngOnInit() { @@ -102,18 +103,15 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { this.deselectAllAnnotations(); } - const annotationsFromViewer = annotations.map(ann => - this.instance.annotManager.getAnnotationById(ann.id) - ); + const annotationsFromViewer = annotations.map(ann => this._getAnnotationById(ann.id)); this.instance.annotManager.selectAnnotations(annotationsFromViewer); this.navigateToPage(annotations[0].pageNumber); this.instance.annotManager.jumpToAnnotation(annotationsFromViewer[0]); } deselectAnnotations(annotations: AnnotationWrapper[]) { - this.instance.annotManager.deselectAnnotations( - annotations.map(ann => this.instance.annotManager.getAnnotationById(ann.id)) - ); + const ann = annotations.map(a => this._getAnnotationById(a.id)); + this.instance.annotManager.deselectAnnotations(ann); } navigateToPage(pageNumber: number) { @@ -133,6 +131,10 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { this.instance.docViewer.getDisplayModeManager().setDisplayMode(instanceDisplayMode); } + private _getAnnotationById(id: string): Annotations.Annotation { + return this.instance.annotManager.getAnnotationById(id); + } + private _loadViewer() { WebViewer( { @@ -143,6 +145,7 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { this.viewer.nativeElement ).then(instance => { this.instance = instance; + this._setSelectionMode(); this._disableElements(); this._disableHotkeys(); this._configureTextPopup(); @@ -158,7 +161,6 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { this._toggleRectangleAnnotationAction( annotations.length === 1 && annotations[0].ReadOnly ); - // this.annotationSelected.emit(annotations.map((a) => a.Id)); } }); @@ -228,6 +230,11 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { }); } + private _setSelectionMode(): void { + const textTool = (this.instance.Tools.TextTool) as TextTool; + textTool.SELECTION_MODE = this._appConfigService.getConfig(AppConfigKey.SELECTION_MODE); + } + private _toggleRectangleAnnotationAction(readonly: boolean) { if (!readonly) { this.instance.enableElements(['add-rectangle']); @@ -537,15 +544,14 @@ export class PdfViewerComponent implements OnInit, AfterViewInit, OnChanges { } } - private _documentLoaded() { + private _documentLoaded(): void { this._ngZone.run(() => { - this._defaultTool = this.instance.getToolMode(); this.viewerReady.emit(this.instance); this.setInitialViewerState(); }); } - private _disableHotkeys() { + private _disableHotkeys(): void { this.instance.hotkeys.off('CTRL+SHIFT+EQUAL'); this.instance.hotkeys.off('COMMAND+SHIFT+EQUAL'); this.instance.hotkeys.off('CTRL+SHIFT+MINUS'); 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 bc013adf2..cc13c7d41 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 @@ -225,7 +225,7 @@ [canPerformActions]="canPerformAnnotationActions" [fileData]="displayData" [fileStatus]="appStateService.activeFile" - [multiSelectActive]="!!fileWorkloadComponent?.multiSelectActive" + [multiSelectActive]="multiSelectActive" [shouldDeselectAnnotationsOnPageChange]="shouldDeselectAnnotationsOnPageChange" > 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 fea21bbd1..7a3ac3694 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 @@ -75,7 +75,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, hideSkipped = false; displayPDFViewer = false; viewDocumentInfo = false; - @ViewChild(FileWorkloadComponent) fileWorkloadComponent: FileWorkloadComponent; + private _instance: WebViewerInstance; private _lastPage: string; @ViewChild('fileWorkloadComponent') private _workloadComponent: FileWorkloadComponent; @@ -112,13 +112,13 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, }); } - get singleUsersSelectOptions() { + get singleUsersSelectOptions(): string[] { return this.appStateService.activeFile?.isUnderApproval ? this.appStateService.activeDossier.approverIds : this.appStateService.activeDossier.memberIds; } - get assignTooltip() { + get assignTooltip(): string { return this.appStateService.activeFile.isUnderApproval ? 'dossier-overview.assign-approver' : 'dossier-overview.assign-reviewer'; @@ -172,6 +172,10 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, return this.appStateService.activeFileId; } + get multiSelectActive(): boolean { + return !!this._workloadComponent?.multiSelectActive; + } + updateViewMode() { const annotations = this._getAnnotations(a => a.getCustomData('redacto-manager')); const redactions = annotations.filter(a => a.getCustomData('redaction')); @@ -294,9 +298,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, handleAnnotationSelected(annotationIds: string[]) { this.selectedAnnotations = annotationIds - .map(annotationId => - this.annotations.find(annotationWrapper => annotationWrapper.id === annotationId) - ) + .map(id => this.annotations.find(annotationWrapper => annotationWrapper.id === id)) .filter(ann => ann !== undefined); if (this.selectedAnnotations.length > 1) { this._workloadComponent.multiSelectActive = true; @@ -391,7 +393,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, viewerPageChanged($event: any) { if (typeof $event === 'number') { this._scrollViews(); - if (!this.fileWorkloadComponent.multiSelectActive) { + if (!this._workloadComponent.multiSelectActive) { this.shouldDeselectAnnotationsOnPageChange = true; } diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 49ce0c5cf..d7dbcb685 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -10,6 +10,7 @@ "LICENSE_START": "01-01-2021", "LICENSE_END": "31-12-2021", "LICENSE_PAGE_COUNT": 1000000, + "SELECTION_MODE": "structural", "RECENT_PERIOD_IN_HOURS": 24, "MAX_FILE_SIZE_MB": 100, "DELETE_RETENTION_HOURS": 96 diff --git a/docker/red-ui/docker-entrypoint.sh b/docker/red-ui/docker-entrypoint.sh index ac66ed5d3..665850dc0 100755 --- a/docker/red-ui/docker-entrypoint.sh +++ b/docker/red-ui/docker-entrypoint.sh @@ -8,6 +8,7 @@ OAUTH_IDP_HINT="${OAUTH_IDP_HINT:-}" ADMIN_CONTACT_NAME="${ADMIN_CONTACT_NAME:-}" ADMIN_CONTACT_URL="${ADMIN_CONTACT_URL:-}" AUTO_READ_TIME="${AUTO_READ_TIME:-1.5}" +SELECTION_MODE="${SELECTION_MODE:-structural}" MAX_FILE_SIZE_MB="${MAX_FILE_SIZE_MB:-50}" DELETE_RETENTION_HOURS="${DELETE_RETENTION_HOURS:-96}" RECENT_PERIOD_IN_HOURS="${RECENT_PERIOD_IN_HOURS:-24}" @@ -35,6 +36,7 @@ echo '{ "LICENSE_EMAIL":"'"$LICENSE_EMAIL"'", "APP_NAME":"'"$APP_NAME"'", "AUTO_READ_TIME":'"$AUTO_READ_TIME"', + "SELECTION_MODE":"'"$SELECTION_MODE"'", "MAX_FILE_SIZE_MB":"'"$MAX_FILE_SIZE_MB"'", "RECENT_PERIOD_IN_HOURS":"'"RECENT_PERIOD_IN_HOURS"'", "DELETE_RETENTION_HOURS":"'"$DELETE_RETENTION_HOURS"'",