description error indicator bug fix on nested sections

This commit is contained in:
Sofia Papacharalampous 2024-04-22 13:37:10 +03:00
parent cb3ff760e5
commit 1f7bcc52ea
3 changed files with 33 additions and 18 deletions

View File

@ -918,29 +918,45 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
const pageToFieldSetMap = new Map<string, DescriptionFieldIndicator[]>();
descriptionTemplate.definition.pages?.forEach((page: DescriptionTemplatePage) => {
page.sections?.forEach((section: DescriptionTemplateSection) => {
const fieldsets = this.getFieldsetsFromSection(section);
const value = fieldsets?.flatMap((fieldset: DescriptionTemplateFieldSet) =>
fieldset.fields?.flatMap((field: DescriptionTemplateField) =>
new DescriptionFieldIndicator(page.id, section.id, fieldset.id, field.id, field.data.fieldType, field.data.multipleSelect)
// 'properties.fieldSets.' + fieldset.id + '.items.0.fields.' + field.id// + '.textValue'
));
pageToFieldSetMap.set(page.id,
value
);
});
let fieldsByPage = this.getFieldsetsOfPage(page);
pageToFieldSetMap.set(page.id, fieldsByPage);
});
return pageToFieldSetMap;
}
getFieldsetsFromSection(section: DescriptionTemplateSection): DescriptionTemplateFieldSet[] {
getFieldsetsOfPage(page: DescriptionTemplatePage): DescriptionFieldIndicator[] {
const fieldsByPage: DescriptionFieldIndicator[] = []
page.sections?.forEach((section: DescriptionTemplateSection) => {
let fieldsets = this.getNestedSectionFieldsets(section);
let sectionIds = this.getNestedSectionIds(section);
let fieldsBySection: DescriptionFieldIndicator[] = fieldsets?.flatMap((fieldset: DescriptionTemplateFieldSet) =>
fieldset.fields?.flatMap((field: DescriptionTemplateField) =>
new DescriptionFieldIndicator(page.id, sectionIds, fieldset.id, field.id, field.data.fieldType, field.data.multipleSelect)
));
fieldsByPage.push(...fieldsBySection);
});
return fieldsByPage;
}
getNestedSectionFieldsets(section: DescriptionTemplateSection): DescriptionTemplateFieldSet[] {
if (section.sections) {
return section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getFieldsetsFromSection(subsection));
return section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getNestedSectionFieldsets(subsection));
}
else return section.fieldSets;
}
getNestedSectionIds(section: DescriptionTemplateSection): string[] {
if (section.sections) {
return [section.id, ...section.sections.flatMap((subsection: DescriptionTemplateSection) => this.getNestedSectionIds(subsection))];
}
else return [section.id];
}
// // this._listenersSubscription.add(dmpSubscription);
// // this._listenersSubscription.add(profileSubscription);

View File

@ -695,14 +695,14 @@ export class DescriptionReferenceEditorModel implements DescriptionReferencePers
export class DescriptionFieldIndicator {
pageId: string;
sectionId: string;
sectionIds: string[];
fieldSetId: string;
fieldId: string;
type: string;
constructor(pageId: string, sectionId: string, fieldSetId: string, fieldId: string, type: DescriptionTemplateFieldType, multipleSelect: boolean = false) {
constructor(pageId: string, sectionIds: string[], fieldSetId: string, fieldId: string, type: DescriptionTemplateFieldType, multipleSelect: boolean = false) {
this.pageId = pageId;
this.sectionId = sectionId;
this.sectionIds = sectionIds;
this.fieldSetId = fieldSetId;
this.fieldId = fieldId;

View File

@ -50,7 +50,6 @@ export class TableOfContentsInternal implements OnInit {
if (this.parentMap) {
this.updatedMap = this.updateMap(this.tocentries, this.parentMap);
console.log(this.updatedMap);
}
}
}
@ -82,7 +81,7 @@ export class TableOfContentsInternal implements OnInit {
parentMap.forEach((fields: DescriptionFieldIndicator[], parentId: string) => {
if (this.parentId === parentId) {
for (let entry of entries) {
let entryFields = fields.filter((field: DescriptionFieldIndicator) => field.sectionId === entry.id || field.fieldSetId === entry.id || field.fieldId === entry.id )
let entryFields = fields.filter((field: DescriptionFieldIndicator) => field.sectionIds.includes(entry.id) || field.fieldSetId === entry.id || field.fieldId === entry.id )
updatedMap.set(entry.id, entryFields);
}