From f3cd880dac7f9aac3d1e245bb17df9b9c81eb072 Mon Sep 17 00:00:00 2001 From: Valentin Mihai Date: Fri, 31 Mar 2023 17:33:03 +0300 Subject: [PATCH] RED-6453 - Value for attribute in file list cannot be set --- .../file-attribute.component.html | 2 +- .../file-attribute.component.ts | 27 +++++++++---------- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier-overview/components/table-item/file-attribute/file-attribute.component.html b/apps/red-ui/src/app/modules/dossier-overview/components/table-item/file-attribute/file-attribute.component.html index 602e751e4..ec156f82e 100644 --- a/apps/red-ui/src/app/modules/dossier-overview/components/table-item/file-attribute/file-attribute.component.html +++ b/apps/red-ui/src/app/modules/dossier-overview/components/table-item/file-attribute/file-attribute.component.html @@ -4,7 +4,7 @@ {{ fileAttributeValue ? (fileAttributeValue | date : 'd MMM yyyy') : '-' }} - +
{ this.#toggleEdit(); } @@ -111,7 +98,11 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit, #initFileAttributes() { const configs = this.fileAttributesService.getFileAttributeConfig(this.file.dossierTemplateId).fileAttributeConfigs; - configs.forEach(config => (this.file.fileAttributes.attributeIdToValue[config.id] = null)); + configs.forEach(config => { + if (!this.file.fileAttributes.attributeIdToValue[config.id]) { + this.file.fileAttributes.attributeIdToValue[config.id] = null; + } + }); } #getForm(): UntypedFormGroup { @@ -129,6 +120,12 @@ export class FileAttributeComponent extends BaseFormComponent implements OnInit, } #toggleEdit(): void { + if (!this.isInEditMode) { + this.#initFileAttributes(); + this.form = this.#getForm(); + this.initialFormValue = this.form.getRawValue(); + } + this.isInEditMode = !this.isInEditMode; this.fileAttributesService.isEditingFileAttribute$.next(this.isInEditMode);