Skip to content

Commit

Permalink
[fix] Create default wizard
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Sep 26, 2020
1 parent eb2102b commit d758072
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/model/WizardGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ export default class WizardGenerator {

const [steps, form] = WizardGenerator._constructWizardSteps(defaultFormData, intl);

const wizardProperties = {
steps,
title
};

return [wizardProperties, form];
return [steps, { root: form }];
}

/**
Expand All @@ -51,7 +46,12 @@ export default class WizardGenerator {
title
};
} catch (e) {
wizardProperties = WizardGenerator.createDefaultWizard(data, title);
const [steps, rootForm] = WizardGenerator.createDefaultWizard(data, title);
form = rootForm;
wizardProperties = {
steps,
title
};
}
return resolve([wizardProperties, form]);
})
Expand All @@ -78,8 +78,8 @@ export default class WizardGenerator {
formElements = form[Constants.HAS_SUBQUESTION];

if (!formElements) {
Logger.error('Could not find any wizard steps in the received data.');
throw 'No wizard steps in form';
Logger.error('Could not find any questions in the received data.');
throw 'Questions in the form';
}

stepQuestions = formElements.filter((item) => {
Expand All @@ -91,6 +91,11 @@ export default class WizardGenerator {
return false;
});

if (!stepQuestions.length) {
Logger.error('Could not find any wizard steps in the received data.');
throw 'No wizard steps in form';
}

// sort by label
stepQuestions.sort(JsonLdObjectUtils.getCompareLocalizedLabelFunction(intl));

Expand Down

0 comments on commit d758072

Please sign in to comment.