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 Apr 12, 2023
1 parent 522956e commit b7c010b
Show file tree
Hide file tree
Showing 49 changed files with 186 additions and 122 deletions.
4 changes: 2 additions & 2 deletions apps/collection/fields/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,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/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
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
28 changes: 20 additions & 8 deletions apps/common/behaviours/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const _ = require('underscore');
const StatsD = require('hot-shots');
const client = new StatsD();
const Model = require('../models/email');
const applicationTypeOptions = require('../fields/application-type.js')['application-type'].options;

function errorChecked(key, data) {
if (data[key + '-checkbox']) {
Expand All @@ -18,12 +19,22 @@ function checkedErrors(data) {
});
return checked;
}
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': () => {
'/not-arrived': data => {
return {
template: 'delivery',
subject: 'Form submitted: Your BRP hasn\'t arrived.'
subject: 'Form submitted: Your BRP hasn\'t arrived. Application Type: ' + appType(data)
};
},
'/correct-mistakes': data => {
Expand All @@ -34,26 +45,27 @@ const serviceMap = {
const suffix = data.triage ? '-triage' : '';
return {
template: 'error' + suffix,
subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ')'
subject: 'Form submitted: Report a problem with your new BRP (' + subjectErrors + ') 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.'
subject: 'Form submitted: Report a lost or stolen BRP. Application Type: ' + appType(data)
};
},
'/collection': () => {
'/collection': data => {
return {
template: 'collection',
subject: 'Form submitted: Report a collection problem.'
subject: 'Form submitted: Report a collection problem. Application Type: ' + appType(data)
};
},
'/someone-else': () => {
'/someone-else': data => {
return {
template: 'someone-else',
subject: 'Form submitted: Report someone else collecting your BRP.'
subject: 'Form submitted: Report someone else collecting your BRP. 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 @@ -99,7 +99,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
38 changes: 21 additions & 17 deletions apps/lost-stolen/views/confirm.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 6 of 6{{/step}}

{{$journeyHeader}}
{{#t}}journeys.lost.header{{/t}}
{{/journeyHeader}}
Expand Down Expand Up @@ -74,21 +72,6 @@
<td><a href="personal-details/edit#brp-card" id='brp-card-change' class="button">{{#t}}buttons.change.brp-card{{/t}}</a></td>
</tr>
{{/values.brp-card}}
{{#values.application-type}}
<tr data-id='application-type'>
<td>{{#t}}pages.check-details.table.headers.application-type{{/t}}</td>
<td class="no-white-space">
{{#t}}fields.application-type.options.{{values.application-type}}.label{{/t}}
<br />
<span>
{{#values.application-type-other}}
{{values.application-type-other}}
{{/values.application-type-other}}
</span>
</td>
<td><a href="application-type/edit#application-type" id='application-type-change' class="button">{{#t}}buttons.change.application-type{{/t}}</a></td>
</tr>
{{/values.application-type}}
{{#values.email}}
<tr data-id='email'>
<td>{{#t}}pages.check-details.table.headers.email{{/t}}</td>
Expand All @@ -105,6 +88,27 @@
{{/values.phone}}
</table>

<h2 class="details-header">{{#t}}pages.check-details.table.headers.application-details{{/t}}</h2>
<table id="application-details" class="table-details">
<tbody>
{{#values.application-type}}
<tr data-id='application-type'>
<td>{{#t}}pages.check-details.table.headers.application-type{{/t}}</td>
<td class="no-white-space">
{{#t}}fields.application-type.options.{{values.application-type}}.label{{/t}}
<br />
<span>
{{#values.application-type-other}}
{{values.application-type-other}}
{{/values.application-type-other}}
</span>
</td>
<td><a href="application-type/edit#application-type" id='application-type-change' class="button">{{#t}}buttons.change.application-type{{/t}}</a></td>
</tr>
{{/values.application-type}}
</tbody>
</table>

{{<partials-org-type}}{{/partials-org-type}}

<h2>{{#t}}footer.title{{/t}}</h2>
Expand Down
2 changes: 0 additions & 2 deletions apps/lost-stolen/views/contact-details.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{{<layout}}
{{$step}}Step 5 of 6{{/step}}

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

0 comments on commit b7c010b

Please sign in to comment.