From 8586e66fb12a730679e38db1de947d4f6a22ee8d Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 1 Nov 2022 15:22:57 +0200 Subject: [PATCH] RED-5401 - Admin option to show suggestions in preview --- .../screens/preferences/preferences.component.html | 5 +++++ .../account/screens/preferences/preferences.component.ts | 5 +++++ .../components/file-workload/file-workload.component.ts | 7 +++++++ .../file-preview/file-preview-screen.component.ts | 5 +++++ .../pdf-viewer/services/annotation-draw.service.ts | 1 + apps/red-ui/src/app/users/user-preference.service.ts | 9 +++++++++ apps/red-ui/src/assets/i18n/de.json | 3 ++- apps/red-ui/src/assets/i18n/en.json | 3 ++- 8 files changed, 36 insertions(+), 2 deletions(-) diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html index 93e976b9e..a2dbe2f8b 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.html @@ -6,6 +6,11 @@ {{ 'preferences-screen.form.auto-expand-filters-on-action' | translate }} +
+ + {{ 'preferences-screen.form.show-suggestions-in-preview' | translate }} + +
diff --git a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts index f5b74db0e..700239dfa 100644 --- a/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts +++ b/apps/red-ui/src/app/modules/account/screens/preferences/preferences.component.ts @@ -5,6 +5,7 @@ import { BaseFormComponent } from '@iqser/common-ui'; interface PreferencesForm { autoExpandFiltersOnActions: boolean; + showSuggestionsInPreview: boolean; [k: string]: any; } @@ -25,6 +26,7 @@ export class PreferencesComponent extends BaseFormComponent { super(); this.form = this._formBuilder.group({ autoExpandFiltersOnActions: [this.userPreferenceService.getAutoExpandFiltersOnActions()], + showSuggestionsInPreview: [this.userPreferenceService.getShowSuggestionsInPreview()], }); this.initialFormValue = this.form.getRawValue(); } @@ -33,6 +35,9 @@ export class PreferencesComponent extends BaseFormComponent { if (this.form.controls.autoExpandFiltersOnActions.value !== this.userPreferenceService.getAutoExpandFiltersOnActions()) { await this.userPreferenceService.toggleAutoExpandFiltersOnActions(); } + if (this.form.controls.showSuggestionsInPreview.value !== this.userPreferenceService.getShowSuggestionsInPreview()) { + await this.userPreferenceService.toggleShowSuggestionsInPreview(); + } await this.userPreferenceService.reload(); this.form.patchValue({ autoExpandFiltersOnActions: this.userPreferenceService.getAutoExpandFiltersOnActions() }); this.initialFormValue = this.form.getRawValue(); diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index fb872bdf5..9cbfc954c 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -39,6 +39,7 @@ import { PdfViewer } from '../../../pdf-viewer/services/pdf-viewer.service'; import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service'; import { AnnotationsListingService } from '../../services/annotations-listing.service'; import { REDDocumentViewer } from '../../../pdf-viewer/services/document-viewer.service'; +import { UserPreferenceService } from '@users/user-preference.service'; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -83,6 +84,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy readonly excludedPagesService: ExcludedPagesService, private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _annotationProcessingService: AnnotationProcessingService, + private readonly _viewModeService: ViewModeService, + private readonly _userPreferencesService: UserPreferenceService, ) { super(); @@ -380,6 +383,10 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy return; } + if (this._viewModeService.isRedacted && !this._userPreferencesService.getShowSuggestionsInPreview()) { + annotations = annotations.filter(a => !a.isSuggestion); + } + this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary); const pagesThatDisplayAnnotations = [...this.displayedAnnotations.keys()]; const enabledFilters = this.filterService.enabledFlatFilters; diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 5cd780217..9b6942b1b 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -250,6 +250,11 @@ export class FilePreviewScreenComponent this._annotationManager.show(redactions); this._annotationManager.hide(nonRedactionEntries); + + if (!this.userPreferenceService.getShowSuggestionsInPreview()) { + const suggestions = redactions.filter(a => bool(a.getCustomData('suggestion'))); + this._annotationManager.hide(suggestions); + } break; } case ViewModes.TEXT_HIGHLIGHTS: { diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts index adc892f72..aee2b013f 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-draw.service.ts @@ -152,6 +152,7 @@ export class AnnotationDrawService { this._annotationManager.isHidden(annotationWrapper.annotationId); annotation.setCustomData('redact-manager', 'true'); annotation.setCustomData('redaction', String(annotationWrapper.previewAnnotation)); + annotation.setCustomData('suggestion', String(annotationWrapper.isSuggestion)); annotation.setCustomData('skipped', String(annotationWrapper.isSkipped)); annotation.setCustomData('changeLog', String(annotationWrapper.isChangeLogEntry)); annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved)); diff --git a/apps/red-ui/src/app/users/user-preference.service.ts b/apps/red-ui/src/app/users/user-preference.service.ts index b2e142e9b..8cd346f26 100644 --- a/apps/red-ui/src/app/users/user-preference.service.ts +++ b/apps/red-ui/src/app/users/user-preference.service.ts @@ -7,6 +7,7 @@ const KEYS = { lastDossierTemplate: 'Last-Dossier-Template', filesListingMode: 'Files-Listing-Mode', autoExpandFiltersOnActions: 'Auto-Expand-Filters-On-Actions', + showSuggestionsInPreview: 'Show-Suggestions-In-Preview', } as const; @Injectable({ @@ -50,6 +51,14 @@ export class UserPreferenceService extends IqserUserPreferenceService { await this._save(KEYS.autoExpandFiltersOnActions, nextValue); } + getShowSuggestionsInPreview(): boolean { + return this._getAttribute(KEYS.showSuggestionsInPreview, 'false') === 'true'; + } + async toggleShowSuggestionsInPreview(): Promise { + const nexValue = (!this.getShowSuggestionsInPreview()).toString(); + await this._save(KEYS.showSuggestionsInPreview, nexValue); + } + getFilesListingMode(): ListingMode { return this._getAttribute(KEYS.filesListingMode) as ListingMode; } diff --git a/apps/red-ui/src/assets/i18n/de.json b/apps/red-ui/src/assets/i18n/de.json index 0d86c999a..a9cce2132 100644 --- a/apps/red-ui/src/assets/i18n/de.json +++ b/apps/red-ui/src/assets/i18n/de.json @@ -1798,7 +1798,8 @@ "save": "" }, "form": { - "auto-expand-filters-on-action": "" + "auto-expand-filters-on-action": "", + "show-suggestions-in-preview": "" }, "label": "", "title": "" diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 68b8c5953..aa15ab0da 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1799,7 +1799,8 @@ "save": "Save changes" }, "form": { - "auto-expand-filters-on-action": "Auto expand filters on my actions" + "auto-expand-filters-on-action": "Auto expand filters on my actions", + "show-suggestions-in-preview": "Show suggestions in preview" }, "label": "Preferences", "title": "Edit preferences"