Giter Club home page Giter Club logo

hmrc-frontend-scaffold.g8's Introduction

hmrc-frontend-scaffold.g8

This repository is a Giter8 template to make building frontend services on the HMRC Multichannel Digital Tax Platform (MDTP) easier.

Detailed Documentation

Please see the wiki for detailed documentation (currently a work in progress). An example service built using these scaffolds will be available soon for reference.

Where to get help

If you're thinking of using this scaffold to create a new service, or have any questions about it, please get in touch - drop us a line in our Slack channel (requires an HMRC slack account).

What is it?

This repository is a template that generates a Scala Play! frontend service ready for use on the MDTP. It brings in all of the core libraries you need, and includes some useful components, patterns and scaffolds to make solving common problems easier.

In particular, it makes it extremely quick and easy to create one-question-per-page user journeys, caching the user's answers as they go.

What it isn't

It isn't a framework or a forms engine. It just gives you a plain old Scala microservice which you can develop, iterate and change as you like. While you'll get the most benefit by using the patterns and scaffolds as-is, you aren't tied in to them; you're free to use or ignore them as you choose.

It also doesn't try to solve every problem. It takes a lot of the grunt work out of creating screens, and makes it easy to wire them together into journeys; but you'll still need to do the wiring up, and of course handle any interactions with other microservices etc. that you need.

Usage

Before you start

Please drop by our Slack channel to say hi and see if we can offer you any support or guidance (requires an HMRC slack account).

You will need to have sbt version 0.13.13 or later installed.

Creating a new service

To create a new service:

  • Run sbt new hmrc/hmrc-frontend-scaffold.g8 and supply a name, e.g. example-frontend.
  • cd into the new directory, e.g. cd example-frontend
  • Initialise a git repo and make an initial commit, e.g. git init && git add . && git commit -m 'Initial commit'
  • Create a repository.yaml file and add the "repoVisibility: xxxxx" line to it (these can be copied from another HMRC repo - public one can be found in this repo), replace xxxxx with the actual string.

Adding new pages using scaffolds

In your service's root directory is a hidden directory .g8, which contains all of the scaffolds available for you to use. Each will add a new screen or suite of related screens into your service.

To use a scaffold, run sbt in interactive mode and issue the command g8Scaffold scaffoldName, e.g. g8Scaffold yesNoPage. The scaffold will ask you for some inputs, and create some new files (e.g. the yesNoPage scaffold will create a controller, view, and some specs).

Exit out of sbt and run the bash script migrate.sh in the root directory of your service. This will modify a couple of files in the service, including routes and messages.

Contributing

If you’ve spotted an issue or thought of a feature that you’d like to contribute to the scaffold, please take a few minutes to review our contribution process and guidelines before you submit your request.

License

This code is open source software licensed under the Apache 2.0 License.

hmrc-frontend-scaffold.g8's People

Contributors

adamliptrot-oc avatar callumcodes avatar chrisjameswright avatar darbyo avatar grab-a-byte avatar hmrc-web-operations avatar ian-hmrc avatar kurtlogan avatar lesjoneshmrc avatar markhunter27 avatar mjcallahanpage avatar muhammad-ali-ahmad avatar oliverslade avatar shnick avatar thenickwilson avatar tomasz-rosiek avatar wolfendale avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hmrc-frontend-scaffold.g8's Issues

Language toggle causes failing tests

Language toggle causes failing tests

If you update the application.conf file to have "welsh-translation: false" this will then cause each view to fail tests for the ViewBehaviours "display language toggles" tests.

Proposed solution

Add a logic into the test to check if the language toggle is required, if true then run test else ignore the test as this is now redundant.

How to recreate

Open the applicaion.conf file in a project with views and switch "welsh-translation: true" to "false", run sbt test.

"Get help with this page" does not render locally

"Get help with this page" does not render locally

The "Get help with this page" link does not render the view locally even with the service running.
This is because the port contact-frontend runs on is blocked by the security policy.

gethelp

Proposed solution

Add the contact-frontend port to the security policy.

How to recreate

Click "Get help with this page"

Update radio buttons

Update radio buttons

Update the markup for the yes/no page and options page to match the current standard

Use language select helper from play-frontend-hmrc

Use language select helper from play-frontend-hmrc

The hmrcLanguageSelectHelper has been added to reduce the code needed to support Welsh language translation.

Proposed solution

Update views/templates/Layout.scala.html to make use of the new helper. There is an example in the documentation but this will need adjusting to include the toggle and passing through the back link toggle.

Default heading size is incorrect

Default heading size is incorrect

Bug

The default heading size in the heading component should be heading-xlarge rather than heading-medium.

Explicitly type public methods

Explicitly type public methods

Public methods should be explicitly typed; there are currently several methods (e.g. the onPageLoad and onSubmit methods on controllers) which aren't.

Nunjucks branch: Reverse router fails in the template when the router function takes a class (not an object)

The reverse router fails when renderer fails when the router function (method) takes a class

The reverse router in the samples only takes an object (NormalMode or CheckMode) which integrates fine with the reverse router (the runtime doesn't have a problem working out what object this is from a String input). This however fails if the parameter is a class and an if an instance is passed to the view, the Play's Json library will do a toString which the runtime cannot do anything with.

The most obvious point where this is a problem is when the reverse router is used to generate a form's action value. In this case the reverse router returns an empty string and the HTML is rendered "fine". This is an accessibility issue.

Proposed solution

Do all reverse route lookup server side and pass it to the view as a string value via a ViewModel that can be serialised to a Json object.

How to recreate

Create a controller endpoint that takes a class instance as a parameter.

Sbt's supershell deletes lines when using gitter8 and looks like the process is hanging

Sbt's supershell deletes lines when using gitter8 and looks like the process is hanging

Sbt's supershell feature interferes and removes the output from g8 when scaffolding based on a template. This makes it look like the process is hanging when it is in fact waiting for user input.

Proposed solution

Disable supershell by default (example: https://github.com/hmrc/declare-transit-movement-arrival-frontend/blob/master/build.sbt#L56)

Projects generated don't run on Mac with arm64 hardware

Projects generated don't run on Mac with arm64 hardware

Generating a new project from this template and then attempting to run it on Mac with arm64 hardware crashes in the JNA native layer from the sbt-sassify project.

Proposed solution

Update the sbt-sassify from 1.5.1 to 1.5.2 to address this.

How to recreate

Run a generated project on Mac with arm64 hardware.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.