From d9160157866a09989c0454c5c4c9b38ecadbb6b6 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 24 Jul 2023 04:50:51 +0300 Subject: [PATCH 1/7] RED-7155 - Resize redaction/hint dialogs --- .../add-hint-dialog.component.html | 4 +- .../add-hint-dialog.component.scss | 8 -- .../add-hint-dialog.component.ts | 3 +- .../add-annotation-dialog.component.html | 4 +- .../add-annotation-dialog.component.scss | 8 -- .../add-annotation-dialog.component.ts | 3 +- .../remove-annotation-dialog.component.scss | 0 .../remove-annotation-dialog.component.ts | 1 - .../redact-text-dialog.component.html | 4 +- .../redact-text-dialog.component.scss | 8 -- .../redact-text-dialog.component.ts | 1 - .../remove-redaction-dialog.component.scss | 0 .../remove-redaction-dialog.component.ts | 1 - .../resize-annotation-dialog.component.html | 31 -------- .../resize-annotation-dialog.component.ts | 39 ---------- .../resize-redaction-dialog.component.html | 55 +++++++++++++ .../resize-redaction-dialog.component.ts | 77 +++++++++++++++++++ .../file-preview/file-preview.module.ts | 4 +- .../services/annotation-actions.service.ts | 28 ++++--- .../services/file-preview-dialog.service.ts | 5 -- .../file-preview/utils/dialog-options.ts | 47 +++++++++++ .../file-preview/utils/dialog-types.ts | 13 ++++ .../resize-redaction-translations.ts | 14 ++++ apps/red-ui/src/assets/config/config.json | 2 +- apps/red-ui/src/assets/i18n/redact/de.json | 36 ++++++--- apps/red-ui/src/assets/i18n/redact/en.json | 36 ++++++--- apps/red-ui/src/assets/i18n/scm/de.json | 36 ++++++--- apps/red-ui/src/assets/i18n/scm/en.json | 36 ++++++--- 28 files changed, 339 insertions(+), 165 deletions(-) delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.scss delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.scss delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.scss delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.scss delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.scss delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html delete mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts create mode 100644 apps/red-ui/src/app/translations/resize-redaction-translations.ts diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.html index b51e471cb..3d4c41376 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.html @@ -2,9 +2,9 @@
-
+
- + {{ form.get('selectedText').value }}
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.scss deleted file mode 100644 index 0bc0b2eb8..000000000 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -label { - font-weight: bold; - padding-bottom: 8px; -} - -iqser-details-radio { - padding-top: 20px; -} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts index 84fb04590..28c252c09 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/add-hint-dialog/add-hint-dialog.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { DetailsRadioOption, IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain'; import { FormBuilder, UntypedFormGroup } from '@angular/forms'; import { Roles } from '@users/roles'; import { JustificationsService } from '@services/entity-services/justifications.service'; @@ -14,7 +14,6 @@ import { AddHintData, AddHintResult } from '../../utils/dialog-types'; @Component({ templateUrl: './add-hint-dialog.component.html', - styleUrls: ['./add-hint-dialog.component.scss'], }) export class AddHintDialogComponent extends IqserDialogComponent implements OnInit { readonly roles = Roles; diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.html index e08222606..61dd8955e 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.html @@ -2,9 +2,9 @@
-
+
- + {{ form.get('selectedText').value }}
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.scss deleted file mode 100644 index 0bc0b2eb8..000000000 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -label { - font-weight: bold; - padding-bottom: 8px; -} - -iqser-details-radio { - padding-top: 20px; -} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.ts index 946b3e521..c3d9f3d86 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/add-annotation-dialog/add-annotation-dialog.component.ts @@ -1,6 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { IconButtonTypes, IqserPermissionsService } from '@iqser/common-ui'; -import { Dictionary, Dossier, IAddRedactionRequest, SuperTypes } from '@red/domain'; +import { Dictionary, Dossier, IAddRedactionRequest } from '@red/domain'; import { FormBuilder, UntypedFormGroup } from '@angular/forms'; import { Roles } from '@users/roles'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; @@ -10,7 +10,6 @@ import { AddAnnotationData, AddAnnotationResult } from '../../../utils/dialog-ty @Component({ templateUrl: './add-annotation-dialog.component.html', - styleUrls: ['./add-annotation-dialog.component.scss'], }) export class AddAnnotationDialogComponent extends IqserDialogComponent diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.ts index 38360893b..155a21324 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component.ts @@ -8,7 +8,6 @@ import { getRemoveRedactionOptions, RemoveAnnotationOption, RemoveAnnotationOpti @Component({ templateUrl: './remove-annotation-dialog.component.html', - styleUrls: ['./remove-annotation-dialog.component.scss'], }) export class RemoveAnnotationDialogComponent extends IqserDialogComponent< RemoveAnnotationDialogComponent, diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html index 5c4700cd9..833b087ee 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.html @@ -2,9 +2,9 @@
-
+
- + {{ form.get('selectedText').value }}
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.scss deleted file mode 100644 index 0bc0b2eb8..000000000 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/redact-text-dialog/redact-text-dialog.component.scss +++ /dev/null @@ -1,8 +0,0 @@ -label { - font-weight: bold; - padding-bottom: 8px; -} - -iqser-details-radio { - padding-top: 20px; -} 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 d30c5586a..eb8a98f73 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 @@ -16,7 +16,6 @@ import { RedactTextData, RedactTextResult } from '../../utils/dialog-types'; @Component({ templateUrl: './redact-text-dialog.component.html', - styleUrls: ['./redact-text-dialog.component.scss'], }) export class RedactTextDialogComponent extends IqserDialogComponent diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.scss b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.scss deleted file mode 100644 index e69de29bb..000000000 diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts index cc1c0d386..27e37a39d 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/remove-redaction-dialog/remove-redaction-dialog.component.ts @@ -10,7 +10,6 @@ import { getRemoveRedactionOptions, RemoveRedactionOption } from '../../utils/di @Component({ templateUrl: './remove-redaction-dialog.component.html', - styleUrls: ['./remove-redaction-dialog.component.scss'], }) export class RemoveRedactionDialogComponent extends IqserDialogComponent< RemoveRedactionDialogComponent, diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html deleted file mode 100644 index 280456868..000000000 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.html +++ /dev/null @@ -1,31 +0,0 @@ -
- -
- -
-
- - -
- -
- - -
-
- -
- - -
-
- - - -
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts deleted file mode 100644 index 4596a3b48..000000000 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-annotation-dialog/resize-annotation-dialog.component.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { Component, Inject, OnInit } from '@angular/core'; -import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; -import { BaseDialogComponent } from '@iqser/common-ui'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; - -@Component({ - templateUrl: './resize-annotation-dialog.component.html', -}) -export class ResizeAnnotationDialogComponent extends BaseDialogComponent implements OnInit { - constructor( - protected readonly _dialogRef: MatDialogRef, - @Inject(MAT_DIALOG_DATA) private readonly _data: { annotation: AnnotationWrapper; text?: string }, - ) { - super(_dialogRef); - } - - get disabled(): boolean { - return !this.valid; - } - - get text(): string { - return this._data.text; - } - - ngOnInit() { - const controlsConfig = { comment: [null] }; - - if (this._data.annotation.isModifyDictionary) { - controlsConfig['updateDictionary'] = [false]; - } - - this.form = this._formBuilder.group(controlsConfig); - this.initialFormValue = this.form.getRawValue(); - } - - save() { - this._dialogRef.close(this.form.getRawValue()); - } -} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html new file mode 100644 index 000000000..0f12aab16 --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html @@ -0,0 +1,55 @@ +
+
+
+ +
+
+ + {{ redaction.value }} +
+ +
+ + {{ data.text }} +
+ + + + +
+ + + + + {{ displayedDictionaryLabel }} + + {{ redaction.entity.label }} + + + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+ + +
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts new file mode 100644 index 000000000..80654e73f --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts @@ -0,0 +1,77 @@ +import { Component, OnInit } from '@angular/core'; +import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermissionsService } from '@iqser/common-ui'; +import { ResizeRedactionData, ResizeRedactionResult } from '../../utils/dialog-types'; +import { FormBuilder, FormControl, UntypedFormGroup } from '@angular/forms'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { getRedactOrHintOptions, getResizeRedactionOptions, RedactOrHintOption, ResizeRedactionOption } from '../../utils/dialog-options'; +import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; +import { Dictionary, Dossier } from '@red/domain'; +import { Roles } from '@users/roles'; +import { DictionaryService } from '@services/entity-services/dictionary.service'; + +@Component({ + templateUrl: './resize-redaction-dialog.component.html', +}) +export class ResizeRedactionDialogComponent + extends IqserDialogComponent + implements OnInit +{ + readonly roles = Roles; + readonly iconButtonTypes = IconButtonTypes; + readonly options: DetailsRadioOption[]; + + dictionaries: Dictionary[] = []; + redaction: AnnotationWrapper; + form!: UntypedFormGroup; + + #applyToAllDossiers: boolean; + + readonly #dossier: Dossier; + readonly #isRss = this._iqserPermissionsService.has(Roles.getRss); + + constructor( + private readonly _activeDossiersService: ActiveDossiersService, + private readonly _iqserPermissionsService: IqserPermissionsService, + private readonly _dictionaryService: DictionaryService, + private readonly _formBuilder: FormBuilder, + ) { + super(); + this.#dossier = _activeDossiersService.find(this.data.dossierId); + this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; + this.redaction = this.data.redaction; + this.options = getResizeRedactionOptions(this.#dossier, this.#isRss, false, this.#applyToAllDossiers, this.data.isApprover); + this.form = this.#getForm(); + } + + get displayedDictionaryLabel() { + const dictType = this.form.get('dictionary').value; + if (dictType) { + return this.dictionaries.find(d => d.type === dictType)?.label ?? null; + } + return null; + } + + get disabled(): boolean { + return !this.valid; + } + + get text(): string { + return this.data.text; + } + + async ngOnInit() { + this.dictionaries = this._dictionaryService.getRedactionTypes(this.#dossier.dossierTemplateId); + } + + #getForm(): UntypedFormGroup { + return this._formBuilder.group({ + comment: [null], + dictionary: new FormControl({ value: this.redaction.entity.type, disabled: true }), + option: [this.options[0]], + }); + } + + save(): void { + this.dialogRef.close(this.form.getRawValue()); + } +} 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 4a617762c..7ce983bf6 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 @@ -42,7 +42,7 @@ import { HighlightsSeparatorComponent } from './components/highlights-separator/ import { PendingChangesGuard } from '@guards/can-deactivate.guard'; import { ManualAnnotationDialogComponent } from './dialogs/manual-redaction-dialog/manual-annotation-dialog.component'; import { ForceAnnotationDialogComponent } from './dialogs/force-redaction-dialog/force-annotation-dialog.component'; -import { ResizeAnnotationDialogComponent } from './dialogs/resize-annotation-dialog/resize-annotation-dialog.component'; +import { ResizeRedactionDialogComponent } from './dialogs/resize-redaction-dialog/resize-redaction-dialog.component'; import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component'; import { RecategorizeImageDialogComponent } from './dialogs/recategorize-image-dialog/recategorize-image-dialog.component'; import { HighlightActionDialogComponent } from './dialogs/highlight-action-dialog/highlight-action-dialog.component'; @@ -82,7 +82,7 @@ const routes: IqserRoutes = [ const dialogs = [ ManualAnnotationDialogComponent, ForceAnnotationDialogComponent, - ResizeAnnotationDialogComponent, + ResizeRedactionDialogComponent, ChangeLegalBasisDialogComponent, RecategorizeImageDialogComponent, HighlightActionDialogComponent, diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index e3f608ec9..c262c1d3b 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -34,15 +34,10 @@ import { IqserDialog } from '@common-ui/dialog/iqser-dialog.service'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { isJustOne, List } from '@iqser/common-ui/lib/utils'; import { PermissionsService } from '@services/permissions.service'; -import { - RedactTextData, - RemoveAnnotationResult, - RemoveRedactionData, - RemoveRedactionPermissions, - RemoveRedactionResult, -} from '../utils/dialog-types'; +import { RemoveRedactionData, RemoveRedactionPermissions, RemoveRedactionResult, ResizeRedactionData } from '../utils/dialog-types'; import { RemoveRedactionOptions } from '../utils/dialog-options'; import { RemoveAnnotationDialogComponent } from '../dialogs/docu-mine/remove-annotation-dialog/remove-annotation-dialog.component'; +import { ResizeRedactionDialogComponent } from '../dialogs/resize-redaction-dialog/resize-redaction-dialog.component'; @Injectable() export class AnnotationActionsService { @@ -221,11 +216,17 @@ export class AnnotationActionsService { return this.convertRecommendationToAnnotation([recommendation]); } + const dossier = this._state.dossier(); + const isImageText = annotation.isImage ? 'Image' : textAndPositions.text; const text = annotation.rectangle ? annotation.value : isImageText; - const data = { annotation, text }; + const isApprover = this._permissionsService.isApprover(dossier); - this._dialogService.openDialog('resizeAnnotation', data, (result: { comment: string; updateDictionary: boolean }) => { + const data = { redaction: annotation, text, isApprover, dossierId: dossier.dossierId }; + + const result = await this.#getResizeRedactionDialog(data).result(); + + if (result) { const resizeRequest: IResizeRequest = { annotationId: annotation.id, comment: result.comment, @@ -239,7 +240,7 @@ export class AnnotationActionsService { const { fileId, dossierId } = this._state; const request = this._manualRedactionService.resizeOrSuggestResize([resizeRequest], dossierId, fileId); this.#processObsAndEmit(request); - }); + } } async cancelResize(annotationWrapper: AnnotationWrapper) { @@ -415,4 +416,11 @@ export class AnnotationActionsService { } return this._iqserDialog.openDefault(RemoveRedactionDialogComponent, { data }); } + + #getResizeRedactionDialog(data: ResizeRedactionData) { + // if (this.#isDocumine) { + // return this._iqserDialog.openDefault(RemoveAnnotationDialogComponent, { data }); + // } + return this._iqserDialog.openDefault(ResizeRedactionDialogComponent, { data }); + } } diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts index d25300155..cc65e1cee 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-preview-dialog.service.ts @@ -6,7 +6,6 @@ import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dia import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component'; import { RecategorizeImageDialogComponent } from '../dialogs/recategorize-image-dialog/recategorize-image-dialog.component'; import { ConfirmationDialogComponent, DialogConfig, DialogService } from '@iqser/common-ui'; -import { ResizeAnnotationDialogComponent } from '../dialogs/resize-annotation-dialog/resize-annotation-dialog.component'; import { HighlightActionDialogComponent } from '../dialogs/highlight-action-dialog/highlight-action-dialog.component'; import { RssDialogComponent } from '../dialogs/rss-dialog/rss-dialog.component'; @@ -16,7 +15,6 @@ type DialogType = | 'rss' | 'recategorizeImage' | 'changeLegalBasis' - | 'resizeAnnotation' | 'forceAnnotation' | 'manualAnnotation' | 'highlightAction'; @@ -38,9 +36,6 @@ export class FilePreviewDialogService extends DialogService { changeLegalBasis: { component: ChangeLegalBasisDialogComponent, }, - resizeAnnotation: { - component: ResizeAnnotationDialogComponent, - }, forceAnnotation: { component: ForceAnnotationDialogComponent, }, diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 6a4774e68..59601f10b 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -5,6 +5,7 @@ import { Dossier } from '@red/domain'; import { removeRedactionTranslations } from '@translations/remove-redaction-translations'; import { RemoveRedactionData } from './dialog-types'; import { removeAnnotationTranslations } from '@translations/remove-annotation-translations'; +import { resizeRedactionTranslations } from '@translations/resize-redaction-translations'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -16,6 +17,7 @@ export const RedactOrHintOptions = { } as const; export type RedactOrHintOption = keyof typeof RedactOrHintOptions; +export type ResizeRedactionOption = RedactOrHintOption; export const RemoveRedactionOptions = { ONLY_HERE: 'ONLY_HERE', @@ -60,6 +62,51 @@ export const getRedactOrHintOptions = ( return options; }; +export const getResizeRedactionOptions = ( + dossier: Dossier, + isRss: boolean, + hint: boolean, + applyToAllDossiers: boolean, + isApprover: boolean, +): DetailsRadioOption[] => { + const translations = resizeRedactionTranslations; + const options: DetailsRadioOption[] = [ + { + label: translations.onlyHere.label, + description: translations.onlyHere.description, + icon: PIN_ICON, + value: RedactOrHintOptions.ONLY_HERE, + }, + ]; + // if (!isRss) { + // options.push({ + // label: translations.inDossier.label, + // description: translations.inDossier.description, + // descriptionParams: { dossierName: dossier.dossierName }, + // icon: FOLDER_ICON, + // value: RedactOrHintOptions.IN_DOSSIER, + // extraOption: { + // label: translations.inDossier.extraOptionLabel, + // checked: applyToAllDossiers, + // hidden: !isApprover, + // }, + // }); + // } + options.push({ + label: translations.inDossier.label, + description: translations.inDossier.description, + descriptionParams: { dossierName: dossier.dossierName }, + icon: FOLDER_ICON, + value: RedactOrHintOptions.IN_DOSSIER, + extraOption: { + label: translations.inDossier.extraOptionLabel, + checked: applyToAllDossiers, + hidden: !isApprover, + }, + }); + return options; +}; + export const getRemoveRedactionOptions = ( data: RemoveRedactionData, isDocumine: boolean = false, diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts index d252100b5..e9a099295 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts @@ -25,6 +25,19 @@ export interface RedactTextResult { export type AddHintResult = RedactTextResult; export type AddAnnotationResult = RedactTextResult; +export interface ResizeRedactionData { + redaction: AnnotationWrapper; + dossierId: string; + text: string; + applyToAllDossiers?: boolean; + isApprover?: boolean; +} + +export interface ResizeRedactionResult { + comment: string; + updateDictionary: boolean; +} + export interface RemoveRedactionPermissions { canRemoveOnlyHere: boolean; canRemoveFromDictionary: boolean; diff --git a/apps/red-ui/src/app/translations/resize-redaction-translations.ts b/apps/red-ui/src/app/translations/resize-redaction-translations.ts new file mode 100644 index 000000000..db339851c --- /dev/null +++ b/apps/red-ui/src/app/translations/resize-redaction-translations.ts @@ -0,0 +1,14 @@ +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; +import { DialogOption } from '@translations/redact-text-translations'; + +export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', DialogOption> = { + onlyHere: { + label: _('resize-redaction.dialog.content.options.only-here.label'), + description: _('resize-redaction.dialog.content.options.only-here.description'), + }, + inDossier: { + label: _('resize-redaction.dialog.content.options.in-dossier.label'), + description: _('resize-redaction.dialog.content.options.in-dossier.description'), + extraOptionLabel: _('resize-redaction.dialog.content.options.in-dossier.extraOptionLabel'), + }, +} as const; diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 772d6e339..c3ce0c189 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -3,7 +3,7 @@ "ADMIN_CONTACT_URL": null, "API_URL": "https://dev-04.iqser.cloud", "APP_NAME": "RedactManager very very very very long", - "IS_DOCUMINE": true, + "IS_DOCUMINE": false, "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", "EULA_URL": "EULA_URL", diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index c34c882c4..0b51eccc2 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -2100,16 +2100,32 @@ }, "header": "Temporäres Passwort für {userName} festlegen" }, - "resize-annotation-dialog": { - "actions": { - "cancel": "Abbrechen", - "save": "Änderungen speichern" - }, - "content": { - "comment": "Kommentar", - "update-dictionary": "" - }, - "header": "Schwärzung ändern" + "resize-redaction": { + "dialog": { + "actions": { + "cancel": "", + "save": "" + }, + "content": { + "comment": "", + "options": { + "in-dossier": { + "description": "", + "extraOptionLabel": "", + "label": "" + }, + "only-here": { + "description": "", + "label": "" + } + }, + "original-text": "", + "resized-text": "", + "type": "", + "update-dictionary": "" + }, + "header": "" + } }, "roles": { "inactive": "Inaktiv", diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index e157891c2..2206613f4 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -2100,16 +2100,32 @@ }, "header": "Set Temporary Password for {userName}" }, - "resize-annotation-dialog": { - "actions": { - "cancel": "Cancel", - "save": "Save Changes" - }, - "content": { - "comment": "Comment", - "update-dictionary": "Update dictionary: {text}" - }, - "header": "Resize Redaction" + "resize-redaction": { + "dialog": { + "actions": { + "cancel": "Cancel", + "save": "Save Changes" + }, + "content": { + "comment": "Comment", + "options": { + "in-dossier": { + "description": "Resize in every document in {dossierName}.", + "extraOptionLabel": "Apply to all dossiers", + "label": "Resize in dossier" + }, + "only-here": { + "description": "Resize only at this position in this document.", + "label": "Resize only here" + } + }, + "original-text": "Original text:", + "resized-text": "Resized text:", + "type": "Type", + "update-dictionary": "Update dictionary: {text}" + }, + "header": "Resize {type}" + } }, "roles": { "inactive": "Inactive", diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index d0867eb4d..0968d90e3 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -2100,16 +2100,32 @@ }, "header": "Temporäres Passwort für {userName} festlegen" }, - "resize-annotation-dialog": { - "actions": { - "cancel": "Abbrechen", - "save": "Änderungen speichern" - }, - "content": { - "comment": "Kommentar", - "update-dictionary": "" - }, - "header": "Schwärzung ändern" + "resize-redaction": { + "dialog": { + "actions": { + "cancel": "", + "save": "" + }, + "content": { + "comment": "", + "options": { + "in-dossier": { + "description": "", + "extraOptionLabel": "", + "label": "" + }, + "only-here": { + "description": "", + "label": "" + } + }, + "original-text": "", + "resized-text": "", + "type": "", + "update-dictionary": "" + }, + "header": "" + } }, "roles": { "inactive": "Inaktiv", diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index defd5c7b3..36aa80a18 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -2100,16 +2100,32 @@ }, "header": "Set Temporary Password for {userName}" }, - "resize-annotation-dialog": { - "actions": { - "cancel": "Cancel", - "save": "Save Changes" - }, - "content": { - "comment": "Comment", - "update-dictionary": "Update dictionary: {text}" - }, - "header": "Resize Component" + "resize-redaction": { + "dialog": { + "actions": { + "cancel": "Cancel", + "save": "Save Changes" + }, + "content": { + "comment": "Comment", + "options": { + "in-dossier": { + "description": "Resize in every document in {dossierName}.", + "extraOptionLabel": "Apply to all dossiers", + "label": "Resize in dossier" + }, + "only-here": { + "description": "Resize only at this position in this document.", + "label": "Resize only here" + } + }, + "original-text": "Original text:", + "resized-text": "Resized text:", + "type": "Type", + "update-dictionary": "Update dictionary: {text}" + }, + "header": "Resize {type}" + } }, "roles": { "inactive": "Inactive", From 94f36a1494fb5bdbc764408edf2b7a4645ec8513 Mon Sep 17 00:00:00 2001 From: George Date: Mon, 24 Jul 2023 17:49:03 +0300 Subject: [PATCH 2/7] RED-6778, add dossier only toggle. --- .../add-edit-entity.component.html | 42 ++++++++-- .../add-edit-entity.component.scss | 24 ++++++ .../add-edit-entity.component.ts | 82 ++++++++++--------- .../src/app/modules/shared/shared.module.ts | 2 + apps/red-ui/src/assets/config/config.json | 12 +-- apps/red-ui/src/assets/i18n/redact/de.json | 7 +- apps/red-ui/src/assets/i18n/redact/en.json | 7 +- apps/red-ui/src/assets/i18n/scm/de.json | 7 +- apps/red-ui/src/assets/i18n/scm/en.json | 7 +- 9 files changed, 127 insertions(+), 63 deletions(-) diff --git a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.html b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.html index 85bc988ce..8514ad901 100644 --- a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.html +++ b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.html @@ -84,15 +84,39 @@
-
- - {{ 'add-edit-entity.form.case-sensitive' | translate }} - -
+
+ + + + {{ 'add-edit-entity.form.template-and-dossier-dictionaries' | translate }} + + + + {{ 'add-edit-entity.form.dossier-dictionary-only' | translate }} + + -
- - {{ 'add-edit-entity.form.add-to-dictionary-action' | translate }} - +
+ + {{ 'add-edit-entity.form.manage-entries-in-dictionary-editor-only' | translate }} + +
+
+ + {{ 'add-edit-entity.form.case-sensitive' | translate }} + +
diff --git a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss index 38569f36f..0e294bf7c 100644 --- a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss +++ b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.scss @@ -9,3 +9,27 @@ margin-top: 0; } } + +.dictionary-extras { + margin-left: 38px; + margin-top: 14px; + + .round-checkbox-form-entry:first-of-type { + margin-bottom: 10px; + } +} + +.round-checkbox-form-entry { + display: flex; + gap: 8px; + margin-bottom: 20px; + user-select: none; +} + +.cursor-pointer { + cursor: pointer; +} + +.disabled { + opacity: 0.6; +} diff --git a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts index 480198427..81ca1132b 100644 --- a/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts +++ b/apps/red-ui/src/app/modules/shared/components/add-edit-entity/add-edit-entity.component.ts @@ -9,6 +9,7 @@ import { PermissionsService } from '@services/permissions.service'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { DictionaryService } from '@services/entity-services/dictionary.service'; import { BaseFormComponent, LoadingService, Toaster } from '@iqser/common-ui'; +import { Roles } from '@users/roles'; const REDACTION_FIELDS = ['defaultReason']; @@ -35,6 +36,7 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit technicalName$: Observable; colors: Color[]; + readonly roles = Roles; constructor( private readonly _dictionariesMapService: DictionariesMapService, @@ -48,10 +50,6 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit super(); } - cpDisabled(color: Color) { - return this.form.get(color.controlName).disabled; - } - get #isDossierRedaction(): boolean { return this.entity?.type === 'dossier_redaction'; } @@ -60,26 +58,34 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit return !!this.entity?.systemManaged; } - get #addToDictionaryActionControl() { - return { value: !!this.entity?.addToDictionaryAction, disabled: this.#isSystemManaged && !this.#isDossierRedaction }; - } - get #isHint(): boolean { return !!this.form.get('hint')?.value; } + cpDisabled(color: Color) { + return this.form.get(color.controlName).disabled; + } + revert(): void { this.form.patchValue(this.initialFormValue); } ngOnInit() { - this._initializeForm(); + this.#initializeForm(); + } + + toggleDossierOnlyEntity() { + const propName = 'dossierDictionaryOnly'; + const control = this.form.get(propName); + if (control.disabled) { + return; + } + this.form.patchValue({ [propName]: !control?.value }); } async save(): Promise { this._loadingService.start(); - const dictionary = this._formToObject(); - + const dictionary = this.#formToObject(); try { if (this.entity) { // edit mode @@ -108,26 +114,26 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit labelParams: () => ({ type: this.#isHint ? 'hint' : 'redaction' }), placeholder: _('add-edit-entity.form.color-placeholder'), controlName: 'hexColor', - hasColor$: this._colorEmpty$(form, 'hexColor'), + hasColor$: this.#colorEmpty$(form, 'hexColor'), }, { label: _('add-edit-entity.form.color'), labelParams: () => ({ type: 'recommendation' }), placeholder: _('add-edit-entity.form.color-placeholder'), controlName: 'recommendationHexColor', - hasColor$: this._colorEmpty$(form, 'recommendationHexColor'), + hasColor$: this.#colorEmpty$(form, 'recommendationHexColor'), }, { label: _('add-edit-entity.form.color'), labelParams: () => ({ type: this.#isHint ? 'ignored' : 'skipped' }), placeholder: _('add-edit-entity.form.color-placeholder'), controlName: 'skippedHexColor', - hasColor$: this._colorEmpty$(form, 'skippedHexColor'), + hasColor$: this.#colorEmpty$(form, 'skippedHexColor'), }, ]; } - private _initializeForm(): void { + #initializeForm(): void { let controlsConfig: Record = { label: [this.entity?.label, [Validators.required, Validators.minLength(3)]], hexColor: [this.entity?.hexColor, [Validators.required, Validators.minLength(7)]], @@ -143,26 +149,28 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit rank: [{ value: this.entity?.rank, disabled: this.#isSystemManaged }, Validators.required], hint: [{ value: !!this.entity?.hint, disabled: this.#isSystemManaged }], hasDictionary: [{ value: !!this.entity?.hasDictionary, disabled: this.#isSystemManaged }], - caseSensitive: [{ value: this.entity ? !this.entity.caseInsensitive : false, disabled: this.#isSystemManaged }], + dossierDictionaryOnly: [{ value: !!this.entity?.dossierDictionaryOnly, disabled: this.#isSystemManaged || this.entity }], + caseSensitive: [{ value: !!this.entity?.caseInsensitive, disabled: this.#isSystemManaged }], + manageEntriesInDictionaryEditorOnly: [ + { + value: !this.entity?.addToDictionaryAction, + disabled: this.#isSystemManaged && !this.#isDossierRedaction, + }, + ], }; } if (!this.entity?.hint && !this.#isDossierRedaction) { - Object.assign(controlsConfig, { + controlsConfig = { + ...controlsConfig, defaultReason: [{ value: null, disabled: true }], - }); - } - - if (this.entity?.hasDictionary || this.#isDossierRedaction) { - Object.assign(controlsConfig, { - addToDictionaryAction: [this.#addToDictionaryActionControl], - }); + }; } const form = this._formBuilder.group(controlsConfig); this.#initializeColors(form); - this.technicalName$ = form.get('label').valueChanges.pipe(map((value: string) => this._toTechnicalName(value))); + this.technicalName$ = form.get('label').valueChanges.pipe(map((value: string) => this.#toTechnicalName(value))); if (!this.#isDossierRedaction) { form.get('hint').valueChanges.subscribe(isHint => { @@ -173,17 +181,9 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit } }); - form.get('hasDictionary').valueChanges.subscribe(hasDictionary => { - if (hasDictionary) { - form.addControl('addToDictionaryAction', new UntypedFormControl(this.#addToDictionaryActionControl)); - } else { - form.removeControl('addToDictionaryAction'); - } - }); - if (!this.entity) { form.get('label').valueChanges.subscribe((label: string) => { - form.get('type').setValue(this._toTechnicalName(label)); + form.get('type').setValue(this.#toTechnicalName(label)); }); } } @@ -197,7 +197,7 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit this.form = form; } - private _toTechnicalName(value: string) { + #toTechnicalName(value: string) { const existingTechnicalNames = this._dictionariesMapService.get(this.dossierTemplateId).map(dict => dict.type); const baseTechnicalName = toSnakeCase(value.trim()); let technicalName = baseTechnicalName.replaceAll(/[^A-Za-z0-9_-]/g, ''); @@ -211,19 +211,20 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit return technicalName; } - private _colorEmpty$(form: UntypedFormGroup, field: string) { + #colorEmpty$(form: UntypedFormGroup, field: string) { return form.get(field).valueChanges.pipe( startWith(form.get(field).value), map((value: string) => !value || value?.length === 0), ); } - private _formToObject(): IDictionary { + #formToObject(): IDictionary { // Fields which aren't set for hints, need additional check - const addToDictionaryAction = !!this.form.get('addToDictionaryAction')?.value; + const addToDictionaryAction = !this.form.get('manageEntriesInDictionaryEditorOnly')?.value; const hasDictionary = !!this.form.get('hasDictionary')?.value; + const dossierDictionaryOnly = !!this.form.get('dossierDictionaryOnly')?.value; - let entity = { + const entity = { ...this.entity, label: this.form.get('label').value, hexColor: this.form.get('hexColor').value, @@ -231,10 +232,11 @@ export class AddEditEntityComponent extends BaseFormComponent implements OnInit skippedHexColor: this.form.get('skippedHexColor').value, dossierTemplateId: this.dossierTemplateId, addToDictionaryAction, + dossierDictionaryOnly, }; if (this.entity?.type !== 'dossier_redaction') { - entity = { + return { ...entity, type: this.form.get('type').value, description: this.form.get('description').value, diff --git a/apps/red-ui/src/app/modules/shared/shared.module.ts b/apps/red-ui/src/app/modules/shared/shared.module.ts index b1919ca5b..104cc7c10 100644 --- a/apps/red-ui/src/app/modules/shared/shared.module.ts +++ b/apps/red-ui/src/app/modules/shared/shared.module.ts @@ -15,6 +15,7 @@ import { IqserAllowDirective, IqserDenyDirective, IqserHelpModeModule, + RoundCheckboxComponent, StopPropagationDirective, } from '@iqser/common-ui'; import { NavigateLastDossiersScreenDirective } from './directives/navigate-last-dossiers-screen.directive'; @@ -98,6 +99,7 @@ const deleteThisWhenAllComponentsAreStandalone = [DonutChartComponent]; IqserAllowDirective, IqserDenyDirective, SelectComponent, + RoundCheckboxComponent, ], exports: [...modules, ...components, ...utils, ...deleteThisWhenAllComponentsAreStandalone], providers: [ diff --git a/apps/red-ui/src/assets/config/config.json b/apps/red-ui/src/assets/config/config.json index 280ef08c2..9734775ed 100644 --- a/apps/red-ui/src/assets/config/config.json +++ b/apps/red-ui/src/assets/config/config.json @@ -1,9 +1,9 @@ { "ADMIN_CONTACT_NAME": null, "ADMIN_CONTACT_URL": null, - "API_URL": "https://dev-04.iqser.cloud", - "APP_NAME": "DocuMine", - "IS_DOCUMINE": true, + "API_URL": "https://dan.iqser.cloud", + "APP_NAME": "RedactManager", + "IS_DOCUMINE": false, "AUTO_READ_TIME": 3, "BACKEND_APP_VERSION": "4.4.40", "EULA_URL": "EULA_URL", @@ -12,13 +12,13 @@ "MAX_RETRIES_ON_SERVER_ERROR": 3, "OAUTH_CLIENT_ID": "redaction", "OAUTH_IDP_HINT": null, - "OAUTH_URL": "https://dev-04.iqser.cloud/auth", + "OAUTH_URL": "https://dan.iqser.cloud/auth", "RECENT_PERIOD_IN_HOURS": 24, "SELECTION_MODE": "structural", "MANUAL_BASE_URL": "https://docs.redactmanager.com/preview", "ANNOTATIONS_THRESHOLD": 1000, - "THEME": "scm", - "BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/scm/", + "THEME": "redact", + "BASE_TRANSLATIONS_DIRECTORY": "/assets/i18n/redact/", "AVAILABLE_NOTIFICATIONS_DAYS": 30, "AVAILABLE_OLD_NOTIFICATIONS_MINUTES": 60, "NOTIFICATIONS_THRESHOLD": 1000, diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 5004a0238..51474b85a 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -118,7 +118,6 @@ "invalid-color-or-rank": "" }, "form": { - "add-to-dictionary-action": "", "case-sensitive": "", "color": "", "color-placeholder": "", @@ -126,15 +125,19 @@ "default-reason-placeholder": "", "description": "", "description-placeholder": "", + "dossier-dictionary-only": "", "has-dictionary": "", "hint": "", + "linked-to-global-entity": "", + "manage-entries-in-dictionary-editor-only": "", "name": "", "name-placeholder": "", "rank": "", "rank-placeholder": "", "redaction": "", "technical-name": "", - "technical-name-hint": "" + "technical-name-hint": "", + "template-and-dossier-dictionaries": "" }, "success": { "create": "", diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 47451d760..3e3de999f 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -118,7 +118,6 @@ "invalid-color-or-rank": "Invalid color or rank! Rank is already used by another entity or the color is not a valid hexColor!" }, "form": { - "add-to-dictionary-action": "Enable 'Add to dictionary'", "case-sensitive": "Case Sensitive", "color": "{type, select, redaction{Redaction} hint{Hint} recommendation{Recommendation} skipped{Skipped Redaction} ignored{Ignored Hint} other{}} Color", "color-placeholder": "#", @@ -126,15 +125,19 @@ "default-reason-placeholder": "No Default Reason", "description": "Description", "description-placeholder": "Enter Description", + "dossier-dictionary-only": "Dossier dictionary only", "has-dictionary": "Has dictionary", "hint": "Hint", + "linked-to-global-entity": "Linked to global entity", + "manage-entries-in-dictionary-editor-only": "Manage entries in Dictionary editor only", "name": "Display Name", "name-placeholder": "Enter Name", "rank": "Rank", "rank-placeholder": "1000", "redaction": "Redaction", "technical-name": "Technical Name", - "technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}" + "technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}", + "template-and-dossier-dictionaries": "Template & dossier dictionaries" }, "success": { "create": "Entity added!", diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index d0b7d4164..9c4ff5b64 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -118,7 +118,6 @@ "invalid-color-or-rank": "" }, "form": { - "add-to-dictionary-action": "", "case-sensitive": "", "color": "", "color-placeholder": "", @@ -126,15 +125,19 @@ "default-reason-placeholder": "", "description": "", "description-placeholder": "", + "dossier-dictionary-only": "", "has-dictionary": "", "hint": "", + "linked-to-global-entity": "", + "manage-entries-in-dictionary-editor-only": "", "name": "", "name-placeholder": "", "rank": "", "rank-placeholder": "", "redaction": "", "technical-name": "", - "technical-name-hint": "" + "technical-name-hint": "", + "template-and-dossier-dictionaries": "" }, "success": { "create": "", diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index f1885e2b9..9dbe556f9 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -118,7 +118,6 @@ "invalid-color-or-rank": "Invalid color or rank! Rank is already used by another entity or the color is not a valid hexColor!" }, "form": { - "add-to-dictionary-action": "Enable 'Add to dictionary'", "case-sensitive": "Case Sensitive", "color": "{type, select, redaction{Component} hint{Hint} recommendation{Recommendation} skipped{Skipped Component} ignored{Ignored Hint} other{}} Color", "color-placeholder": "#", @@ -126,15 +125,19 @@ "default-reason-placeholder": "No Default Reason", "description": "Description", "description-placeholder": "Enter Description", + "dossier-dictionary-only": "", "has-dictionary": "Has dictionary", "hint": "Hint", + "linked-to-global-entity": "", + "manage-entries-in-dictionary-editor-only": "", "name": "Display Name", "name-placeholder": "Enter Name", "rank": "Rank", "rank-placeholder": "1000", "redaction": "Component", "technical-name": "Technical Name", - "technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}" + "technical-name-hint": "{type, select, edit{Autogenerated based on the initial display name.} create{Autogenerates based on the display name and cannot be edited after saving.} other{}}", + "template-and-dossier-dictionaries": "" }, "success": { "create": "Entity added!", From 6ad01fe77c22a096fde69aec8fade00ad8df6144 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 24 Jul 2023 18:39:56 +0300 Subject: [PATCH 3/7] DM-337 - update common ui --- libs/common-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common-ui b/libs/common-ui index 7ff786476..5aa064ac6 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 7ff7864767e693a74ef1e05c8808847f7b4f0841 +Subproject commit 5aa064ac65e631f0871f2833ae91007a7c9b7a55 From e963e47709ecef7b66e204aa1ff0765e00882dc6 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 24 Jul 2023 23:44:18 +0300 Subject: [PATCH 4/7] RED-7155 - Resize redaction/hint dialogs --- .../resize-redaction-dialog.component.html | 2 +- .../resize-redaction-dialog.component.ts | 24 ++++++--- .../services/annotation-actions.service.ts | 9 +++- .../file-preview/utils/dialog-options.ts | 52 ++++++++----------- .../resize-redaction-translations.ts | 7 ++- apps/red-ui/src/assets/i18n/redact/de.json | 6 +-- apps/red-ui/src/assets/i18n/redact/en.json | 6 +-- apps/red-ui/src/assets/i18n/scm/de.json | 6 +-- apps/red-ui/src/assets/i18n/scm/en.json | 6 +-- libs/common-ui | 2 +- 10 files changed, 69 insertions(+), 51 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html index 0f12aab16..a64e7987e 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html @@ -33,7 +33,7 @@
-
+
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts index 80654e73f..5b2eb7ff4 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts @@ -3,11 +3,11 @@ import { DetailsRadioOption, IconButtonTypes, IqserDialogComponent, IqserPermiss import { ResizeRedactionData, ResizeRedactionResult } from '../../utils/dialog-types'; import { FormBuilder, FormControl, UntypedFormGroup } from '@angular/forms'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { getRedactOrHintOptions, getResizeRedactionOptions, RedactOrHintOption, ResizeRedactionOption } from '../../utils/dialog-options'; +import { getResizeRedactionOptions, ResizeOptions, ResizeRedactionOption } from '../../utils/dialog-options'; import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; import { Dictionary, Dossier } from '@red/domain'; import { Roles } from '@users/roles'; -import { DictionaryService } from '@services/entity-services/dictionary.service'; +import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; @Component({ templateUrl: './resize-redaction-dialog.component.html', @@ -32,14 +32,20 @@ export class ResizeRedactionDialogComponent constructor( private readonly _activeDossiersService: ActiveDossiersService, private readonly _iqserPermissionsService: IqserPermissionsService, - private readonly _dictionaryService: DictionaryService, + private readonly _dictionariesMapService: DictionariesMapService, private readonly _formBuilder: FormBuilder, ) { super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.redaction = this.data.redaction; - this.options = getResizeRedactionOptions(this.#dossier, this.#isRss, false, this.#applyToAllDossiers, this.data.isApprover); + this.options = getResizeRedactionOptions( + this.redaction, + this.#dossier, + this.#isRss, + this.#applyToAllDossiers, + this.data.isApprover, + ); this.form = this.#getForm(); } @@ -60,7 +66,7 @@ export class ResizeRedactionDialogComponent } async ngOnInit() { - this.dictionaries = this._dictionaryService.getRedactionTypes(this.#dossier.dossierTemplateId); + this.dictionaries = this._dictionariesMapService.get(this.#dossier.dossierTemplateId); } #getForm(): UntypedFormGroup { @@ -72,6 +78,12 @@ export class ResizeRedactionDialogComponent } save(): void { - this.dialogRef.close(this.form.getRawValue()); + const formValue = this.form.getRawValue(); + const updateDictionary = formValue.option.value === ResizeOptions.IN_DOSSIER; + + this.dialogRef.close({ + comment: formValue.comment, + updateDictionary, + }); } } diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index c262c1d3b..99563135e 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -221,8 +221,15 @@ export class AnnotationActionsService { const isImageText = annotation.isImage ? 'Image' : textAndPositions.text; const text = annotation.rectangle ? annotation.value : isImageText; const isApprover = this._permissionsService.isApprover(dossier); + const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); - const data = { redaction: annotation, text, isApprover, dossierId: dossier.dossierId }; + const data = { + redaction: annotation, + text, + applyToAllDossiers: isApprover && dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault, + isApprover, + dossierId: dossier.dossierId, + }; const result = await this.#getResizeRedactionDialog(data).result(); diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 59601f10b..257e3f9b5 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -6,6 +6,7 @@ import { removeRedactionTranslations } from '@translations/remove-redaction-tran import { RemoveRedactionData } from './dialog-types'; import { removeAnnotationTranslations } from '@translations/remove-annotation-translations'; import { resizeRedactionTranslations } from '@translations/resize-redaction-translations'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; const PIN_ICON = 'red:push-pin'; const FOLDER_ICON = 'red:folder'; @@ -17,6 +18,8 @@ export const RedactOrHintOptions = { } as const; export type RedactOrHintOption = keyof typeof RedactOrHintOptions; + +export const ResizeOptions = RedactOrHintOptions; export type ResizeRedactionOption = RedactOrHintOption; export const RemoveRedactionOptions = { @@ -42,7 +45,7 @@ export const getRedactOrHintOptions = ( label: translations.onlyHere.label, description: translations.onlyHere.description, icon: PIN_ICON, - value: RedactOrHintOptions.ONLY_HERE, + value: ResizeOptions.ONLY_HERE, }, ]; if (!isRss) { @@ -51,7 +54,7 @@ export const getRedactOrHintOptions = ( description: translations.inDossier.description, descriptionParams: { dossierName: dossier.dossierName }, icon: FOLDER_ICON, - value: RedactOrHintOptions.IN_DOSSIER, + value: ResizeOptions.IN_DOSSIER, extraOption: { label: translations.inDossier.extraOptionLabel, checked: applyToAllDossiers, @@ -63,9 +66,9 @@ export const getRedactOrHintOptions = ( }; export const getResizeRedactionOptions = ( + redaction: AnnotationWrapper, dossier: Dossier, isRss: boolean, - hint: boolean, applyToAllDossiers: boolean, isApprover: boolean, ): DetailsRadioOption[] => { @@ -78,32 +81,23 @@ export const getResizeRedactionOptions = ( value: RedactOrHintOptions.ONLY_HERE, }, ]; - // if (!isRss) { - // options.push({ - // label: translations.inDossier.label, - // description: translations.inDossier.description, - // descriptionParams: { dossierName: dossier.dossierName }, - // icon: FOLDER_ICON, - // value: RedactOrHintOptions.IN_DOSSIER, - // extraOption: { - // label: translations.inDossier.extraOptionLabel, - // checked: applyToAllDossiers, - // hidden: !isApprover, - // }, - // }); - // } - options.push({ - label: translations.inDossier.label, - description: translations.inDossier.description, - descriptionParams: { dossierName: dossier.dossierName }, - icon: FOLDER_ICON, - value: RedactOrHintOptions.IN_DOSSIER, - extraOption: { - label: translations.inDossier.extraOptionLabel, - checked: applyToAllDossiers, - hidden: !isApprover, - }, - }); + if (!isRss) { + const dictBasedType = redaction.isModifyDictionary; + options.push({ + label: translations.inDossier.label, + description: translations.inDossier.description, + descriptionParams: { dossierName: dossier.dossierName }, + disabled: !dictBasedType, + tooltip: !dictBasedType ? translations.inDossier.tooltip : null, + icon: FOLDER_ICON, + value: RedactOrHintOptions.IN_DOSSIER, + extraOption: { + label: translations.inDossier.extraOptionLabel, + checked: applyToAllDossiers, + hidden: !isApprover, + }, + }); + } return options; }; diff --git a/apps/red-ui/src/app/translations/resize-redaction-translations.ts b/apps/red-ui/src/app/translations/resize-redaction-translations.ts index db339851c..efcda8cca 100644 --- a/apps/red-ui/src/app/translations/resize-redaction-translations.ts +++ b/apps/red-ui/src/app/translations/resize-redaction-translations.ts @@ -1,7 +1,11 @@ import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; import { DialogOption } from '@translations/redact-text-translations'; -export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', DialogOption> = { +interface ResizeDialogOption extends DialogOption { + tooltip?: string; +} + +export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', ResizeDialogOption> = { onlyHere: { label: _('resize-redaction.dialog.content.options.only-here.label'), description: _('resize-redaction.dialog.content.options.only-here.description'), @@ -10,5 +14,6 @@ export const resizeRedactionTranslations: Record<'onlyHere' | 'inDossier', Dialo label: _('resize-redaction.dialog.content.options.in-dossier.label'), description: _('resize-redaction.dialog.content.options.in-dossier.description'), extraOptionLabel: _('resize-redaction.dialog.content.options.in-dossier.extraOptionLabel'), + tooltip: _('resize-redaction.dialog.content.options.in-dossier.tooltip'), }, } as const; diff --git a/apps/red-ui/src/assets/i18n/redact/de.json b/apps/red-ui/src/assets/i18n/redact/de.json index 0b51eccc2..ae0b262ab 100644 --- a/apps/red-ui/src/assets/i18n/redact/de.json +++ b/apps/red-ui/src/assets/i18n/redact/de.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "", "extraOptionLabel": "", - "label": "" + "label": "", + "tooltip": "" }, "only-here": { "description": "", @@ -2121,8 +2122,7 @@ }, "original-text": "", "resized-text": "", - "type": "", - "update-dictionary": "" + "type": "" }, "header": "" } diff --git a/apps/red-ui/src/assets/i18n/redact/en.json b/apps/red-ui/src/assets/i18n/redact/en.json index 2206613f4..aa48b452c 100644 --- a/apps/red-ui/src/assets/i18n/redact/en.json +++ b/apps/red-ui/src/assets/i18n/redact/en.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "Resize in every document in {dossierName}.", "extraOptionLabel": "Apply to all dossiers", - "label": "Resize in dossier" + "label": "Resize in dossier", + "tooltip": "Only available for dictionary-based types" }, "only-here": { "description": "Resize only at this position in this document.", @@ -2121,8 +2122,7 @@ }, "original-text": "Original text:", "resized-text": "Resized text:", - "type": "Type", - "update-dictionary": "Update dictionary: {text}" + "type": "Type" }, "header": "Resize {type}" } diff --git a/apps/red-ui/src/assets/i18n/scm/de.json b/apps/red-ui/src/assets/i18n/scm/de.json index 0968d90e3..ca93efb54 100644 --- a/apps/red-ui/src/assets/i18n/scm/de.json +++ b/apps/red-ui/src/assets/i18n/scm/de.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "", "extraOptionLabel": "", - "label": "" + "label": "", + "tooltip": "" }, "only-here": { "description": "", @@ -2121,8 +2122,7 @@ }, "original-text": "", "resized-text": "", - "type": "", - "update-dictionary": "" + "type": "" }, "header": "" } diff --git a/apps/red-ui/src/assets/i18n/scm/en.json b/apps/red-ui/src/assets/i18n/scm/en.json index 36aa80a18..3d5173cc9 100644 --- a/apps/red-ui/src/assets/i18n/scm/en.json +++ b/apps/red-ui/src/assets/i18n/scm/en.json @@ -2112,7 +2112,8 @@ "in-dossier": { "description": "Resize in every document in {dossierName}.", "extraOptionLabel": "Apply to all dossiers", - "label": "Resize in dossier" + "label": "Resize in dossier", + "tooltip": "Only available for dictionary-based types" }, "only-here": { "description": "Resize only at this position in this document.", @@ -2121,8 +2122,7 @@ }, "original-text": "Original text:", "resized-text": "Resized text:", - "type": "Type", - "update-dictionary": "Update dictionary: {text}" + "type": "Type" }, "header": "Resize {type}" } diff --git a/libs/common-ui b/libs/common-ui index 2524896f4..8f4cc53d0 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 2524896f460594d7766a7c572b63cd3199eac7db +Subproject commit 8f4cc53d0f814d3f222801379497cff40d7801ee From cc7c95b79544840b04fd6c8a2bc7b3e078861120 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Mon, 24 Jul 2023 23:45:14 +0300 Subject: [PATCH 5/7] RED-7155 - update common ui --- libs/common-ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/common-ui b/libs/common-ui index 8f4cc53d0..b368fa6fe 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit 8f4cc53d0f814d3f222801379497cff40d7801ee +Subproject commit b368fa6fe89b1cf65eb76ce15868bccf1a51ff67 From 03ed172f802349b02a66c887362209d079ff9d2c Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 25 Jul 2023 00:31:34 +0300 Subject: [PATCH 6/7] DM-344 - Resize annotation dialog in DocuMine --- .../resize-annotation-dialog.component.html | 49 ++++++++++++++ .../resize-annotation-dialog.component.ts | 66 +++++++++++++++++++ .../resize-redaction-dialog.component.html | 1 - .../resize-redaction-dialog.component.ts | 8 --- .../file-preview/file-preview.module.ts | 2 + .../services/annotation-actions.service.ts | 17 +++-- .../file-preview/utils/dialog-types.ts | 11 +++- apps/red-ui/src/assets/i18n/redact/de.json | 16 ++++- apps/red-ui/src/assets/i18n/redact/en.json | 16 ++++- apps/red-ui/src/assets/i18n/scm/de.json | 16 ++++- apps/red-ui/src/assets/i18n/scm/en.json | 16 ++++- 11 files changed, 197 insertions(+), 21 deletions(-) create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.html create mode 100644 apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.ts diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.html new file mode 100644 index 000000000..f6fd4404d --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.html @@ -0,0 +1,49 @@ +
+
+
+ +
+
+ + {{ redaction.value }} +
+ +
+ + {{ data.text }} +
+ + +
+ + + + + {{ displayedDictionaryLabel }} + + {{ redaction.entity.label }} + + + +
+
+ +
+ + +
+
+ +
+ + +
+
+
+ + +
diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.ts new file mode 100644 index 000000000..9f0bab091 --- /dev/null +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/docu-mine/resize-annotation-dialog/resize-annotation-dialog.component.ts @@ -0,0 +1,66 @@ +import { Component, OnInit } from '@angular/core'; +import { IconButtonTypes, IqserDialogComponent } from '@iqser/common-ui'; +import { FormBuilder, FormControl, UntypedFormGroup } from '@angular/forms'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service'; +import { Dictionary, Dossier } from '@red/domain'; +import { Roles } from '@users/roles'; +import { DictionariesMapService } from '@services/entity-services/dictionaries-map.service'; +import { ResizeAnnotationData, ResizeAnnotationResult } from '../../../utils/dialog-types'; + +@Component({ + templateUrl: './resize-annotation-dialog.component.html', +}) +export class ResizeAnnotationDialogComponent + extends IqserDialogComponent + implements OnInit +{ + readonly roles = Roles; + readonly iconButtonTypes = IconButtonTypes; + + dictionaries: Dictionary[] = []; + redaction: AnnotationWrapper; + form!: UntypedFormGroup; + + readonly #dossier: Dossier; + + constructor( + private readonly _activeDossiersService: ActiveDossiersService, + private readonly _dictionariesMapService: DictionariesMapService, + private readonly _formBuilder: FormBuilder, + ) { + super(); + this.#dossier = _activeDossiersService.find(this.data.dossierId); + this.redaction = this.data.redaction; + + this.form = this.#getForm(); + } + + get displayedDictionaryLabel() { + const dictType = this.form.get('dictionary').value; + if (dictType) { + return this.dictionaries.find(d => d.type === dictType)?.label ?? null; + } + return null; + } + + async ngOnInit() { + this.dictionaries = this._dictionariesMapService.get(this.#dossier.dossierTemplateId); + } + + #getForm(): UntypedFormGroup { + return this._formBuilder.group({ + comment: [null], + dictionary: new FormControl({ value: this.redaction.entity.type, disabled: true }), + }); + } + + save(): void { + const formValue = this.form.getRawValue(); + + this.dialogRef.close({ + comment: formValue.comment, + updateDictionary: this.redaction.entity.hasDictionary, + }); + } +} diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html index a64e7987e..2f562a0b1 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.html @@ -41,7 +41,6 @@
Date: Tue, 25 Jul 2023 12:03:59 +0300 Subject: [PATCH 7/7] RED-7155 - removed "apply to all dossiers" option from resize dialog --- .../resize-redaction-dialog.component.ts | 11 +---------- .../services/annotation-actions.service.ts | 4 ---- .../app/modules/file-preview/utils/dialog-options.ts | 7 ------- .../app/modules/file-preview/utils/dialog-types.ts | 11 ++++------- 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts index 8d9fbbe37..d14e6a5dc 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/resize-redaction-dialog/resize-redaction-dialog.component.ts @@ -24,8 +24,6 @@ export class ResizeRedactionDialogComponent redaction: AnnotationWrapper; form!: UntypedFormGroup; - #applyToAllDossiers: boolean; - readonly #dossier: Dossier; readonly #isRss = this._iqserPermissionsService.has(Roles.getRss); @@ -37,15 +35,8 @@ export class ResizeRedactionDialogComponent ) { super(); this.#dossier = _activeDossiersService.find(this.data.dossierId); - this.#applyToAllDossiers = this.data.applyToAllDossiers ?? true; this.redaction = this.data.redaction; - this.options = getResizeRedactionOptions( - this.redaction, - this.#dossier, - this.#isRss, - this.#applyToAllDossiers, - this.data.isApprover, - ); + this.options = getResizeRedactionOptions(this.redaction, this.#dossier, this.#isRss); this.form = this.#getForm(); } diff --git a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts index adb5cc314..aad817655 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/annotation-actions.service.ts @@ -227,14 +227,10 @@ export class AnnotationActionsService { const isImageText = annotation.isImage ? 'Image' : textAndPositions.text; const text = annotation.rectangle ? annotation.value : isImageText; - const isApprover = this._permissionsService.isApprover(dossier); - const dossierTemplate = this._dossierTemplatesService.find(this._state.dossierTemplateId); const data = { redaction: annotation, text, - applyToAllDossiers: isApprover && dossierTemplate.applyDictionaryUpdatesToAllDossiersByDefault, - isApprover, dossierId: dossier.dossierId, }; diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts index 257e3f9b5..31d865ef2 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-options.ts @@ -69,8 +69,6 @@ export const getResizeRedactionOptions = ( redaction: AnnotationWrapper, dossier: Dossier, isRss: boolean, - applyToAllDossiers: boolean, - isApprover: boolean, ): DetailsRadioOption[] => { const translations = resizeRedactionTranslations; const options: DetailsRadioOption[] = [ @@ -91,11 +89,6 @@ export const getResizeRedactionOptions = ( tooltip: !dictBasedType ? translations.inDossier.tooltip : null, icon: FOLDER_ICON, value: RedactOrHintOptions.IN_DOSSIER, - extraOption: { - label: translations.inDossier.extraOptionLabel, - checked: applyToAllDossiers, - hidden: !isApprover, - }, }); } return options; diff --git a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts index b4b6185a9..222cbd54a 100644 --- a/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts +++ b/apps/red-ui/src/app/modules/file-preview/utils/dialog-types.ts @@ -25,23 +25,20 @@ export interface RedactTextResult { export type AddHintResult = RedactTextResult; export type AddAnnotationResult = RedactTextResult; -export interface ResizeAnnotationData { +export interface ResizeRedactionData { redaction: AnnotationWrapper; text: string; dossierId: string; } -export interface ResizeRedactionData extends ResizeAnnotationData { - applyToAllDossiers?: boolean; - isApprover?: boolean; -} +export type ResizeAnnotationData = ResizeRedactionData; -export interface ResizeAnnotationResult { +export interface ResizeRedactionResult { comment: string; updateDictionary: boolean; } -export type ResizeRedactionResult = ResizeAnnotationResult; +export type ResizeAnnotationResult = ResizeRedactionResult; export interface RemoveRedactionPermissions { canRemoveOnlyHere: boolean;