Skip to content

Commit

Permalink
Update deps and use form-template
Browse files Browse the repository at this point in the history
  • Loading branch information
HughePaul committed May 27, 2021
1 parent a787872 commit 453555a
Show file tree
Hide file tree
Showing 25 changed files with 97 additions and 264 deletions.
13 changes: 0 additions & 13 deletions example/controllers/question.js

This file was deleted.

2 changes: 1 addition & 1 deletion example/locales/en/fields.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ left-only:

right-only:
label: Right field
hint: This field is only shown if you selected Left
hint: This field is only shown if you selected Right

question1:
label: Question 1
Expand Down
18 changes: 9 additions & 9 deletions example/locales/en/pages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ invalidation:
title: Completed
content:
- Demo completed!
- Change the answer to <a href="question2">question 2</a> and question 3 and 4 will be invalidated.
- Change the answer to <a href="question2/edit">question 2</a> and question 3 and 4 will be invalidated.
- You won't be able to move forward until you complete those questions.
- <a href="/" class="button">Back to examples list</a>
- <a href="/" class="govuk-button">Back to examples list</a>
all:
shortcuts:
- 'Shortcuts to steps:'
- - <a href="question1">question 1</a>
- - <a href="question2">question 2</a>
- - <a href="question3">question 3</a>
- - <a href="question4">question 4</a>
- - <a href="question5">question 5</a>
- - <a href="done">done</a>
- 'Direct links to steps:'
- - <a href="/invalidation/question1/edit">question 1</a>
- - <a href="/invalidation/question2/edit">question 2</a>
- - <a href="/invalidation/question3/edit">question 3</a>
- - <a href="/invalidation/question4/edit">question 4</a>
- - <a href="/invalidation/question5/edit">question 5</a>
- - <a href="/invalidation/done">done</a>

multiwizard:
index:
Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"body-parser": "^1.12.2",
"cookie-parser": "^1.4.1",
"express": "^4.17.1",
"express-session": "^1.13.0",
"express-session": "^1.17.2",
"govuk-frontend": "latest",
"hmpo-components": "latest",
"hmpo-config": "latest",
Expand Down
3 changes: 3 additions & 0 deletions example/routes/basic/fields.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
module.exports = {
name: {
type: 'text',
validate: 'required'
},
age: {
type: 'number',
validate: [
'required',
'numeric',
{ type: 'range', fn: value => value >= 0 && value < 120 },
]
},
color: {
type: 'select',
validate: 'required',
items: [
'red',
Expand Down
4 changes: 4 additions & 0 deletions example/routes/branching/fields.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@

module.exports = {
direction: {
type: 'radios',
items: [
'left',
'right'
]
},
'left-only': {
type: 'text',
validate: 'required'
},
'right-only': {
type: 'text',
validate: 'required'
}
};
5 changes: 5 additions & 0 deletions example/routes/invalidation/fields.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
module.exports = {
question1: {
type: 'text',
journeyKey: 'q1',
validate: 'required'
},
question2: {
type: 'text',
validate: 'required',
invalidates: [ 'question3', 'question4' ]
},
question3: {
type: 'text',
validate: 'required'
},
question4: {
type: 'text',
journeyKey: 'q4',
validate: 'required'
},
question5: {
type: 'text',
validate: 'required'
}
};
4 changes: 2 additions & 2 deletions example/routes/invalidation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ const fields = require('./fields');
app.use(wizard(steps, fields, {
journeyName: 'invalidation',
name: 'invalidation1',
controller: require('../../controllers/question'),
templatePath: 'pages/invalidation'
templatePath: 'pages/invalidation',
editBackStep: 'done'
}));

module.exports = app;
5 changes: 5 additions & 0 deletions example/routes/invalidation/steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,31 @@ module.exports = {
next: 'question1'
},
'/question1': {
editable: true,
fields: ['question1'],
template: 'question',
next: 'question2'
},
'/question2': {
editable: true,
fields: ['question2'],
template: 'question',
next: 'question3'
},
'/question3': {
editable: true,
fields: ['question3'],
template: 'question',
next: 'question4'
},
'/question4': {
editable: true,
fields: ['question4'],
template: 'question',
next: 'question5'
},
'/question5': {
editable: true,
fields: ['question5'],
template: 'question',
next: 'done'
Expand Down
1 change: 1 addition & 0 deletions example/routes/multiwizard/fields1.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = {
age: {
type: 'number',
journeyKey: 'myage',
validate: [
'required',
Expand Down
22 changes: 1 addition & 21 deletions example/views/pages/basic/favorite-color.html
Original file line number Diff line number Diff line change
@@ -1,21 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-select/macro.njk" import hmpoSelect %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.color.label" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoSelect(ctx, {
id: "color",
placeholder: true,
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
12 changes: 1 addition & 11 deletions example/views/pages/basic/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}
{% extends "form-template.njk" %}

{% set hmpoPageKey = "basic.index" %}
{% set backLink = "/" %}

{% block content %}
{{ super() }}
{% call hmpoForm(ctx) %}
{{ hmpoSubmit(ctx) }}
{% endcall %}
{% endblock %}
13 changes: 1 addition & 12 deletions example/views/pages/basic/submit.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}
{% extends "form-template.njk" %}

{% set hmpoPageKey = "basic.submit" %}

{% block content %}
{{ super() }}

{% call hmpoForm(ctx) %}
{{ hmpoSubmit(ctx) }}
{% endcall %}
{% endblock %}
21 changes: 1 addition & 20 deletions example/views/pages/basic/your-age.html
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-number/macro.njk" import hmpoNumber %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.age.label" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoNumber(ctx, {
id: "age",
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
21 changes: 1 addition & 20 deletions example/views/pages/basic/your-name.html
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-text/macro.njk" import hmpoText %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.name.label" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoText(ctx, {
id: "name",
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
21 changes: 1 addition & 20 deletions example/views/pages/branching/choose-direction.html
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-radios/macro.njk" import hmpoRadios %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.direction.legend" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoRadios(ctx, {
id: "direction",
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
12 changes: 1 addition & 11 deletions example/views/pages/branching/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}
{% extends "form-template.njk" %}

{% set hmpoPageKey = "branching.index" %}
{% set backLink = "/" %}

{% block content %}
{{ super() }}
{% call hmpoForm(ctx) %}
{{ hmpoSubmit(ctx) }}
{% endcall %}
{% endblock %}
21 changes: 1 addition & 20 deletions example/views/pages/branching/left-branch.html
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-text/macro.njk" import hmpoText %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.left-only.label" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoText(ctx, {
id: "left-only",
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
12 changes: 1 addition & 11 deletions example/views/pages/branching/neither-branch.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}
{% extends "form-template.njk" %}

{% set hmpoPageKey = "branching.neither" %}

{% block content %}
{% super() %}
{% call hmpoForm(ctx) %}
{{ hmpoSubmit(ctx) }}
{% endcall %}
{% endblock %}
21 changes: 1 addition & 20 deletions example/views/pages/branching/right-branch.html
Original file line number Diff line number Diff line change
@@ -1,20 +1 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-text/macro.njk" import hmpoText %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}

{% set hmpoTitleKey = "fields.right-only.label" %}

{% block content %}
{% call hmpoForm(ctx) %}

{{ hmpoText(ctx, {
id: "right-only",
isPageHeading: true
}) }}

{{ hmpoSubmit(ctx) }}

{% endcall %}
{% endblock %}
{% extends "form-template.njk" %}
2 changes: 1 addition & 1 deletion example/views/pages/file-not-found.html
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
{% extends "hmpo-template.njk" %}
{% set hmpoPageKey = "fileNodeFound" %}
{% set hmpoPageKey = "fileNotFound" %}
12 changes: 1 addition & 11 deletions example/views/pages/invalidation/index.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
{% from "hmpo-form/macro.njk" import hmpoForm %}
{% from "hmpo-submit/macro.njk" import hmpoSubmit %}

{% extends "hmpo-template.njk" %}
{% extends "form-template.njk" %}

{% set hmpoPageKey = "invalidation.index" %}
{% set backLink = "/" %}

{% block content %}
{{ super() }}
{% call hmpoForm(ctx) %}
{{ hmpoSubmit(ctx) }}
{% endcall %}
{% endblock %}
Loading

0 comments on commit 453555a

Please sign in to comment.