From 443ce153ee3ae3eb3b059c4622de37d25bb2a294 Mon Sep 17 00:00:00 2001 From: Diamantis Tziotzios Date: Wed, 21 Feb 2024 17:21:17 +0200 Subject: [PATCH] description editor fix --- .../description/editor/description-editor.model.ts | 14 ++++++++++---- .../form-field/form-field.component.html | 9 --------- .../table-of-contents-internal.ts | 2 +- .../table-of-contents.component.ts | 4 ++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts index a0e58b77b..7b8fed036 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts +++ b/dmp-frontend/src/app/ui/description/editor/description-editor.model.ts @@ -155,7 +155,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp validationErrorModel: ValidationErrorModel, rootPath: string }): void { - + const { formGroup, rootPath, validationErrorModel } = params; const keys = Object.keys(formGroup.value as Object); @@ -166,7 +166,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp rootPath: `${rootPath}fieldSets[${key}].`, validationErrorModel: validationErrorModel }) - }); + }); } private calculateProperties(item: DescriptionPropertyDefinition, descriptionTemplate: DescriptionTemplate, descriptionReferences: DescriptionReference[]): Map { @@ -322,7 +322,13 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des if (item) { this.comment = item.comment; this.ordinal = item.ordinal; - if (item.fields) { Object.keys(item.fields)?.forEach(key => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(item.fields[key], definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); } + if (item.fields) { + //TODO: don't like it. Find a common way to parse it either its Map or json. + if (item.fields instanceof Map) + new Map(item.fields)?.forEach((value, key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(value, definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); + else + Object.keys(item.fields)?.forEach((key) => this.fields.set(key, new DescriptionFieldEditorModel(this.validationErrorModel).fromModel(item.fields[key], definitionFieldSet?.fields?.find(x => x.id == key), descriptionReferences))); + } } return this; } @@ -392,7 +398,7 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des rootPath: `${rootPath}fields[${key}].`, validationErrorModel: validationErrorModel }) - }); + }); ['comment', 'ordinal'].forEach(keyField => { const control = formGroup?.get(keyField); diff --git a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html index b91f97931..9fe802bb2 100644 --- a/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html +++ b/dmp-frontend/src/app/ui/description/editor/description-form/components/form-field/form-field.component.html @@ -155,15 +155,6 @@ {{'GENERAL.VALIDATION.REQUIRED' | translate}} -
- - - - - - -
-
diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts index 26e3bbe0b..e71abe8ce 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents-internal/table-of-contents-internal.ts @@ -29,7 +29,7 @@ export class TableOfContentsInternal implements OnInit { constructor() { } ngOnInit(): void { - console.log('component created' + JSON.stringify(this.tocentries)); + // console.log('component created' + JSON.stringify(this.tocentries)); if (this.tocentries) { this.expandChildren = this.tocentries.map(() => false); if (this.selected) { diff --git a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts index 9d9cb97fd..c62759f60 100644 --- a/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts +++ b/dmp-frontend/src/app/ui/description/editor/table-of-contents/table-of-contents.component.ts @@ -220,10 +220,10 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O .subscribe(_ => { if (this.hasFocus) { this._resetObserver(); - this.hiddenEntries = this._findHiddenEntries(this.tocentries); + // this.hiddenEntries = this._findHiddenEntries(this.tocentries); } }); - this.hiddenEntries = this._findHiddenEntries(this.tocentries); + // this.hiddenEntries = this._findHiddenEntries(this.tocentries); } // if (!this.isActive && this.links && this.links.length > 0) { // this.links.forEach(link => {