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