description editor fix

This commit is contained in:
Diamantis Tziotzios 2024-02-21 17:21:17 +02:00
parent cc6359e0fc
commit 443ce153ee
4 changed files with 13 additions and 16 deletions

View File

@ -155,7 +155,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp
validationErrorModel: ValidationErrorModel, validationErrorModel: ValidationErrorModel,
rootPath: string rootPath: string
}): void { }): void {
const { formGroup, rootPath, validationErrorModel } = params; const { formGroup, rootPath, validationErrorModel } = params;
const keys = Object.keys(formGroup.value as Object); const keys = Object.keys(formGroup.value as Object);
@ -166,7 +166,7 @@ export class DescriptionPropertyDefinitionEditorModel implements DescriptionProp
rootPath: `${rootPath}fieldSets[${key}].`, rootPath: `${rootPath}fieldSets[${key}].`,
validationErrorModel: validationErrorModel validationErrorModel: validationErrorModel
}) })
}); });
} }
private calculateProperties(item: DescriptionPropertyDefinition, descriptionTemplate: DescriptionTemplate, descriptionReferences: DescriptionReference[]): Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> { private calculateProperties(item: DescriptionPropertyDefinition, descriptionTemplate: DescriptionTemplate, descriptionReferences: DescriptionReference[]): Map<string, DescriptionPropertyDefinitionFieldSetEditorModel> {
@ -322,7 +322,13 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des
if (item) { if (item) {
this.comment = item.comment; this.comment = item.comment;
this.ordinal = item.ordinal; 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; return this;
} }
@ -392,7 +398,7 @@ export class DescriptionPropertyDefinitionFieldSetItemEditorModel implements Des
rootPath: `${rootPath}fields[${key}].`, rootPath: `${rootPath}fields[${key}].`,
validationErrorModel: validationErrorModel validationErrorModel: validationErrorModel
}) })
}); });
['comment', 'ordinal'].forEach(keyField => { ['comment', 'ordinal'].forEach(keyField => {
const control = formGroup?.get(keyField); const control = formGroup?.get(keyField);

View File

@ -155,15 +155,6 @@
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('dateValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="propertiesFormGroup?.get(field.id).get('dateValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.EXTERNAL_DATASETS" class="col-12">
<ng-container *ngIf="field.data.multipleSelect">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('references')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Datasets" [multiple]="true" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
<ng-container *ngIf="!(field.data.multipleSelect)">
<app-reference-field-component [form]="propertiesFormGroup?.get(field.id).get('reference')" [label]="field.label" [placeholder]="(field.data.label | translate) + (isRequired ? ' *': '')" [referenceType]="referenceTypeEnum.Datasets" [multiple]="false" [required]="isRequired" hint="{{ 'TYPES.DATASET-PROFILE-COMBO-BOX-TYPE.EXTERNAL-SOURCE-HINT' | translate }}"></app-reference-field-component>
</ng-container>
</div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAGS" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.TAGS" class="col-12">
<div class="row"> <div class="row">
<mat-form-field class="col-md-12"> <mat-form-field class="col-md-12">

View File

@ -29,7 +29,7 @@ export class TableOfContentsInternal implements OnInit {
constructor() { constructor() {
} }
ngOnInit(): void { ngOnInit(): void {
console.log('component created' + JSON.stringify(this.tocentries)); // console.log('component created' + JSON.stringify(this.tocentries));
if (this.tocentries) { if (this.tocentries) {
this.expandChildren = this.tocentries.map(() => false); this.expandChildren = this.tocentries.map(() => false);
if (this.selected) { if (this.selected) {

View File

@ -220,10 +220,10 @@ export class TableOfContentsComponent extends BaseComponent implements OnInit, O
.subscribe(_ => { .subscribe(_ => {
if (this.hasFocus) { if (this.hasFocus) {
this._resetObserver(); 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) { // if (!this.isActive && this.links && this.links.length > 0) {
// this.links.forEach(link => { // this.links.forEach(link => {