From 93fa8c60911d98a344f72f75778caaafe475adf2 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 9 Aug 2023 15:47:35 +0300 Subject: [PATCH] RED-7369 - Remove "Display suggestions in document preview" from user preferences --- .../preferences/preferences.component.html | 6 -- .../preferences/preferences.component.ts | 6 -- .../file-workload/file-workload.component.ts | 3 - .../view-switch/view-switch.component.ts | 5 +- .../file-preview-screen.component.ts | 3 - .../file-preview/file-preview.module.ts | 3 +- .../services/file-data.service.ts | 26 +------ .../services/suggestions.service.ts | 68 ------------------- .../services/annotation-draw.service.ts | 10 +-- .../src/app/users/user-preference.service.ts | 9 --- apps/red-ui/src/assets/i18n/redact/de.json | 2 - apps/red-ui/src/assets/i18n/redact/en.json | 2 - apps/red-ui/src/assets/i18n/scm/de.json | 2 - apps/red-ui/src/assets/i18n/scm/en.json | 2 - 14 files changed, 4 insertions(+), 143 deletions(-) delete mode 100644 apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts 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 589002dfd..6ae529b9d 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 @@ -9,12 +9,6 @@ -
- - {{ 'preferences-screen.form.show-suggestions-in-preview' | translate }} - -
-
{{ 'preferences-screen.form.open-structured-view-by-default' | 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 80b8cddd5..29eafaea8 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 @@ -9,7 +9,6 @@ import { PreferencesKeys, UserPreferenceService } from '@users/user-preference.s interface PreferencesForm { // preferences autoExpandFiltersOnActions: boolean; - displaySuggestionsInPreview: boolean; openScmDialogByDefault: boolean; tableExtractionType: string; // warnings preferences @@ -52,7 +51,6 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { this.form = this._formBuilder.group({ // preferences autoExpandFiltersOnActions: [this.userPreferenceService.getAutoExpandFiltersOnActions()], - displaySuggestionsInPreview: [this.userPreferenceService.getDisplaySuggestionsInPreview()], openScmDialogByDefault: [this.userPreferenceService.getOpenScmDialogByDefault()], tableExtractionType: [this.userPreferenceService.getTableExtractionType()], // warnings preferences @@ -80,9 +78,6 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { if (this.form.controls.autoExpandFiltersOnActions.value !== this.userPreferenceService.getAutoExpandFiltersOnActions()) { await this.userPreferenceService.toggleAutoExpandFiltersOnActions(); } - if (this.form.controls.displaySuggestionsInPreview.value !== this.userPreferenceService.getDisplaySuggestionsInPreview()) { - await this.userPreferenceService.toggleDisplaySuggestionsInPreview(); - } if (this.form.controls.openScmDialogByDefault.value !== this.userPreferenceService.getOpenScmDialogByDefault()) { await this.userPreferenceService.toggleOpenScmDialogByDefault(); } @@ -114,7 +109,6 @@ export class PreferencesComponent extends BaseFormComponent implements OnInit { #patchValues() { this.form.patchValue({ autoExpandFiltersOnActions: this.userPreferenceService.getAutoExpandFiltersOnActions(), - displaySuggestionsInPreview: this.userPreferenceService.getDisplaySuggestionsInPreview(), openScmDialogByDefault: this.userPreferenceService.getOpenScmDialogByDefault(), tableExtractionType: this.userPreferenceService.getTableExtractionType(), unapprovedSuggestionsWarning: this.userPreferenceService.getUnapprovedSuggestionsWarning(), 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 ed379effb..e5b8fdb49 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 @@ -18,7 +18,6 @@ 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 { SuggestionsService } from '../../services/suggestions.service'; import { ListItem } from '@models/file/list-item'; import { PageRotationService } from '../../../pdf-viewer/services/page-rotation.service'; import { getLocalStorageDataByFileId } from '@utils/local-storage'; @@ -66,7 +65,6 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On readonly excludedPagesService: ExcludedPagesService, private readonly _changeDetectorRef: ChangeDetectorRef, private readonly _annotationProcessingService: AnnotationProcessingService, - private readonly _suggestionsService: SuggestionsService, private readonly _pageRotationService: PageRotationService, private readonly _userPreferenceService: UserPreferenceService, ) { @@ -359,7 +357,6 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On if (this.viewModeService.isRedacted()) { annotations = annotations.filter(a => !bool(a.isChangeLogRemoved)); - annotations = this._suggestionsService.filterWorkloadSuggestionsInPreview(annotations); } if (this.#isDocumine && !this.#devMode) { diff --git a/apps/red-ui/src/app/modules/file-preview/components/view-switch/view-switch.component.ts b/apps/red-ui/src/app/modules/file-preview/components/view-switch/view-switch.component.ts index 3df651796..c50fe0467 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/view-switch/view-switch.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/view-switch/view-switch.component.ts @@ -61,10 +61,7 @@ export class ViewSwitchComponent { return this.viewModeService.switchToRedacted(); } - const displaySuggestionsInPreview = this._userPreferenceService.getDisplaySuggestionsInPreview(); - const question = displaySuggestionsInPreview - ? _('unapproved-suggestions.confirmation-dialog.displayed-question') - : _('unapproved-suggestions.confirmation-dialog.not-displayed-question'); + const question = _('unapproved-suggestions.confirmation-dialog.not-displayed-question'); const data: IConfirmationDialogData = { title: _('unapproved-suggestions.confirmation-dialog.title'), question: question, 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 845ddce7b..fce0b7098 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 @@ -67,7 +67,6 @@ import { PdfProxyService } from './services/pdf-proxy.service'; import { ConfigService } from '@services/config.service'; import { ReadableRedactionsService } from '../pdf-viewer/services/readable-redactions.service'; import { Roles } from '@users/roles'; -import { SuggestionsService } from './services/suggestions.service'; import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { copyLocalStorageFiltersValues, FilterService, NestedFilter, processFilters } from '@iqser/common-ui/lib/filtering'; @@ -143,7 +142,6 @@ export class FilePreviewScreenComponent private readonly _fileManagementService: FileManagementService, private readonly _readableRedactionsService: ReadableRedactionsService, private readonly _helpModeService: HelpModeService, - private readonly _suggestionsService: SuggestionsService, private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _dialog: MatDialog, private readonly _tablesService: TablesService, @@ -270,7 +268,6 @@ export class FilePreviewScreenComponent this._readableRedactionsService.setAnnotationsOpacity(redactions); this._annotationManager.show(redactions); this._annotationManager.hide(nonRedactionEntries); - this._suggestionsService.hideSuggestionsInPreview(redactions); break; } diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts b/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts index 6a4a66491..0de813009 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview.module.ts @@ -55,7 +55,6 @@ import { ImportRedactionsDialogComponent } from './dialogs/import-redactions-dia import { DocumentUnloadedGuard } from './services/document-unloaded.guard'; import { FilePreviewRightContainerComponent } from './components/right-container/file-preview-right-container.component'; import { ReadonlyBannerComponent } from './components/readonly-banner/readonly-banner.component'; -import { SuggestionsService } from './services/suggestions.service'; import { PagesComponent } from './components/pages/pages.component'; import { SharedModule } from '@shared/shared.module'; import { SharedDossiersModule } from '../shared-dossiers/shared-dossiers.module'; @@ -158,6 +157,6 @@ const components = [ TenantPipe, LogPipe, ], - providers: [FilePreviewDialogService, ManualRedactionService, DocumentUnloadedGuard, SuggestionsService, TablesService], + providers: [FilePreviewDialogService, ManualRedactionService, DocumentUnloadedGuard, TablesService], }) export class FilePreviewModule {} diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index aeec3258d..54491be42 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -27,7 +27,6 @@ import { MultiSelectService } from './multi-select.service'; import { FilesService } from '@services/files/files.service'; import { DefaultColorsService } from '@services/entity-services/default-colors.service'; import { DictionaryService } from '@services/entity-services/dictionary.service'; -import { SuggestionsService } from './suggestions.service'; import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service'; import { toObservable } from '@angular/core/rxjs-interop'; @@ -62,7 +61,6 @@ export class FileDataService extends EntitiesService !a.isFalsePositive); this.#annotations.set(annotations); @@ -178,28 +176,6 @@ export class FileDataService extends EntitiesService { - const redactionLogCopy: IRedactionLog = JSON.parse(JSON.stringify(redactionLog)); - const redactionLogEntries: IRedactionLogEntry[] = []; - - for (const entry of redactionLogCopy.redactionLogEntry) { - const lastChange = entry.manualChanges.at(-1); - if ( - lastChange?.annotationStatus === LogEntryStatuses.REQUESTED && - !entry.hint && - !entry.reason.includes('requested to force hint') - ) { - entry.manualChanges.pop(); - entry.reason = null; - redactionLogEntries.push(entry); - } - } - - redactionLogCopy.redactionLogEntry = redactionLogEntries; - const annotations = await this.#convertData(redactionLogCopy); - this._suggestionsService.removedRedactions = annotations.filter(a => !a.isSkipped); - } - async #convertData(redactionLog: IRedactionLog) { if (!redactionLog.redactionLogEntry) { return []; diff --git a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts deleted file mode 100644 index 3730ae6e0..000000000 --- a/apps/red-ui/src/app/modules/file-preview/services/suggestions.service.ts +++ /dev/null @@ -1,68 +0,0 @@ -import { Injectable } from '@angular/core'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { bool } from '@iqser/common-ui/lib/utils'; -import { Core } from '@pdftron/webviewer'; -import { REDAnnotationManager } from '../../pdf-viewer/services/annotation-manager.service'; -import { UserPreferenceService } from '@users/user-preference.service'; -import { ReadableRedactionsService } from '../../pdf-viewer/services/readable-redactions.service'; -import Annotation = Core.Annotations.Annotation; - -@Injectable() -export class SuggestionsService { - #removedRedactions: AnnotationWrapper[] = []; - - constructor( - private readonly _annotationManager: REDAnnotationManager, - private readonly _userPreferenceService: UserPreferenceService, - private readonly _readableRedactionsService: ReadableRedactionsService, - ) {} - - set removedRedactions(removedRedactions: AnnotationWrapper[]) { - this.#removedRedactions = removedRedactions; - } - - hideSuggestionsInPreview(annotations: Annotation[]): void { - if (this._readableRedactionsService.active) { - if (this._userPreferenceService.getDisplaySuggestionsInPreview()) { - const suggestionsRemove = annotations.filter( - a => bool(a.getCustomData('suggestionRemove')) || bool(a.getCustomData('suggestionForceHint')), - ); - this._annotationManager.hide(suggestionsRemove); - return; - } - } - const suggestionsToHide = annotations.filter( - a => - (bool(a.getCustomData('suggestionAdd')) && !bool(a.getCustomData('suggestionAddToFalsePositive'))) || - bool(a.getCustomData('notSignatureImage')), - ); - annotations.forEach(a => { - if (bool(a.getCustomData('suggestionRemove'))) { - const foundRedaction = this.#removedRedactions.find(r => r.id === a.Id); - if (!foundRedaction) { - suggestionsToHide.push(a); - } - } - }); - this._annotationManager.hide(suggestionsToHide); - } - - filterWorkloadSuggestionsInPreview(annotations: AnnotationWrapper[]): AnnotationWrapper[] { - if (this._readableRedactionsService.active) { - if (this._userPreferenceService.getDisplaySuggestionsInPreview()) { - return annotations.filter(a => !a.isSuggestionRemove && !a.isSuggestionForceHint); - } - } - - annotations = annotations.filter(a => (!a.isSuggestionAdd || a.isSuggestionAddToFalsePositive) && !a.isNotSignatureImage); - for (let i = annotations.length - 1; i >= 0; i--) { - const foundRemovedRedaction = this.#removedRedactions.find(r => r.id === annotations[i].id); - if (foundRemovedRedaction) { - annotations[i] = foundRemovedRedaction; - } else if (annotations[i].isSuggestionRemove) { - annotations.splice(i, 1); - } - } - return annotations; - } -} 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 854fdf3e3..152a051e0 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 @@ -200,15 +200,7 @@ export class AnnotationDrawService { annotation.setCustomData('changeLogRemoved', String(annotationWrapper.isChangeLogRemoved)); annotation.setCustomData('opacity', String(annotation.Opacity)); - const dictionaryRequestColor = - annotationWrapper.isSuggestionAddDictionary || (annotationWrapper.isSuggestionResize && annotationWrapper.isModifyDictionary); - - const redactionColor = - annotationWrapper.isSuggestion && this._userPreferenceService.getDisplaySuggestionsInPreview() - ? dictionaryRequestColor - ? this._defaultColorsService.getColor(dossierTemplateId, 'dictionaryRequestColor') - : this._defaultColorsService.getColor(dossierTemplateId, 'requestAddColor') - : this._defaultColorsService.getColor(dossierTemplateId, 'previewColor'); + const redactionColor = this._defaultColorsService.getColor(dossierTemplateId, 'previewColor'); annotation.setCustomData('redactionColor', String(redactionColor)); annotation.setCustomData('annotationColor', String(annotationWrapper.color)); 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 0a78f8e9a..3e9a3a996 100644 --- a/apps/red-ui/src/app/users/user-preference.service.ts +++ b/apps/red-ui/src/app/users/user-preference.service.ts @@ -64,15 +64,6 @@ export class UserPreferenceService extends IqserUserPreferenceService { await this.save(PreferencesKeys.openScmDialogByDefault, nextValue); } - getDisplaySuggestionsInPreview(): boolean { - return this._getAttribute(PreferencesKeys.displaySuggestionsInPreview, 'false') === 'true'; - } - - async toggleDisplaySuggestionsInPreview(): Promise { - const nextValue = (!this.getDisplaySuggestionsInPreview()).toString(); - await this.save(PreferencesKeys.displaySuggestionsInPreview, nextValue); - } - getUnapprovedSuggestionsWarning(): boolean { return this._getAttribute(PreferencesKeys.unapprovedSuggestionsWarning, 'false') === 'true'; } diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index d521c75fc..925fc0472 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1951,7 +1951,6 @@ "auto-expand-filters-on-action": "", "load-all-annotations-warning": "", "open-structured-view-by-default": "", - "show-suggestions-in-preview": "", "table-extraction-type": "", "unapproved-suggestions-warning": "" }, @@ -2345,7 +2344,6 @@ "checkbox-text": "", "confirmation-text": "", "deny-text": "", - "displayed-question": "", "not-displayed-question": "", "success-confirmation-text": "", "title": "" diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index da566c31c..f6a4b4f31 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1951,7 +1951,6 @@ "auto-expand-filters-on-action": "Auto-expand filters on my actions", "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", "open-structured-view-by-default": "Display structured component management modal by default", - "show-suggestions-in-preview": "Display suggestions in document preview", "table-extraction-type": "Table extraction type", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" }, @@ -2345,7 +2344,6 @@ "checkbox-text": "Do not show this message again", "confirmation-text": "Continue to Preview", "deny-text": "Cancel", - "displayed-question": "The document contains unapproved suggestions, which are marked with their respective color.", "not-displayed-question": "The document contains unapproved suggestions that are not included in the preview.", "success-confirmation-text": "Prompts about unapproved suggestions were disabled. Change this preference in account settings.", "title": "Document with unapproved suggestions" diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index d252a0fa5..55180cc1a 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1951,7 +1951,6 @@ "auto-expand-filters-on-action": "", "load-all-annotations-warning": "", "open-structured-view-by-default": "", - "show-suggestions-in-preview": "", "table-extraction-type": "", "unapproved-suggestions-warning": "" }, @@ -2345,7 +2344,6 @@ "checkbox-text": "", "confirmation-text": "", "deny-text": "", - "displayed-question": "", "not-displayed-question": "", "success-confirmation-text": "", "title": "" diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index d97d7cd16..7ea454797 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1951,7 +1951,6 @@ "auto-expand-filters-on-action": "Auto expand filters on my actions", "load-all-annotations-warning": "Warning regarding loading all annotations at once in file preview", "open-structured-view-by-default": "Display Component View by default when opening a document", - "show-suggestions-in-preview": "Display suggestions in document preview", "table-extraction-type": "Table extraction type", "unapproved-suggestions-warning": "Warning regarding unapproved suggestions in document Preview mode" }, @@ -2345,7 +2344,6 @@ "checkbox-text": "Do not show this message again", "confirmation-text": "Continue to Preview", "deny-text": "Cancel", - "displayed-question": "The document contains unapproved suggestions, which are marked with their respective color.", "not-displayed-question": "The document contains unapproved suggestions that are not included in the preview.", "success-confirmation-text": "Prompts about unapproved suggestions were disabled. Change this preference in account settings.", "title": "Document with unapproved suggestions"