{
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);