Skip to content

Commit

Permalink
Add another qualification of the same type (#362)
Browse files Browse the repository at this point in the history
* Add another of same qualification type
* Fix other other qualifications
  • Loading branch information
paulrobertlloyd committed Mar 16, 2020
1 parent 412e831 commit a32e1e8
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 16 deletions.
6 changes: 4 additions & 2 deletions app/data/dummy-application.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ module.exports = {
'other-qualifications': {
ksufp: {
id: 'ksufp',
type: 'GCSE(A*-G)',
type: 'Non-UK qualification',
'type-non-uk': 'GCSE(A*-G)',
subject: 'Science',
org: 'Juliet High School',
grade: '173',
Expand All @@ -102,7 +103,8 @@ module.exports = {
},
kv0y7: {
id: 'kv0y7',
type: 'Higher Secondary School Certificate',
type: 'Non-UK qualification',
'type-non-uk': 'Higher Secondary School Certificate',
subject: '',
org: 'Juliet High School',
grade: '647',
Expand Down
23 changes: 20 additions & 3 deletions app/routes/application/other-qualifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,37 @@ module.exports = router => {

// Render details page
router.get('/application/:applicationId/other-qualifications/:id/details', (req, res) => {
const applicationData = utils.applicationData(req)
const { id } = req.params
const { referrer } = req.query
const { type } = applicationData['other-qualifications'][id]

res.render('application/other-qualifications/details', {
id,
referrer
referrer,
type
})
})

router.post('/application/:applicationId/other-qualifications/:id/details', (req, res) => {
const applicationData = utils.applicationData(req)
const next = req.session.data.next || 'review'
const { applicationId } = req.params
const nextId = utils.generateRandomString()
const { applicationId, id } = req.params
const { referrer } = req.query
const { year, org, type } = applicationData['other-qualifications'][id]
const typeUk = applicationData['other-qualifications'][id]['type-uk']

res.redirect(referrer || `/application/${applicationId}/other-qualifications/${next}`)
if (next === 'add-type') {
applicationData['other-qualifications'][nextId] = {
year,
org,
type,
'type-uk': typeUk
}
res.redirect(referrer || `/application/${applicationId}/other-qualifications/${nextId}/details`)
} else {
res.redirect(referrer || `/application/${applicationId}/other-qualifications/${next}`)
}
})
}
6 changes: 4 additions & 2 deletions app/views/_includes/item/other-qualification.njk
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{% set applicationPath = "/application/" + applicationId %}
{% set country = " " + item.country if item.country else "" %}
{% set type = item["type-uk"] if item["type-uk"] else item.type or "Not entered" %}
{{ govukSummaryList({
rows: [{
key: {
text: "Type of qualification"
},
value: {
text: item.type or "Not entered"
text: type
},
actions: {
classes: "govuk-!-padding-right-2",
Expand Down Expand Up @@ -35,7 +37,7 @@
text: "Institution"
},
value: {
text: (item.org + " " + item.country if item.org) or "Not entered"
text: (item.org + country if item.org) or "Not entered"
},
actions: {
classes: "govuk-!-padding-right-2",
Expand Down
3 changes: 2 additions & 1 deletion app/views/_includes/review/other-qualifications.njk
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
{% if qualifications.length %}
{% for item in qualifications %}

{% set type = item["type-uk"] if item["type-uk"] else item.type or "Not entered" %}
{% set qualificationHtml %}
{% include "_includes/item/other-qualification.njk" %}
{% endset %}
{{ appSummaryCard({
classes: "govuk-!-margin-bottom-6",
headingLevel: 3,
titleText: item.type + " " + item.subject,
titleText: type + " " + item.subject,
actions: {
items: [{
href: applicationPath + "/other-qualifications/" + item.id + "/delete?referrer=" + referrer,
Expand Down
11 changes: 8 additions & 3 deletions app/views/application/other-qualifications/details.njk
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

{% set applicationPath = "/application/" + applicationId %}
{% set title = "Qualification details" %}
{% set nextType = applicationValue(["other-qualifications", id, "type-uk"]) or type %}

{% block pageNavigation %}
{% if referrer %}
Expand All @@ -16,7 +17,7 @@
{% endblock %}

{% block primary %}
{% if applicationValue(["other-qualifications", id, "type"]) == "gcse" %}
{% if type == "GCSE" %}
{{ appAutocomplete({
label: {
text: "Subject",
Expand Down Expand Up @@ -72,11 +73,15 @@
}
},
items: [{
value: "add-type",
text: "Yes, add another " + nextType,
checked: true
}, {
value: "add",
text: "Yes, I want to add another qualification"
text: "Yes, add a different qualification"
}, {
value: "review",
text: "No, I’ve completed my other qualifications"
text: "No, not right now"
}]
}) }}
{% endif %}
Expand Down
10 changes: 5 additions & 5 deletions app/views/application/other-qualifications/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@
}
},
items: [{
value: "gcse",
value: "GCSE",
text: "GCSE"
}, {
value: "as-level",
value: "AS level",
text: "AS level"
}, {
value: "a-level",
value: "A level",
text: "A level"
}, {
value: "other-uk",
value: "Other UK qualification",
text: "Other UK qualification" if data.flags.international_qualifications else "Other",
conditional: {
html: otherUkConditionalHtml
}
}, {
value: "non-uk",
value: "Non-UK qualification",
text: "Non-UK qualification",
conditional: {
html: nonUkConditionalHtml
Expand Down

0 comments on commit a32e1e8

Please sign in to comment.