This project uses an existing HMRC digital form as a template for conversion to a Scala web application using code scaffolds
The steps to add a new page are as follows:
- In sbt run
g8Scaffold yesNoPage
or whichever scaffold you want to apply - the options are:intPage
- a page with a single text field for a whole-number valueoptionsPage
- a page with a set of radio buttonsquestionPage
- a page with multiple questions on it backed by a case classrepeater
- a set of screens to allow multiple items to be addedyesNoPage
- a page with a pair of yes/no radio optionsstringPage
- a page with a single text field for a string value
- It will ask for a name which should be CamelCased, e.g.
ChildAgedTwo
. This will be used throughout, so for example you'll get aChildAgedTwoController
,ChildAgedTwoForm
etc. as needed - Exit sbt and run the script
./migrate.sh
- Run
sbt test
git add .
andgit commit
your work at this point
You'll then need to touch these areas yourself as needed (and the order is less important):
- Change
NavigatorSpec
andNavigator
to include your page in the routing - If necessary, change
CascadeUpsertSpec
andCascadeUpsert
to add any data-cleanup logic you may need - Add in the messages, and add any guidance etc. you need to the screen. You can easily test this in the relevant
ViewSpec
- Change the URLs in
app.routes
as necessary - If you're using a Check Your Answers page, add the new screen to that and add appropriate tests
- If you added an
optionsPage
you can change the available options informs\<YourClass>Form
- If you added a
questionPage
you'll need to changemodels\<YourClass>
,forms\<YourClass>Form
andviews\<yourClass>
as needed, along with the relevant tests and messages - If you added an
intPage
you may want to change the validation informs\<YourClass>Form
- by default it expects non-negative numbers (0 or greater) which you may want to change, or you may need to add a maximum value etc.