From 403d3e849f566f74465947db070839cb5bd53050 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Wed, 28 Jun 2023 18:30:52 +0300 Subject: [PATCH] RED-6774 - fixed comments --- .../annotation-actions.component.ts | 1 - .../manual-annotation-dialog.component.ts | 2 +- .../redact-text-dialog.component.ts | 14 ++++---- .../file-preview-screen.component.ts | 13 +++++--- .../services/manual-redaction.service.ts | 23 +++---------- .../services/pdf-proxy.service.ts | 32 ++++++------------- .../modules/file-preview/utils/constants.ts | 2 -- .../app/modules/pdf-viewer/utils/constants.ts | 5 +-- .../entity-services/dictionary.service.ts | 2 +- apps/red-ui/src/assets/i18n/redact/de.json | 8 ++--- apps/red-ui/src/assets/i18n/redact/en.json | 8 ++--- apps/red-ui/src/assets/i18n/scm/de.json | 8 ++--- apps/red-ui/src/assets/i18n/scm/en.json | 8 ++--- 13 files changed, 43 insertions(+), 83 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.ts index 366813407..7300fb5a7 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-actions/annotation-actions.component.ts @@ -10,7 +10,6 @@ import { HelpModeService, IqserPermissionsService } from '@iqser/common-ui'; import { ViewModeService } from '../../services/view-mode.service'; import { REDAnnotationManager } from '../../../pdf-viewer/services/annotation-manager.service'; import { Roles } from '@users/roles'; -import { RemoveRedactionPermissions } from '../../dialogs/remove-redaction-dialog/remove-redaction-dialog.component'; export const AnnotationButtonTypes = { dark: 'dark', diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 783741417..5a2ab66d7 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -58,7 +58,7 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme } get title() { - return this._manualRedactionService.getTitle(this.data.manualRedactionEntryWrapper.type, this._dossier); + return this._manualRedactionService.getTitle(this.data.manualRedactionEntryWrapper.type); } get isRectangle() { diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts index d9ab15bdc..10bf712eb 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { DetailsRadioOption, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; -import { Dictionary, Dossier, DossierTemplate, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain'; +import { Dictionary, Dossier, File, IAddRedactionRequest, IManualRedactionEntry, SuperTypes } from '@red/domain'; import { FormBuilder, UntypedFormGroup } from '@angular/forms'; import { Roles } from '@users/roles'; import { firstValueFrom } from 'rxjs'; @@ -19,7 +19,6 @@ import { RedactTextOption, RedactTextOptions } from './redact-text-options'; import { tap } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { IqserDialogComponent } from '../../../../../../../../libs/common-ui/src/lib/dialog/iqser-dialog-component.directive'; -import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -28,6 +27,7 @@ interface RedactTextData { manualRedactionEntryWrapper: ManualRedactionEntryWrapper; dossierId: string; file: File; + applyToAllDossiers: boolean; } interface DialogResult { @@ -54,7 +54,7 @@ export class RedactTextDialogComponent form!: UntypedFormGroup; #manualRedactionTypeExists = true; - #applyToAllDossiers = true; + #applyToAllDossiers: boolean; readonly #translations = redactTextTranslations; readonly #dossier: Dossier; @@ -65,13 +65,13 @@ export class RedactTextDialogComponent private readonly _activeDossiersService: ActiveDossiersService, private readonly _dictionaryService: DictionaryService, private readonly _iqserPermissionsService: IqserPermissionsService, - private readonly _dossierTemplatesService: DossierTemplatesService, private readonly _formBuilder: FormBuilder, ) { super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); this.type = this.data.manualRedactionEntryWrapper.type; this.#hint = this.type === ManualRedactionEntryTypes.HINT; + this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.#manualRedactionTypeExists = this._dictionaryService.hasManualType(this.#dossier.dossierTemplateId); this.options = this.#options(); @@ -205,7 +205,7 @@ export class RedactTextDialogComponent value: RedactTextOptions.IN_DOSSIER, extraOption: { label: this.#translations[this.type].inDossier.extraOptionLabel, - checked: true, + checked: this.data.applyToAllDossiers ?? true, }, }); } @@ -213,8 +213,8 @@ export class RedactTextDialogComponent } #resetValues() { - this.#applyToAllDossiers = true; - this.options[1].extraOption.checked = true; + this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; + this.options[1].extraOption.checked = this.#applyToAllDossiers; if (this.dictionaryRequest) { this.form.get('reason').setValue(null); this.form.get('dictionary').setValue(null); 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 7c0e5b32e..74ffedca4 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 @@ -39,7 +39,7 @@ import { ManualRedactionEntryWrapper } from '@models/file/manual-redaction-entry import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationDrawService } from '../pdf-viewer/services/annotation-draw.service'; import { AnnotationProcessingService } from './services/annotation-processing.service'; -import { Dictionary, File, IManualRedactionEntry, ViewModes } from '@red/domain'; +import { Dictionary, File, ViewModes } from '@red/domain'; import { PermissionsService } from '@services/permissions.service'; import { combineLatest, firstValueFrom, of, pairwise } from 'rxjs'; import { PreferencesKeys, UserPreferenceService } from '@users/user-preference.service'; @@ -78,7 +78,7 @@ import { IqserDialog } from '../../../../../../libs/common-ui/src/lib/dialog/iqs import { RedactTextDialogComponent } from './dialogs/redact-text-dialog/redact-text-dialog.component'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; -const textActions = [TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]; +const textActions = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE]; @Component({ templateUrl: './file-preview-screen.component.html', @@ -373,9 +373,15 @@ export class FilePreviewScreenComponent async openRedactTextDialog(manualRedactionEntryWrapper: ManualRedactionEntryWrapper) { const file = this.state.file(); + const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId); const result = await this._iqserDialog .openDefault(RedactTextDialogComponent, { - data: { manualRedactionEntryWrapper, dossierId: this.dossierId, file }, + data: { + manualRedactionEntryWrapper, + dossierId: this.dossierId, + file, + applyToAllDossiers: dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault, + }, }) .result(); @@ -388,7 +394,6 @@ export class FilePreviewScreenComponent ); if (result.applyToAllDossiers !== null) { - const dossierTemplate = this._dossierTemplatesService.find(this.state.dossierTemplateId); const { ...body } = dossierTemplate; body.applyDictionaryUpdatesToAllDossiersByDefault = result.applyToAllDossiers; await this._dossierTemplatesService.createOrUpdate(body); diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 0ef6fc812..3bc7d2dc9 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -156,25 +156,12 @@ export class ManualRedactionService extends GenericService { ); } - getTitle(type: ManualRedactionEntryType, dossier: Dossier) { - if (this._permissionsService.isApprover(dossier)) { - switch (type) { - case 'DICTIONARY': - return _('manual-annotation.dialog.header.dictionary'); - case 'FALSE_POSITIVE': - return _('manual-annotation.dialog.header.false-positive'); - case 'REDACTION': - return _('manual-annotation.dialog.header.redaction'); - } - } - + getTitle(type: ManualRedactionEntryType) { switch (type) { - case 'DICTIONARY': - return _('manual-annotation.dialog.header.request-dictionary'); - case 'FALSE_POSITIVE': - return _('manual-annotation.dialog.header.request-false-positive'); - case 'REDACTION': - return _('manual-annotation.dialog.header.request-redaction'); + case 'REDACT': + return _('manual-annotation.dialog.header.redact'); + case 'HINT': + return _('manual-annotation.dialog.header.hint'); } } diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index c92108a62..e7f53ac51 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -1,5 +1,5 @@ import { computed, effect, inject, Injectable, NgZone } from '@angular/core'; -import { IHeaderElement, IManualRedactionEntry } from '@red/domain'; +import { IHeaderElement, IManualRedactionEntry, User } from '@red/domain'; import { Core } from '@pdftron/webviewer'; import { TranslateService } from '@ngx-translate/core'; import { @@ -9,7 +9,7 @@ import { } from '@models/file/manual-redaction-entry.wrapper'; import { AnnotationDrawService } from '../../pdf-viewer/services/annotation-draw.service'; import { UserPreferenceService } from '@users/user-preference.service'; -import { BASE_HREF_FN, IqserPermissionsService, isJustOne, shareDistinctLast } from '@iqser/common-ui'; +import { BASE_HREF_FN, getCurrentUser, IqserPermissionsService, isJustOne, shareDistinctLast } from '@iqser/common-ui'; import { toPosition } from '../utils/pdf-calculation.utils'; import { MultiSelectService } from './multi-select.service'; import { FilePreviewStateService } from './file-preview-state.service'; @@ -43,6 +43,7 @@ export class PdfProxyService { readonly annotationSelected$ = this.#annotationSelected$; readonly manualAnnotationRequested$ = new Subject(); readonly redactTextRequested$ = new Subject(); + readonly currentUser = getCurrentUser(); readonly pageChanged$ = this._pdf.pageChanged$.pipe( tap(() => this.#handleCustomActions()), tap(() => this._pdf.resetAnnotationActions()), @@ -157,37 +158,22 @@ export class PdfProxyService { }); } - if (this._iqserPermissionsService.has(Roles.redactions.write) || this._iqserPermissionsService.has(Roles.redactions.request)) { + const isApprover = this._permissionsService.isApprover(this._state.dossier()); + if (this._iqserPermissionsService.has(Roles.redactions.write) && isApprover) { popups.push({ type: 'actionButton', dataElement: TextPopups.REDACT_TEXT, img: this.#addRedactionIcon, + title: this.#getTitle(ManualRedactionEntryTypes.REDACT), onClick: () => this._ngZone.run(() => this.#redactText(ManualRedactionEntryTypes.REDACT)), }); popups.push({ type: 'actionButton', dataElement: TextPopups.ADD_HINT, img: this.#addHintIcon, + title: this.#getTitle(ManualRedactionEntryTypes.HINT), onClick: () => this._ngZone.run(() => this.#redactText(ManualRedactionEntryTypes.HINT)), }); - - // popups.push({ - // type: 'actionButton', - // dataElement: TextPopups.ADD_REDACTION, - // img: this.#addRedactionIcon, - // title: this.#getTitle(ManualRedactionEntryTypes.REDACTION), - // onClick: () => this._ngZone.run(() => this._addManualRedactionOfType(ManualRedactionEntryTypes.REDACTION)), - // }); - // - // if (!this._iqserPermissionsService.has(Roles.getRss)) { - // popups.push({ - // type: 'actionButton', - // dataElement: TextPopups.ADD_DICTIONARY, - // img: this.#addDictIcon, - // title: this.#getTitle(ManualRedactionEntryTypes.DICTIONARY), - // onClick: () => this._ngZone.run(() => this._addManualRedactionOfType(ManualRedactionEntryTypes.DICTIONARY)), - // }); - // } } } @@ -254,7 +240,7 @@ export class PdfProxyService { this._viewerHeaderService.enable(HEADER_ITEMS_TO_TOGGLE); if (this._documentViewer.selectedText().length > 2) { - this._pdf.enable([TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]); + this._pdf.enable([TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_FALSE_POSITIVE]); } } @@ -394,6 +380,6 @@ export class PdfProxyService { } #getTitle(type: ManualRedactionEntryType) { - return this._translateService.instant(this._manualRedactionService.getTitle(type, this._state.dossier())); + return this._translateService.instant(this._manualRedactionService.getTitle(type)); } } diff --git a/apps/red-ui/src/app/modules/file-preview/utils/constants.ts b/apps/red-ui/src/app/modules/file-preview/utils/constants.ts index e8b3d7878..2d2dc7cfd 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/constants.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/constants.ts @@ -31,8 +31,6 @@ export type HeaderElementType = ValuesOf; export const TextPopups = { REDACT_TEXT: 'redact-text', ADD_HINT: 'add-hint', - ADD_REDACTION: 'add-redaction', - ADD_DICTIONARY: 'add-dictionary', ADD_RECTANGLE: 'add-rectangle', ADD_FALSE_POSITIVE: 'add-false-positive', } as const; diff --git a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts index e40fd8b43..18de282ff 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/utils/constants.ts @@ -5,13 +5,14 @@ import { HeaderElements, TextPopups } from '../../file-preview/utils/constants'; export const ROTATION_BUTTONS = [HeaderElements.ROTATE_LEFT_BUTTON, HeaderElements.ROTATE_RIGHT_BUTTON]; export const ROTATION_ACTION_BUTTONS = [HeaderElements.APPLY_ROTATION, HeaderElements.DISCARD_ROTATION]; -export const TEXT_POPUPS_TO_TOGGLE = [TextPopups.ADD_REDACTION, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE]; +export const TEXT_POPUPS_TO_TOGGLE = [TextPopups.REDACT_TEXT, TextPopups.ADD_HINT, TextPopups.ADD_RECTANGLE, TextPopups.ADD_FALSE_POSITIVE]; export const HEADER_ITEMS_TO_TOGGLE = [HeaderElements.SHAPE_TOOL_GROUP_BUTTON]; export const ALLOWED_ACTIONS_WHEN_PAGE_EXCLUDED: string[] = [ TextPopups.ADD_RECTANGLE, - TextPopups.ADD_REDACTION, + TextPopups.REDACT_TEXT, + TextPopups.ADD_HINT, HeaderElements.SHAPE_TOOL_GROUP_BUTTON, ]; diff --git a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts index 32f63b54f..46277ea1c 100644 --- a/apps/red-ui/src/app/services/entity-services/dictionary.service.ts +++ b/apps/red-ui/src/app/services/entity-services/dictionary.service.ts @@ -150,7 +150,7 @@ export class DictionaryService extends EntitiesService this._dictionariesMapService.get(dossierTemplateId).forEach((d: Dictionary) => { if (!hintTypes) { - if (!d.hint) { + if (!d.virtual && !d.hint && !d.systemManaged) { possibleDictionaries.push(d); } } else if (d.hint) { diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 1e00f5941..d4be71ef3 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -1716,14 +1716,10 @@ }, "error": "", "header": { - "dictionary": "Zum Wörterbuch hinzufügen", - "false-positive": "Als Falsch-Positiv definieren", "force-hint": "Hinweis erzwingen", "force-redaction": "Schwärzung erzwingen", - "redaction": "Schwärzung", - "request-dictionary": "Neuen Wörterbucheintrag vorschlagen", - "request-false-positive": "Als Falsch-Positiv vorschlagen", - "request-redaction": "Schwärzung vorschlagen" + "hint": "", + "redact": "" } } }, diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 53efcf790..9d112bf8e 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -1716,14 +1716,10 @@ }, "error": "Error! Invalid page selection", "header": { - "dictionary": "Add to dictionary", - "false-positive": "Set false positive", "force-hint": "Force Hint", "force-redaction": "Force Redaction", - "redaction": "Redaction", - "request-dictionary": "Request add to dictionary", - "request-false-positive": "Request false positive", - "request-redaction": "Request Redaction" + "hint": "Add hint", + "redact": "Redact" } } }, diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 98eabdfc6..6aea01327 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -1716,14 +1716,10 @@ }, "error": "", "header": { - "dictionary": "Zum Wörterbuch hinzufügen", - "false-positive": "Als Falsch-Positiv definieren", "force-hint": "Hinweis erzwingen", "force-redaction": "Schwärzung erzwingen", - "redaction": "Schwärzung", - "request-dictionary": "Neuen Wörterbucheintrag vorschlagen", - "request-false-positive": "Als Falsch-Positiv vorschlagen", - "request-redaction": "Schwärzung vorschlagen" + "hint": "", + "redact": "" } } }, diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 175b23540..da1726ee8 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -1716,14 +1716,10 @@ }, "error": "Error! Invalid page selection", "header": { - "dictionary": "Add to dictionary", - "false-positive": "Set false positive", "force-hint": "Force Hint", "force-redaction": "Force Component", - "redaction": "Component", - "request-dictionary": "Request add to dictionary", - "request-false-positive": "Request false positive", - "request-redaction": "Request Component" + "hint": "Add hint", + "redact": "Redact" } } },