description error indicator bug fix on nested sections
This commit is contained in:
parent
cb3ff760e5
commit
1f7bcc52ea
|
@ -918,29 +918,45 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
|
||||||
const pageToFieldSetMap = new Map<string, DescriptionFieldIndicator[]>();
|
const pageToFieldSetMap = new Map<string, DescriptionFieldIndicator[]>();
|
||||||
|
|
||||||
descriptionTemplate.definition.pages?.forEach((page: DescriptionTemplatePage) => {
|
descriptionTemplate.definition.pages?.forEach((page: DescriptionTemplatePage) => {
|
||||||
page.sections?.forEach((section: DescriptionTemplateSection) => {
|
let fieldsByPage = this.getFieldsetsOfPage(page);
|
||||||
const fieldsets = this.getFieldsetsFromSection(section);
|
pageToFieldSetMap.set(page.id, fieldsByPage);
|
||||||
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
|
|
||||||
);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return pageToFieldSetMap;
|
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) {
|
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;
|
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(dmpSubscription);
|
||||||
// // this._listenersSubscription.add(profileSubscription);
|
// // this._listenersSubscription.add(profileSubscription);
|
||||||
|
|
|
@ -695,14 +695,14 @@ export class DescriptionReferenceEditorModel implements DescriptionReferencePers
|
||||||
|
|
||||||
export class DescriptionFieldIndicator {
|
export class DescriptionFieldIndicator {
|
||||||
pageId: string;
|
pageId: string;
|
||||||
sectionId: string;
|
sectionIds: string[];
|
||||||
fieldSetId: string;
|
fieldSetId: string;
|
||||||
fieldId: string;
|
fieldId: string;
|
||||||
type: 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.pageId = pageId;
|
||||||
this.sectionId = sectionId;
|
this.sectionIds = sectionIds;
|
||||||
this.fieldSetId = fieldSetId;
|
this.fieldSetId = fieldSetId;
|
||||||
this.fieldId = fieldId;
|
this.fieldId = fieldId;
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,6 @@ export class TableOfContentsInternal implements OnInit {
|
||||||
|
|
||||||
if (this.parentMap) {
|
if (this.parentMap) {
|
||||||
this.updatedMap = this.updateMap(this.tocentries, 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) => {
|
parentMap.forEach((fields: DescriptionFieldIndicator[], parentId: string) => {
|
||||||
if (this.parentId === parentId) {
|
if (this.parentId === parentId) {
|
||||||
for (let entry of entries) {
|
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);
|
updatedMap.set(entry.id, entryFields);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue