Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/repeat pages #34

Merged
merged 6 commits into from
Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/circle_trigger.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ PACKAGES=$(ls ${ROOT} -l | grep ^d | awk '{print $9}')
echo "Searching for changes since commit [${LAST_COMPLETED_BUILD_SHA:0:7}] ..."

## The CircleCI API parameters object
PARAMETERS='"trigger":false, "designer":true, "runner":true'
PARAMETERS='"trigger":false, "designer":true, "runner":true, "engine":true'
COUNT=2

## Get the list of workflows in current branch for which the CI is currently in failed state
Expand Down
20 changes: 10 additions & 10 deletions engine/components/radiosfield.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,20 +44,20 @@ class RadiosField extends ConditionalFormComponent {
condition: item.condition
}

if (options.bold) {
itemModel.label = {
classes: 'govuk-label--s'
if (options.bold) {
itemModel.label = {
classes: 'govuk-label--s'
}
}
}

if (item.description) {
itemModel.hint = {
html: this.localisedString(item.description)
if (item.description) {
itemModel.hint = {
html: this.localisedString(item.description)
}
}
}

return super.addConditionalComponents(item, itemModel, formData, errors)
})
return super.addConditionalComponents(item, itemModel, formData, errors)
})
})

return viewModel
Expand Down
3 changes: 2 additions & 1 deletion engine/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "babel src -d lib --source-maps inline",
"build:watch": "babel src -d lib --source-maps inline --watch",
"test-lab": "lab -T node_modules/@xgovformbuilder/lab-babel -S -v -P 'test' test/cases -r console -o stdout -r html -o unit-test.html -I version",
"test": "npm run-script lint && npm run-script test-lab"
"test": "yarn lint && yarn test-lab"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -42,6 +42,7 @@
"@hapi/code": "^8.0.1",
"@hapi/lab": "^22.0.4",
"@xgovformbuilder/lab-babel": "2.0.0",
"babel-eslint": "11.0.0-beta.2",
"standard": "14.3.3"
},
"peerDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions engine/src/lib.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import findByPostcode from './address-service'
import ComponentTypes from './component-types'
import ConditionalComponentTypes from './conditional-component-types'
import * as ComponentTypes from './component-types'
import * as ConditionalComponentTypes from './conditional-component-types'
import * as Helpers from './helpers'
import Model from './model'
import Page from './page'
Expand Down
7 changes: 6 additions & 1 deletion engine/src/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Model {
constructor (def, options) {
const result = schema.validate(def, { abortEarly: false })

// TODO:- throw/catch this properly 🤦🏻‍
if (result.error) {
throw result.error
}
Expand Down Expand Up @@ -78,11 +79,15 @@ class Model {

if (sectionPages.length > 0) {
if (section) {
const isRepeatable = sectionPages.find(page => page.pageDef.repeatField)

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

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