-
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 branch 'master' into PAF-129-Bug-fix
- Loading branch information
Showing
39 changed files
with
830 additions
and
107 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
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
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
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,84 @@ | ||
module.exports = superclass => class extends superclass { | ||
locals(req, res) { | ||
const locals = super.locals(req, res); | ||
|
||
// set crime-transport-vehicle toggles | ||
if (req.form.values['crime-car-group'] === 'car') { | ||
locals.carChecked = true; | ||
} else if (req.form.values['crime-car-group'] === 'car-transporter') { | ||
locals.carTransporterChecked = true; | ||
} else if (req.form.values['crime-hgv-group'] === 'hgv-canvas-sided') { | ||
locals.hgvCSChecked = true; | ||
} else if (req.form.values['crime-hgv-group'] === 'hgv-flatbed') { | ||
locals.hgvFChecked = true; | ||
} else if (req.form.values['crime-hgv-group'] === 'hgv-hard-sided') { | ||
locals.hgvHSChecked = true; | ||
} else if (req.form.values['crime-hgv-group'] === 'hgv-refrigerated') { | ||
locals.hgvRChecked = true; | ||
} else if (req.form.values['crime-hgv-group'] === 'hgv-tanker') { | ||
locals.hgvTChecked = true; | ||
} else if (req.form.values['crime-lorry-group'] === 'lorry') { | ||
locals.lorryChecked = true; | ||
} else if (req.form.values['crime-lorry-group'] === 'lorry-and-drag') { | ||
locals.lorryDragChecked = true; | ||
} else if (req.form.values['crime-van-group'] === 'van') { | ||
locals.vanChecked = true; | ||
} else if (req.form.values['crime-van-group'] === 'van-and-trailer') { | ||
locals.vanTrailerChecked = true; | ||
} else if (req.form.values['crime-van-group'] === 'van-other') { | ||
locals.vanOtherChecked = true; | ||
} else if (req.form.values['crime-van-group'] === 'seven-point-five-tonne-van') { | ||
locals.sevenVanChecked = true; | ||
} | ||
|
||
// set crime-transport-boat toggles | ||
if (req.form.values['crime-carrier-group'] === 'bulk-carrier') { | ||
locals.bulkChecked = true; | ||
} else if (req.form.values['crime-carrier-group'] === 'vehicle-carrier') { | ||
locals.vehicleChecked = true; | ||
} else if (req.form.values['crime-carrier-group'] === 'vessel-carrier') { | ||
locals.vesselChecked = true; | ||
} else if (req.form.values['crime-general-cargo-group'] === 'general-cargo') { | ||
locals.generalChecked = true; | ||
} else if (req.form.values['crime-general-cargo-group'] === 'general-cargo-with-container-capacity') { | ||
locals.generalContainerChecked = true; | ||
} else if (req.form.values['crime-vessel-group'] === 'research-vessel') { | ||
locals.researchChecked = true; | ||
} else if (req.form.values['crime-vessel-group'] === 'supply-vessel') { | ||
locals.supplyChecked = true; | ||
} else if (req.form.values['crime-vessel-group'] === 'support-vessel') { | ||
locals.supportChecked = true; | ||
} | ||
|
||
// set report-person-transport toggles | ||
if (req.form.values['report-person-transport-car-group'] === 'car') { | ||
locals.personCarChecked = true; | ||
} else if (req.form.values['report-person-transport-car-group'] === 'car-transporter') { | ||
locals.personCarTransporterChecked = true; | ||
} else if (req.form.values['report-person-transport-hgv-group'] === 'hgv-canvas-sided') { | ||
locals.personHgvCSChecked = true; | ||
} else if (req.form.values['report-person-transport-hgv-group'] === 'hgv-flatbed') { | ||
locals.personHgvFChecked = true; | ||
} else if (req.form.values['report-person-transport-hgv-group'] === 'hgv-hard-sided') { | ||
locals.personHgvHSChecked = true; | ||
} else if (req.form.values['report-person-transport-hgv-group'] === 'hgv-refrigerated') { | ||
locals.personHgvRChecked = true; | ||
} else if (req.form.values['report-person-transport-hgv-group'] === 'hgv-tanker') { | ||
locals.personHgvTChecked = true; | ||
} else if (req.form.values['report-person-transport-lorry-group'] === 'lorry') { | ||
locals.personLorryChecked = true; | ||
} else if (req.form.values['report-person-transport-lorry-group'] === 'lorry-and-drag') { | ||
locals.personLorryDragChecked = true; | ||
} else if (req.form.values['report-person-transport-van-group'] === 'van') { | ||
locals.personVanChecked = true; | ||
} else if (req.form.values['report-person-transport-van-group'] === 'van-and-trailer') { | ||
locals.personVanTrailerChecked = true; | ||
} else if (req.form.values['report-person-transport-van-group'] === 'van-other') { | ||
locals.personVanOtherChecked = true; | ||
} else if (req.form.values['report-person-transport-van-group'] === 'seven-point-five-tonne-van') { | ||
locals.personSevenVanChecked = true; | ||
} | ||
|
||
return locals; | ||
} | ||
}; |
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,56 @@ | ||
/* eslint-disable max-len */ | ||
const _ = require('lodash'); | ||
|
||
module.exports = superclass => class extends superclass { | ||
configure(req, res, next) { | ||
// preprend '0' if number is only a single digit | ||
const pad = num => num !== '' && num.length < 2 ? `0${num}` : num; | ||
|
||
if (req.sessionModel.get('time-crime-will-happen-hour')) { | ||
req.sessionModel.set('time-crime-will-happen-hour', pad(req.sessionModel.get('time-crime-will-happen-hour'))); | ||
} | ||
if (req.sessionModel.get('time-crime-will-happen-minute')) { | ||
req.sessionModel.set('time-crime-will-happen-minute', pad(req.sessionModel.get('time-crime-will-happen-minute'))); | ||
} | ||
// sets minutes to 00 if the hour field has been completed but the minute field left blank | ||
if (req.sessionModel.get('time-crime-will-happen-hour') && req.sessionModel.get('time-crime-will-happen-minute') === '') { | ||
req.sessionModel.set('time-crime-will-happen-minute', '00'); | ||
} | ||
|
||
if (req.sessionModel.get('time-crime-will-happen-hour') && req.sessionModel.get('time-crime-will-happen-minute')) { | ||
const time = req.sessionModel.get('time-crime-will-happen-hour').concat(' : ', req.sessionModel.get('time-crime-will-happen-minute')); | ||
if (req.sessionModel.get('time-crime-will-happen-hour') < 12) { | ||
req.sessionModel.set('time-crime-will-happen', time + ' am'); | ||
} else { | ||
req.sessionModel.set('time-crime-will-happen', time + ' pm'); | ||
} | ||
} else { | ||
req.sessionModel.unset('time-crime-will-happen'); | ||
} | ||
|
||
return super.configure(req, res, next); | ||
} | ||
|
||
locals(req, res) { | ||
const locals = super.locals(req, res); | ||
// set change link for for time-crime-will-happen field | ||
if (locals.route === 'confirm') { | ||
_.forEach(locals.rows, fields => { | ||
locals.rows = locals.rows.map(row => { | ||
if (row.section === 'The Crime - Duration') { | ||
_.forEach(fields, sectionFields => { | ||
_.forEach(sectionFields, field => { | ||
if (field.field === 'time-crime-will-happen') { | ||
field.changeLink = '/paf/date-time-crime-will-happen/edit#time-crime-will-happen-hour'; | ||
} | ||
}); | ||
}); | ||
return row; | ||
} | ||
return row; | ||
}); | ||
}); | ||
} | ||
return locals; | ||
} | ||
}; |
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
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
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
Oops, something went wrong.