diff --git a/package.json b/package.json index 76e5a33..7926b5d 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,8 @@ "test:watch": "mocha --watch", "mocks": "yarn run wiremock --port 8030 --root-dir test/mocks", "test:browser": "wait-on tcp:8030 tcp:5030 && cucumber-js --config test/browser/cucumber.js", - "test:browser:ci": "npm-run-all -p -r start:ci mocks test:browser" + "test:browser:ci": "npm-run-all -p -r start:ci mocks test:browser", + "check-translation": "node node_modules/di-ipv-cri-common-express/scripts/checkTranslations.js" }, "repository": { "type": "git", @@ -70,12 +71,12 @@ "cfenv": "1.2.4", "connect-dynamodb": "^2.0.5", "copyfiles": "2.4.1", - "di-ipv-cri-common-express": "alphagov/di-ipv-cri-common-express.git#v0.0.38", + "di-ipv-cri-common-express": "alphagov/di-ipv-cri-common-express.git#v0.0.39", "dotenv": "^16.0.1", "express": "4.18.1", "express-async-errors": "^3.1.1", "express-session": "^1.17.3", - "govuk-frontend": "4.2.0", + "govuk-frontend": "4.5.0", "hmpo-app": "2.4.0", "hmpo-components": "5.7.0", "hmpo-config": "2.2.1", diff --git a/src/assets/scss/application.scss b/src/assets/scss/application.scss index fc659c6..68cd1d7 100644 --- a/src/assets/scss/application.scss +++ b/src/assets/scss/application.scss @@ -12,6 +12,11 @@ $govuk-assets-path: "/public/"; background-color: $govuk-error-colour; } +// remove the resize option on the driving licence number character count +// To match both the DVLA and DVA forms this selector looks for any textarea +// that contains the string 'LicenceNumber' anywhere in the class name +textarea[name*="LicenceNumber"] {resize: none;} + //// Task list pattern // //.app-task-list { diff --git a/src/locales/cy/default.yml b/src/locales/cy/default.yml index c222e53..17b09c6 100644 --- a/src/locales/cy/default.yml +++ b/src/locales/cy/default.yml @@ -31,7 +31,7 @@ govuk: paragraph2: unrhyw bryd. buttonAcceptText: Derbyn cwcis dadansoddi buttonRejectText: Gwrthod cwcis dadansoddi - linkViewCookies: Gweld cwcis + linkViewCookiesText: Gweld cwcis cookieBannerHideLink: Cuddio'r neges yma footerNavItems: meta: @@ -66,6 +66,11 @@ drivingLicence: retryMessageList2: rydych wedi rhoi eich rhif trwydded yrru yn gywir retryMessageList3: bod dyddiau a misoedd yn y drefn gywir yn eich dyddiad geni, dyddiad cyhoeddi a dyddiad dilys tan retryMessageList4: you’ve left the middle names section blank if you do not have any middle names + charactersUnderLimitTextOther: Mae gennych %{count} nod ar ôl + charactersUnderLimitTextOne: Mae gennych %{count} nod ar ôl + charactersAtLimitText: Mae gennych 0 nod ar ôl + charactersOverLimitTextOne: Mae gennych %{count} nod yn ormod + charactersOverLimitTextOther: Mae gennych %{count} nod yn ormod prove-another-way: title: Profi pwy ydych chi mewn ffordd arall diff --git a/src/locales/cy/fields.yml b/src/locales/cy/fields.yml index f811473..a80487a 100644 --- a/src/locales/cy/fields.yml +++ b/src/locales/cy/fields.yml @@ -1,6 +1,7 @@ drivingLicenceNumber: label: Rhif trwydded hint: "Dyma'r rhif hir yn adran 5 ar eich trwydded er enghraifft HARRI559146MJ931" + maxlength: false validation: default: "Rhowch y rhif yn union fel mae’n ymddangos ar eich trwydded yrru" exactlength: "Dylai rhif eich trwydded fod yn 16 nod o hyd" @@ -8,6 +9,7 @@ drivingLicenceNumber: limit: "Driving licence numbers do not start with 16 – enter the number as it appears on your driving licence" dvlaChecker: "Rhowch y rhif yn union fel mae’n ymddangos ar eich trwydded yrru" regexSpecialCharacters: "Ni ddylai rhif eich trwydded gynnwys unrhyw symbolau neu ofodau" + dvaLicenceNumber: label: Rhif trwydded hint: "Dyma'r rhif hir yn adran 5 ar eich trwydded" @@ -15,6 +17,8 @@ dvaLicenceNumber: default: "Rhowch y rhif yn union fel mae’n ymddangos ar eich trwydded yrru" exactlength: "Dylai rhif eich trwydded fod yn 8 nod o hyd" numeric: "Ni ddylai rhif eich trwydded gynnwys unrhyw symbolau neu ofodau" + regexSpecialCharacters: "Ni ddylai rhif eich trwydded gynnwys unrhyw symbolau neu ofodau" + issueNumber: label: Rhif cyhoeddi hint: "Dyma'r rhif 2 ddigid ar ôl y gofod yn adran 5 o'ch trwydded" @@ -22,6 +26,7 @@ issueNumber: default: "Rhowch y rhif cyhoeddi fel y mae'n ymddangos ar eich trwydded yrru" exactlength: "Dylai eich rhif cyhoeddi fod yn 2 rif o hyd" numeric: "Ni ddylai eich rhif cyhoeddi gynnwys unrhyw symbolau neu ofodau" + regexSpecialCharacters: "Ni ddylai rhif eich trwydded gynnwys unrhyw symbolau neu ofodau" surname: label: Enw olaf @@ -54,6 +59,7 @@ dateOfBirth: default: "Rhowch eich dyddiad geni fel y mae'n ymddangos ar eich trwydded yrru" before: "Rhaid i'ch dyddiad geni fod yn y gorffennol" dvlaChecker: "Gwiriwch eich bod wedi rhoi eich dyddiad geni yn gywir" + dvaDateOfBirth: legend: Dyddiad geni hint: "Er enghraifft, 5 9 1973" diff --git a/src/locales/en/default.yml b/src/locales/en/default.yml index 369393c..0f9ab6d 100644 --- a/src/locales/en/default.yml +++ b/src/locales/en/default.yml @@ -66,6 +66,11 @@ drivingLicence: retryMessageList2: you’ve entered your driving licence number correctly retryMessageList3: days and months are in the right order in your date of birth, issue date and valid to date retryMessageList4: you’ve left the middle names section blank if you do not have any middle names + charactersUnderLimitTextOther: You have %{count} characters remaining + charactersUnderLimitTextOne: You have %{count} character remaining + charactersAtLimitText: You have 0 characters remaining + charactersOverLimitTextOne: You have %{count} character too many + charactersOverLimitTextOther: You have %{count} characters too many prove-another-way: title: Prove your identity another way diff --git a/src/locales/en/fields.yml b/src/locales/en/fields.yml index 3ff3d6d..e692fef 100644 --- a/src/locales/en/fields.yml +++ b/src/locales/en/fields.yml @@ -1,6 +1,7 @@ drivingLicenceNumber: label: Licence number hint: "This is the long number in section 5 on your licence for example HARRI559146MJ931" + maxlength: false validation: default: "Enter the number exactly as it appears on your driving licence" exactlength: "Your licence number should be 16 characters long" @@ -8,6 +9,7 @@ drivingLicenceNumber: limit: "Driving licence numbers do not start with 16 – Enter the number exactly as it appears on your driving licence" dvlaChecker: "Enter the number exactly as it appears on your driving licence" regexSpecialCharacters: "Your licence number should not include any symbols or spaces" + dvaLicenceNumber: label: Licence number hint: "This is the long number in section 5 on your licence" @@ -16,6 +18,7 @@ dvaLicenceNumber: exactlength: "Your licence number should be 8 characters long" regexSpecialCharacters: "Your licence number should not include any symbols or spaces" numeric: "Enter the number exactly as it appears on your driving licence" + issueNumber: label: Issue number hint: "This is the 2 digit number after the space in section 5 of your licence" @@ -23,6 +26,7 @@ issueNumber: default: "Enter the issue number as it appears on your driving licence" exactlength: "Your issue number should be 2 numbers long" regexSpecialCharacters: "Your issue number should not include any symbols or spaces" + numeric: "Enter the number exactly as it appears on your driving licence" surname: label: Last name diff --git a/src/views/drivingLicence/details.html b/src/views/drivingLicence/details.html index 642da10..f31997c 100644 --- a/src/views/drivingLicence/details.html +++ b/src/views/drivingLicence/details.html @@ -8,6 +8,7 @@ {% from "govuk/components/inset-text/macro.njk" import govukInsetText %} {% from "hmpo-text/macro.njk" import hmpoText %} +{% from "./hmpoCountText.njk" import hmpoCountText %} {% from "hmpo-form/macro.njk" import hmpoForm %} {% from "hmpo-date/macro.njk" import hmpoDate %} @@ -23,7 +24,7 @@

{{ translate("drivingLicence.title") }}

- {% endif %} +{% endif %} {% if values.showRetryMessage and not (ctx("errors") | length) %} {# user is retrying, show more information about how to complete the form #} @@ -57,9 +58,9 @@

{{ translate("drivingLicence.retryMessageHeading") }}

{# user's first attempt #} {% if (values.licenceIssuer == "DVA") %} -

{{ translate("drivingLicence.checkDetailsContextDVA") }}

+

{{ translate("drivingLicence.checkDetailsContextDVA") }}

{% else %} -

{{ translate("drivingLicence.checkDetailsContext") }}

+

{{ translate("drivingLicence.checkDetailsContext") }}

{% endif %} {% endif %} @@ -68,7 +69,7 @@

{{ translate("drivingLicence.retryMessageHeading") }}

html: translate("drivingLicence.drivingLicenceTryAnotherWay") }) }} - {% call hmpoForm(ctx, {attributes: {onsubmit: 'window.disableFormSubmit()'} }) %} +{% call hmpoForm(ctx, {attributes: {onsubmit: 'window.disableFormSubmit()'} }) %} {{ hmpoText(ctx, { id: "surname", @@ -83,16 +84,16 @@

{{ translate("drivingLicence.retryMessageHeading") }}

{% if firstNameError and middleNameError %}
- {% else %} -
- {% endif %} + {% else %} +
+ {% endif %} - {% call govukFieldset({ - legend: { - text: translate("drivingLicence.drivingLicenceGivenNames"), - classes: "govuk-!-margin-0" - } - }) %} + {% call govukFieldset({ + legend: { + text: translate("drivingLicence.drivingLicenceGivenNames"), + classes: "govuk-!-margin-0" + } + }) %}
{{ hmpoText(ctx, { id: "firstName", @@ -113,53 +114,53 @@

{{ translate("drivingLicence.retryMessageHeading") }}

{% endcall %}
- {% if (values.licenceIssuer == "DVLA") %} + {% if (values.licenceIssuer == "DVLA") %} - {{ hmpoDate(ctx, { - id: "dateOfBirth", - legend: { - classes: "govuk-label" - } - }) }} - - {{ hmpoText(ctx, { - id: "dvlaDependent", - type: "hidden", - legend: "", - default: "DVLA" - }) }} - - {{ hmpoDate(ctx, { - id: "issueDate", - legend: { - classes: "govuk-label" - } - }) }} + {{ hmpoDate(ctx, { + id: "dateOfBirth", + legend: { + classes: "govuk-label" + } + }) }} - {% else %} + {{ hmpoText(ctx, { + id: "dvlaDependent", + type: "hidden", + legend: "", + default: "DVLA" + }) }} - {{ hmpoDate(ctx, { - id: "dvaDateOfBirth", - legend: { - classes: "govuk-label" - } - }) }} - - {{ hmpoText(ctx, { - id: "dvaDependent", - type: "hidden", - legend: "", - default: "DVA" - }) }} - - {{ hmpoDate(ctx, { - id: "dateOfIssue", - legend: { - classes: "govuk-label" - } - }) }} + {{ hmpoDate(ctx, { + id: "issueDate", + legend: { + classes: "govuk-label" + } + }) }} + + {% else %} + + {{ hmpoDate(ctx, { + id: "dvaDateOfBirth", + legend: { + classes: "govuk-label" + } + }) }} - {% endif %} + {{ hmpoText(ctx, { + id: "dvaDependent", + type: "hidden", + legend: "", + default: "DVA" + }) }} + + {{ hmpoDate(ctx, { + id: "dateOfIssue", + legend: { + classes: "govuk-label" + } + }) }} + + {% endif %} {{ hmpoDate(ctx, { id: "expiryDate", @@ -169,31 +170,48 @@

{{ translate("drivingLicence.retryMessageHeading") }}

}) }} {% if (values.licenceIssuer == "DVLA") %} - {{ hmpoText(ctx, { - id: "drivingLicenceNumber", - label: { - classes: "govuk-label" - } + + {{ hmpoCountText(ctx, { + id: "drivingLicenceNumber", + label: { + classes: "govuk-label" + }, + i18n:{ + charactersUnderLimitTextOther:translate("drivingLicence.charactersUnderLimitTextOther"), + charactersUnderLimitTextOne:translate("drivingLicence.charactersUnderLimitTextOne"), + charactersAtLimitText:translate("drivingLicence.charactersAtLimitText"), + charactersOverLimitTextOne:translate("drivingLicence.charactersOverLimitTextOne"), + charactersOverLimitTextOther:translate("drivingLicence.charactersOverLimitTextOther") + } }) }} - {{ hmpoText(ctx, { - id: "issueNumber", - label: { - classes: "govuk-label" - } - }) }} + {{ hmpoText(ctx, { + id: "issueNumber", + classes: "govuk-input--width-3", + label: { + classes: "govuk-label" + } + }) }} {% else %} - {{ hmpoText(ctx, { - id: "dvaLicenceNumber", - label: { - classes: "govuk-label" - } + + {{ hmpoCountText(ctx, { + id: "dvaLicenceNumber", + label: { + classes: "govuk-label" + }, + i18n:{ + charactersUnderLimitTextOther:translate("drivingLicence.charactersUnderLimitTextOther"), + charactersUnderLimitTextOne:translate("drivingLicence.charactersUnderLimitTextOne"), + charactersAtLimitText:translate("drivingLicence.charactersAtLimitText"), + charactersOverLimitTextOne:translate("drivingLicence.charactersOverLimitTextOne"), + charactersOverLimitTextOther:translate("drivingLicence.charactersOverLimitTextOther") + } }) }} {% endif %} - {{ hmpoText(ctx, { + {{ hmpoText(ctx, { id: "postcode", label: { classes: "govuk-label" @@ -201,54 +219,56 @@

{{ translate("drivingLicence.retryMessageHeading") }}

}) }} {% if values.showRetryMessage and not (ctx("errors") | length) %} - {# user is retrying, show warning message they have run out of attempts #} - {{ govukWarningText({ - text: translate("drivingLicence.retryWarningText"), - iconFallbackText: translate("drivingLicence.retryWarningTitle") - }) }} + {# user is retrying, show warning message they have run out of attempts #} + {{ govukWarningText({ + text: translate("drivingLicence.retryWarningText"), + iconFallbackText: translate("drivingLicence.retryWarningTitle") + }) }} {% endif %} - {{ hmpoSubmit(ctx, {id: "continue", text: translate("buttons.next")}) }} + {{ hmpoSubmit(ctx, {id: "continue", text: translate("buttons.next")}) }} {% endcall %} {% endblock %} + {% block scripts %} -{{ super ()}} + {{ super ()}} - + + {% endblock %} + {# generate the specific footer items required for the PYI flows #} {% set footerNavItems = translate("govuk.footerNavItems") %} - {% block footer %} {{ govukFooter( footerNavItems ) }} {% endblock %} diff --git a/src/views/drivingLicence/hmpoCountText.njk b/src/views/drivingLicence/hmpoCountText.njk new file mode 100644 index 0000000..d8be048 --- /dev/null +++ b/src/views/drivingLicence/hmpoCountText.njk @@ -0,0 +1,71 @@ + +{% macro hmpoCountText(ctx, params, base) %} + + {%- set params = hmpoGetParams(ctx, params, base) %} + + {%- set pageHeading = { + isPageHeading: true, + classes: "govuk-label--l" + } if params.isPageHeading %} + + {%- set args = { + id: params.id, + name: params.id, + label: merge( + pageHeading, + { attributes: { id: params.id + "-label" } }, + hmpoGetOptions(ctx, params, "label") + ), + hint: hmpoGetOptions(ctx, params, "hint", true), + value: hmpoGetValue(ctx, params), + errorMessage: hmpoGetError(ctx, params), + type: params.type, + inputmode: params.inputmode, + classes: "" + (params.classes if params.classes else "govuk-!-width-one-half") + (" js-nopaste" if params.noPaste), + formGroup: params.formGroup, + autocomplete: params.autocomplete, + rows: params.rows, + i18n: params.i18n, + attributes: hmpoGetAttributes(ctx, params, { + "aria-required": hmpoGetValidatorAttribute(ctx, params, "required", null, false), + "min": hmpoGetValidatorAttribute(ctx, params, "min", 0), + "max": hmpoGetValidatorAttribute(ctx, params, "max", 0), + "maxlength": hmpoGetValidatorAttribute(ctx, params, "maxlength", 0) or hmpoGetValidatorAttribute(ctx, params, "exactlength", 0) + } | filter(null)) + } %} + + {%- if params.type == "textarea" %} + {%- from "govuk/components/textarea/macro.njk" import govukTextarea %} + {{- govukTextarea(args) }} + {%- else %} + {%- from "govuk/components/character-count/macro.njk" import govukCharacterCount %} + {%- from "govuk/components/input/macro.njk" import govukInput %} + + {# {{- govukInput(args) }} #} + {{ govukCharacterCount({ + name: args.name, + id: args.id, + maxlength: args.attributes.maxlength, + rows:1, + value: args.value, + label: { + id:args.label.id, + text: args.label.html, + classes: args.label.classes, + isPageHeading: false + }, + hint: { + text: args.hint.html + }, + charactersUnderLimitText: { + other: args.i18n.charactersUnderLimitTextOther, + one: args.i18n.charactersUnderLimitTextOne + }, + charactersOverLimitText: { + one: args.i18n.charactersOverLimitTextOne, + other: args.i18n.charactersOverLimitTextOther + }, + charactersAtLimitText: args.i18n.charactersAtLimitText + }) }} + {%- endif %} +{% endmacro %}