RED-7369 - Remove "Display suggestions in document preview" from user preferences

This commit is contained in:
Valentin Mihai 2023-08-09 15:47:35 +03:00
parent e251c29af8
commit 93fa8c6091
14 changed files with 4 additions and 143 deletions

View File

@ -9,12 +9,6 @@
</mat-slide-toggle>
</div>
<div class="iqser-input-group">
<mat-slide-toggle color="primary" formControlName="displaySuggestionsInPreview">
{{ 'preferences-screen.form.show-suggestions-in-preview' | translate }}
</mat-slide-toggle>
</div>
<div *ngIf="config.IS_DOCUMINE" class="iqser-input-group">
<mat-slide-toggle color="primary" formControlName="openStructuredComponentManagementDialogByDefault">
{{ 'preferences-screen.form.open-structured-view-by-default' | translate }}

View File

@ -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(),

View File

@ -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) {

View File

@ -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,

View File

@ -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;
}

View File

@ -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 {}

View File

@ -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<AnnotationWrapper, Annotati
private readonly _permissionsService: PermissionsService,
private readonly _redactionLogService: RedactionLogService,
private readonly _earmarksService: EarmarksService,
private readonly _suggestionsService: SuggestionsService,
private readonly _multiSelectService: MultiSelectService,
private readonly _filesService: FilesService,
private readonly _toaster: Toaster,
@ -136,7 +134,7 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
const redactionLog = await this._redactionLogService.getRedactionLog(this._state.dossierId, this._state.fileId);
this._logger.info('[REDACTION_LOG] Redaction log loaded', redactionLog);
let [annotations] = await Promise.all([this.#convertData(redactionLog), this.#buildRemovedRedactions(redactionLog)]);
let annotations = await this.#convertData(redactionLog);
this.#checkMissingTypes();
annotations = this._userPreferenceService.areDevFeaturesEnabled ? annotations : annotations.filter(a => !a.isFalsePositive);
this.#annotations.set(annotations);
@ -178,28 +176,6 @@ export class FileDataService extends EntitiesService<AnnotationWrapper, Annotati
});
}
async #buildRemovedRedactions(redactionLog: IRedactionLog): Promise<void> {
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 [];

View File

@ -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;
}
}

View File

@ -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));

View File

@ -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<void> {
const nextValue = (!this.getDisplaySuggestionsInPreview()).toString();
await this.save(PreferencesKeys.displaySuggestionsInPreview, nextValue);
}
getUnapprovedSuggestionsWarning(): boolean {
return this._getAttribute(PreferencesKeys.unapprovedSuggestionsWarning, 'false') === 'true';
}

View File

@ -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": ""

View File

@ -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 <a href={settingsUrl} target=_self class=\"toast-link\">account settings</a>.",
"title": "Document with unapproved suggestions"

View File

@ -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": ""

View File

@ -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 <a href={settingsUrl} target=_self class=\"toast-link\">account settings</a>.",
"title": "Document with unapproved suggestions"