order fields and sections by ordinal on dmp-editor blueprint step

This commit is contained in:
Sofia Papacharalampous 2024-05-10 17:02:30 +03:00
parent 2b1bc2a5ce
commit 8e899db021
1 changed files with 6 additions and 0 deletions

View File

@ -195,6 +195,12 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
prepareForm(data: Dmp) {
try {
if (data?.blueprint?.definition?.sections != null) {
data.blueprint.definition.sections = data.blueprint.definition.sections.sort((s1,s2) => s1.ordinal-s2.ordinal);
for (let i=0; i<data.blueprint.definition.sections.length; i++){
data.blueprint.definition.sections[i].fields = data.blueprint.definition.sections[i]?.fields?.sort((f1,f2) => f1.ordinal-f2.ordinal);
}
}
this.editorModel = data ? new DmpEditorModel().fromModel(data) : new DmpEditorModel();
if (data) {
if (data.descriptions) {