-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from UKHomeOffice/CSL-20-premises-address
* add premises address page; add premises contact details page
- Loading branch information
Showing
8 changed files
with
218 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
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 === 'premises-telephone') { | ||
const phoneNumber = req.form.values[key]; | ||
if(phoneNumber) { | ||
const phoneNumberWithoutSpace = phoneNumber.replace(/\s+/g, '').trim(); | ||
const isValidphoneNumber = validators.regex(phoneNumberWithoutSpace, /^\(?\+?[\d()-]{8,16}$/); | ||
if(!isValidphoneNumber || !validators.ukPhoneNumber(phoneNumber)) { | ||
return validationErrorFunc('ukPhoneNumber'); | ||
} | ||
} | ||
} | ||
|
||
return super.validateField(key, req); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,47 @@ | ||
module.exports = { | ||
'is-premises-address-same': { | ||
isPageHeading: 'true', | ||
mixin: 'radio-group', | ||
validate: ['required'], | ||
className: ['govuk-radios govuk-radios--inline'], | ||
options: [ | ||
{ | ||
value: 'yes' | ||
}, | ||
{ | ||
value: 'no' | ||
} | ||
] | ||
}, | ||
'premises-address-line-1': { | ||
validate: ['required', { type: 'maxlength', arguments: [250]}, 'notUrl'], | ||
mixins: ['input-text'], | ||
className: ['govuk-input', 'govuk-!-width-two-thirds'] | ||
}, | ||
'premises-address-line-2': { | ||
validate: [{ type: 'maxlength', arguments: [250]}, 'notUrl'], | ||
mixins: ['input-text'], | ||
className: ['govuk-input', 'govuk-!-width-two-thirds'] | ||
}, | ||
'premises-town-or-city': { | ||
validate: ['required', { type: 'maxlength', arguments: [250]}, 'notUrl'], | ||
mixins: 'input-text', | ||
className: ['govuk-input', 'govuk-!-width-two-thirds'] | ||
}, | ||
'premises-postcode': { | ||
validate: ['required', 'postcode'], | ||
mixins: 'input-text', | ||
formatter: ['ukPostcode'], | ||
className: ['govuk-input', 'govuk-input--width-10'] | ||
}, | ||
'premises-telephone': { | ||
validate: ['required'], // additional validation rules added in custom-validation.js | ||
mixins: 'input-text', | ||
className: ['govuk-input', 'govuk-!-width-two-thirds'] | ||
}, | ||
'premises-email': { | ||
validate: ['required', 'email'], | ||
mixins: 'input-text', | ||
className: ['govuk-input', 'govuk-!-width-two-thirds'] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
apps/precursor-chemicals/sections/summary-data-sections.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
|
||
'use strict'; | ||
|
||
module.exports = { | ||
'about-the-applicants': { | ||
steps: [ | ||
{ | ||
step: '/reuse-premises-address', | ||
field: 'is-premises-address-same' | ||
}, | ||
{ | ||
step: '/premises-address', | ||
field: 'premises-address-details', | ||
parse: (list, req) => { | ||
if (!req.sessionModel.get('steps').includes('/premises-address')) { | ||
return null; | ||
} | ||
const addressDetails = []; | ||
addressDetails.push(req.sessionModel.get('premises-address-line-1')); | ||
if(req.sessionModel.get('premises-address-line-2')) { | ||
addressDetails.push(req.sessionModel.get('premises-address-line-2')); | ||
} | ||
addressDetails.push(req.sessionModel.get('premises-town-or-city')); | ||
addressDetails.push(req.sessionModel.get('premises-postcode')); | ||
return addressDetails.join('\n'); | ||
} | ||
}, | ||
{ | ||
step: '/premises-contact-details', | ||
field: 'premises-contact-details', | ||
parse: (list, req) => { | ||
const contactDetails = []; | ||
contactDetails.push(req.sessionModel.get('premises-telephone')); | ||
contactDetails.push(req.sessionModel.get('premises-email')); | ||
return contactDetails.join('\n'); | ||
} | ||
} | ||
] | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
{ | ||
|
||
"is-premises-address-same": { | ||
"legend": "Is the premises address the same as the licence holder address?", | ||
"options": { | ||
"yes": { | ||
"label": "Yes" | ||
}, | ||
"no": { | ||
"label": "No" | ||
} | ||
} | ||
}, | ||
"premises-address-line-1": { | ||
"label": "Address line 1" | ||
}, | ||
"premises-address-line-2": { | ||
"label": "Address line 2 (optional)" | ||
}, | ||
"premises-town-or-city": { | ||
"label": "Town or city" | ||
}, | ||
"premises-postcode": { | ||
"label": "Postcode" | ||
}, | ||
"premises-telephone": { | ||
"label": "UK telephone number" | ||
}, | ||
"premises-email": { | ||
"label": "Email address" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletion
30
apps/precursor-chemicals/translations/src/en/validation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,31 @@ | ||
{ | ||
|
||
"is-premises-address-same": { | ||
"required": "Select if your contact details are the same for your licence and business address" | ||
}, | ||
"premises-address-line-1": { | ||
"required": "Enter a premises address", | ||
"notUrl": "Your answer must not contain URLs or links", | ||
"maxlength": "Address line 1 must be between 1 and 250 characters" | ||
}, | ||
"premises-address-line-2": { | ||
"notUrl": "Your answer must not contain URLs or links", | ||
"maxlength": "Address line 2 must be between 1 and 250 characters" | ||
}, | ||
"premises-town-or-city": { | ||
"required": "Enter a town or city", | ||
"notUrl": "Your answer must not contain URLs or links", | ||
"maxlength": "Town or city must be between 1 and 250 characters" | ||
}, | ||
"premises-postcode": { | ||
"required": "Enter a postcode", | ||
"postcode": "Enter a real UK postcode" | ||
}, | ||
"premises-telephone": { | ||
"required": "Enter a UK telephone number", | ||
"ukPhoneNumber": "Enter a UK telephone number in the correct format, like 01632 960001 or +44 808 157 0192" | ||
}, | ||
"premises-email": { | ||
"required": "Enter an email address", | ||
"email": "Enter a real email address" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{<partials-page}} | ||
{{$page-content}} | ||
|
||
<div class="table-details"> | ||
{{#rows}} | ||
{{> partials-summary-table}} | ||
{{/rows}} | ||
</div> | ||
|
||
{{#input-submit}}continue{{/input-submit}} | ||
{{/page-content}} | ||
{{/partials-page}} |