From 03ed172f802349b02a66c887362209d079ff9d2c Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Tue, 25 Jul 2023 00:31:34 +0300 Subject: [PATCH] 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 @@