Skip to content

Commit

Permalink
BRP-61: Amend application type on all forms
Browse files Browse the repository at this point in the history
* add application type to email subject header
* add unit tests
* add character limit for 'other' freetext
  • Loading branch information
Rhodine-orleans-lindsay committed May 24, 2022
1 parent f3ab9d3 commit 4cf2974
Show file tree
Hide file tree
Showing 52 changed files with 198 additions and 125 deletions.
4 changes: 2 additions & 2 deletions apps/collection/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ module.exports = {
validate: ['required', 'notUrl']
},
'application-type-other': {
validate: ['required'],
validate: ['required', {type: 'maxlength', arguments: 50}],
dependent: {
field: 'application-type',
value: 'other'
value: 'application-type-other'
}
}
};
2 changes: 1 addition & 1 deletion apps/collection/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
"legend": "Dependant",
"label": "Dependant"
},
"other": {
"application-type-other": {
"legend":"Other",
"label": "Other"
}
Expand Down
1 change: 1 addition & 0 deletions apps/collection/translations/src/en/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
},
"org-details-group": {
"header": "What are your details?",
"subheader": "We will attempt to contact the BRP holder directly. We will only use these details to contact you if needed.",
"type": "Type of support"
},
"footer": {
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/application-type.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 5 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/confirm.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 7 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/contact-details.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 6 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/nominated-person.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 3 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/personal-details.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 4 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/reasons.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 2 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/collection/views/where.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 1 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.collection.header{{/t}}
{{/journeyHeader}}
Expand Down
27 changes: 21 additions & 6 deletions apps/common/behaviours/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const StatsD = require('hot-shots');
const client = new StatsD();
const Model = require('../models/email');
const config = require('../../../config');

const { customAlphabet } = require('nanoid');
const applicationTypeOptions = require('../fields/application-type.js')['application-type'].options;
const alphabet = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
const nanoid = customAlphabet(alphabet, 9);

Expand All @@ -31,12 +31,23 @@ function setRef(data) {
}
return submissionRef;
}
function appType(data) {
const apptype = data['application-type'];
const otherFreetext = data['application-type-other'];
let applicationType = _.get( _.find(applicationTypeOptions, a => a.value === apptype), 'label', '');
if (apptype === 'application-type-other') {
applicationType = _.get( _.find(applicationTypeOptions, a => a.value === apptype), 'label', '') +
' - ' + otherFreetext;
}
return applicationType;
}

const serviceMap = {
'/not-arrived': data => {
return {
template: 'delivery',
subject: 'Form submitted: Your BRP hasn\'t arrived. Ref: ' + setRef(data)
subject: 'Form submitted: Your BRP hasn\'t arrived. Ref: ' + setRef(data) +
' (Application Type: ' + appType(data) + ')'
};
},
'/correct-mistakes': data => {
Expand All @@ -47,26 +58,30 @@ const serviceMap = {
const suffix = data.triage ? '-triage' : '';
return {
template: 'error' + suffix,
subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ') Ref: ' + setRef(data)
subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ') Ref: ' + setRef(data) +
' (Application Type: ' + appType(data) + ')'
};
},
'/lost-stolen': data => {
const suffix = (data['inside-uk'] === 'yes') ? '-uk' : '-abroad';
return {
template: 'lost-or-stolen' + suffix,
subject: 'Form submitted: Report a lost or stolen BRP. Ref: ' + setRef(data)
subject: 'Form submitted: Report a lost or stolen BRP. Ref: ' + setRef(data) +
' (Application Type: ' + appType(data) + ')'
};
},
'/collection': data => {
return {
template: 'collection',
subject: 'Form submitted: Report a collection problem. Ref: ' + setRef(data)
subject: 'Form submitted: Report a collection problem. Ref: ' + setRef(data) +
' (Application Type: ' + appType(data) + ')'
};
},
'/someone-else': data => {
return {
template: 'someone-else',
subject: 'Form submitted: Report someone else collecting your BRP. Ref: ' + setRef(data)
subject: 'Form submitted: Report someone else collecting your BRP. Ref: ' + setRef(data) +
' (Application Type: ' + appType(data) + ')'
};
}
};
Expand Down
60 changes: 47 additions & 13 deletions apps/common/fields/application-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,53 @@ module.exports = {
className: 'visuallyhidden'
},
options: [
{ value: 'work' },
{ value: 'study-academic-visit' },
{ value: 'graduate' },
{ value: 'settlement' },
{ value: 'asylum-humanitarian-protection' },
{ value: 'joining-family-human-rights' },
{ value: 'marriage-civil-partnership' },
{ value: 'business' },
{ value: 'uk-ancestry-youth-mobility' },
{ value: 'medical-treatment' },
{ value: 'dependant' },
{
value: 'other',
{
value: 'work',
label: 'Work'
},
{
value: 'study-academic-visit',
label: 'Study/Academic Visit'
},
{
value: 'graduate',
label: 'Graduate'
},
{
value: 'settlement',
label: 'Settlement'
},
{
value: 'asylum-humanitarian-protection',
label: 'Asylum/Humanitarian Protection'
},
{
value: 'joining-family-human-rights',
label: 'Joining Family/Human Rights'
},
{
value: 'marriage-civil-partnership',
label: 'Marriage/Civil Partnership'
},
{
value: 'business',
label: 'Business'
},
{
value: 'uk-ancestry-youth-mobility',
label: 'UK Ancestry/Youth Mobility'
},
{
value: 'medical-treatment',
label: 'Medical Treatment'
},
{
value: 'dependant',
label: 'Dependant'
},
{
value: 'application-type-other',
label: 'Other',
toggle: 'application-type-other',
child: 'input-text'
}
Expand Down
2 changes: 1 addition & 1 deletion apps/common/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
"legend": "Dependant",
"label": "Dependant"
},
"other": {
"application-type-other": {
"legend":"Other",
"label": "Other"
}
Expand Down
4 changes: 2 additions & 2 deletions apps/correct-mistakes/fields/application-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

module.exports = {
'application-type-other': {
validate: ['required'],
validate: ['required', {type: 'maxlength', arguments: 50}],
dependent: {
field: 'application-type',
value: 'other'
value: 'application-type-other'
}
}
};
2 changes: 1 addition & 1 deletion apps/correct-mistakes/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@
"legend": "Dependant",
"label": "Dependant"
},
"other": {
"application-type-other": {
"legend":"Other",
"label": "Other"
}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/about-error.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}

{{$step}}Step 2 of 7{{/step}}

{{$validationSummary}}
{{> partials-validation-summary}}
{{/validationSummary}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/application-type.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 5 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/confirm.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 7 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/contact-details.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 6 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/location-applied.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}

{{$step}}Step 1 of 7{{/step}}

{{$validationSummary}}
{{> partials-validation-summary}}
{{/validationSummary}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/personal-details-brp.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 4 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/same-address.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 3 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
2 changes: 0 additions & 2 deletions apps/correct-mistakes/views/uk-address.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 3 of 7{{/step}}

{{$journeyHeader}}
{{#t}}journeys.error.header{{/t}}
{{/journeyHeader}}
Expand Down
4 changes: 2 additions & 2 deletions apps/lost-stolen/fields/application-type.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

module.exports = {
'application-type-other': {
validate: ['required'],
validate: ['required', {type: 'maxlength', arguments: 50}],
dependent: {
field: 'application-type',
value: 'other'
value: 'application-type-other'
}
}
};
2 changes: 1 addition & 1 deletion apps/lost-stolen/translations/src/en/fields.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"legend": "Dependant",
"label": "Dependant"
},
"other": {
"application-type-other": {
"legend":"Other",
"label": "Other"
}
Expand Down
1 change: 1 addition & 0 deletions apps/lost-stolen/translations/src/en/pages.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"email": "Email address",
"phone": "Phone number",
"brp-card-number": "BRP number",
"application-details": "Application details",
"application-type": "Application type"
}
},
Expand Down
2 changes: 0 additions & 2 deletions apps/lost-stolen/views/application-type.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 4 of 6{{/step}}

{{$journeyHeader}}
{{#t}}journeys.lost.header{{/t}}
{{/journeyHeader}}
Expand Down
Loading

0 comments on commit 4cf2974

Please sign in to comment.