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

ROD-92 Create a reference number page #49

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/cancel-request/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,12 @@
}
}
},
"cnc-email":{
"cnc-email": {
"label": "Email address",
"hint": "This is where the Home Office will contact you about your request to cancel documents being returned"
},
"cnc-telephone":{
"cnc-telephone": {
"label": "Contact telephone number",
"hint": "For international numbers, include the country code"
}
}

52 changes: 42 additions & 10 deletions apps/rod/behaviours/custom-validation.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,44 @@
module.exports = superclass => class extends superclass {
validateField(key, req) {
if (key === 'cancel-application') {
const dependent = req.form.options.fields[key].dependent;
const dependentValue = req.sessionModel.get(dependent.field);
if (dependentValue && dependentValue === dependent.value) {
return null;
const validators = require('hof/controller/validation/validators');

module.exports = superclass =>
class extends superclass {
validateField(key, req) {
const validationErrorFunc = (type, args) =>
new this.ValidationError(key, { type: type, arguments: [args] });

if (key === 'cancel-application') {
const dependent = req.form.options.fields[key].dependent;
const dependentValue = req.sessionModel.get(dependent.field);
if (dependentValue && dependentValue === dependent.value) {
return null;
}
}

if (
req.form.values['rod-reference-number']?.includes(
'ho-reference-number'
) &&
key === 'rod-ho-reference-number'
) {
const hoRefNum = req.form.values[key];
if (hoRefNum) {
const valueWithoutSpace = hoRefNum.replace(/\s+/g, '').trim();

if (!validators.minlength(valueWithoutSpace, 8)) {
return validationErrorFunc('minlength', 8);
}
if (!validators.maxlength(valueWithoutSpace, 8)) {
return validationErrorFunc('maxlength', 8);
}
if (valueWithoutSpace.match(/\W|_/g)) {
return validationErrorFunc('specialCharacter');
}
if (!valueWithoutSpace.match(/^[A-Z]\d+$/i)) {
return validationErrorFunc('hoRefNum');
}
}
}

return super.validateField(key, req);
}
return super.validateField(key, req);
}
};
};
88 changes: 74 additions & 14 deletions apps/rod/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,91 @@ module.exports = {
},
'main-applicant-address-1': {
mixin: 'input-text',
validate: [
'required',
'notUrl',
{ type: 'maxlength', arguments: 250 }
]
validate: ['required', 'notUrl', { type: 'maxlength', arguments: 250 }]
},
'main-applicant-address-2': {
mixin: 'input-text',
validate: [
'notUrl',
{ type: 'maxlength', arguments: 250 }
]
validate: ['notUrl', { type: 'maxlength', arguments: 250 }]
},
'main-applicant-town-or-city': {
mixin: 'input-text',
validate: [
'required',
'notUrl',
{ type: 'maxlength', arguments: 250 }
]
validate: ['required', 'notUrl', { type: 'maxlength', arguments: 250 }]
},
'main-applicant-postcode': {
mixin: 'input-text',
validate: ['required', 'notUrl', postCode, 'postcode'],
formatter: ['ukPostcode'],
className: ['govuk-input--width-10', 'govuk-input']
},
'rod-reference-number': {
mixin: 'checkbox-group',
labelClassName: 'govuk-label--s',
isPageHeading: true,
validate: ['required'],
options: [
{
value: 'case-id',
toggle: 'rod-case-id',
child: 'input-text'
},
{
value: 'ho-reference-number',
toggle: 'rod-ho-reference-number',
child: 'input-text'
},
{
value: 'payment-reference-number',
toggle: 'rod-payment-reference-number',
child: 'input-text'
},
{
value: 'courier-reference-number',
toggle: 'rod-courier-reference-number',
child: 'input-text'
}
]
},
'rod-case-id': {
dependent: {
field: 'rod-reference-number',
value: 'case-id'
},
className: ['govuk-input', 'govuk-!-width-two-thirds'],
validate: [
'required',
{ type: 'maxlength', arguments: 8 },
{ type: 'minlength', arguments: 8 },
'numeric',
'notUrl'
]
},
'rod-ho-reference-number': {
dependent: {
field: 'rod-reference-number',
value: 'ho-reference-number'
},
className: ['govuk-input', 'govuk-!-width-two-thirds'],
validate: [
'required',
{ type: 'minlength', arguments: 8 },
'notUrl',
{ type: 'maxlength', arguments: 250 }
]
},
'rod-payment-reference-number': {
dependent: {
field: 'rod-reference-number',
value: 'payment-reference-number'
},
className: ['govuk-input', 'govuk-!-width-two-thirds'],
validate: ['required', { type: 'maxlength', arguments: 100 }, 'notUrl']
},
'rod-courier-reference-number': {
dependent: {
field: 'rod-reference-number',
value: 'courier-reference-number'
},
className: ['govuk-input'],
validate: ['required', { type: 'maxlength', arguments: 100 }, 'notUrl']
}
};
15 changes: 12 additions & 3 deletions apps/rod/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ module.exports = {
next: '/reference-number'
},

'/proof-of-identity': {},
'/proof-of-identity': {

'/reference-number': {
next: '/your-documents'
},
'/your-documents': {
fields: ['document-type', 'enter-document-type', 'document-description'],
Expand Down Expand Up @@ -202,6 +200,17 @@ module.exports = {
fields: ['notes'],
next: '/confirm'
},
'/reference-number': {
behaviours: [customValidation],
fields: [
'rod-reference-number',
'rod-case-id',
'rod-ho-reference-number',
'rod-payment-reference-number',
'rod-courier-reference-number'
],
next: '/your-documents'
},
'/confirm': {
behaviours: [SummaryPageBehaviour],
sections: require('./sections/summary-data-sections'),
Expand Down
23 changes: 23 additions & 0 deletions apps/rod/sections/summary-data-sections.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,29 @@ module.exports = {
{
step: '/extra-notes',
field: 'notes'
},
{
step: '/reference-number',
field: 'rod-reference-number',
parse: value => {
return Array.isArray(value) ? value.map(option => option).join('\n') : value;
}
},
{
step: '/reference-number',
field: 'rod-case-id'
},
{
step: '/reference-number',
field: 'rod-ho-reference-number'
},
{
step: '/reference-number',
field: 'rod-payment-reference-number'
},
{
step: '/reference-number',
field: 'rod-courier-reference-number'
}
]
};
34 changes: 34 additions & 0 deletions apps/rod/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,40 @@
},
"notes": {
"label": "Enter any relevant details about your request, for example if you need your documents urgently"
},
"rod-reference-number": {
"legend": "Which reference number can you provide?",
"options": {
"case-id": {
"label": "Case ID",
"hint": "The main applicant received this number when they applied. For example, 12345678"
},
"ho-reference-number": {
"label": "Home Office reference number",
"hint": "This is on official documents, such as letters about your immigration status or biometric residence permit cards. For example, A1234567"
},
"payment-reference-number": {
"label": "Payment reference number",
"hint": "This is on the letter the Home Office sent to the main applicant confirming they received an application"
},
"courier-reference-number": {
"label": "Courier reference number",
"hint": "This includes Royal Mail reference numbers"
}
}
},
"rod-case-id": {
"label": "Enter the case ID"
},
"rod-ho-reference-number": {
"label": "Enter the Home Office reference number"
},
"rod-payment-reference-number": {
"label": "Enter the payment reference number"
},
"rod-courier-reference-number": {
"label": "Enter the courier reference number",
"hint": "Royal Mail reference numbers are between 9 and 27 characters long"
},
"declaration-check": {
"label": "I understand and agree to this declaration"
Expand Down
15 changes: 15 additions & 0 deletions apps/rod/translations/src/en/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@
},
"notes": {
"label": "Notes"
},
"rod-reference-number": {
"label": "Reference number"
},
"rod-case-id": {
"label": "Case ID"
},
"rod-ho-reference-number": {
"label": "Home Office reference number"
},
"rod-payment-reference-number": {
"label": "Payment reference number"
},
"rod-courier-reference-number": {
"label": "Courier reference number"
}
}
},
Expand Down
28 changes: 28 additions & 0 deletions apps/rod/translations/src/en/validation.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,33 @@
"notUrl": "Answer must not contain a URL. Remove any links, URLs or special characters like /@:%_+~#=\\ from your answer",
"postCode": "Postcode must only include letters a-z, numbers and spaces",
"postcode": "Enter a real UK postcode"
},
"rod-reference-number": {
"required": "You must provide a reference number. Select one you can provide"
},
"rod-case-id": {
"required": "Enter a case ID",
"minlength": "Case ID must be at least 8 numbers",
"maxlength": "Case ID cannot be more than 8 numbers",
"numeric": "Case ID can only include numbers",
"notUrl": "Answer must not contain a URL. Remove any links, URLs or special characters like /@:%_+~#=\\ from your answer."
},
"rod-ho-reference-number": {
"required": "Enter a Home Office reference number",
"minlength": "Home Office reference must be at least 8 characters",
"maxlength": "Home Office reference number cannot be more than 8 numbers",
"hoRefNum": "Home Office reference number must start with a letter, followed by 7 numbers",
"specialCharacter": "Home Office reference number must only include letters and numbers",
"notUrl": "Answer must not contain a URL. Remove any links, URLs or special characters like /@:%_+~#=\\ from your answer."
},
"rod-payment-reference-number": {
"required": "Enter a payment reference number",
"maxlength": "Payment reference number cannot be more than 100 characters",
"notUrl": "Answer must not contain a URL. Remove any links, URLs or special characters like /@:%_+~#=\\ from your answer."
},
"rod-courier-reference-number": {
"required": "Enter a courier reference number",
"maxlength": "Courier reference number cannot be more than 100 characters",
"notUrl": "Answer must not contain a URL. Remove any links, URLs or special characters like /@:%_+~#=\\ from your answer."
}
}