Skip to content

Commit

Permalink
summary does not error, dont rely on null value for summary.js..!
Browse files Browse the repository at this point in the history
  • Loading branch information
jenbutongit committed Jul 1, 2020
1 parent 4349bfa commit 0298514
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
18 changes: 13 additions & 5 deletions engine/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,22 @@ class Model {

if (sectionPages.length > 0) {
if (section) {
let sectionSchema = joi.object().required()
const isRepeatable = sectionPages.find(page => page.pageDef.repeatField)
let sectionSchema

sectionSchema = joi.object().required()
sectionPages.forEach(sectionPage => {
sectionSchema = sectionSchema.concat(sectionPage.stateSchema)
})

schema = schema.append({
[section.name]: sectionSchema
})
if(isRepeatable) {
sectionSchema = joi.array().items(sectionSchema)
}

if(!isRepeatable ||( isRepeatable && !schema[section.name])) {
schema = schema.append({
[section.name]: sectionSchema
})
}
} else {
sectionPages.forEach(sectionPage => {
schema = schema.concat(sectionPage.stateSchema)
Expand Down
6 changes: 2 additions & 4 deletions runner/src/server/plugins/builder/pages/summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@ class SummaryViewModel {
let endPage = null

let nextPage = model.startPage
while (nextPage !== null) {
if (nextPage.hasFormComponents) {
relevantPages.push(nextPage)
}
while (nextPage?.hasFormComponents) {
relevantPages.push(nextPage)
nextPage = nextPage.getNextPage(state)
}

Expand Down

0 comments on commit 0298514

Please sign in to comment.