Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check your requirements page (with requirements summary cards) #1019

Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
68a2972
Returns required journey - Check your requirements page (with require…
Demwunz May 15, 2024
870da75
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
Demwunz May 17, 2024
c8493d6
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
Demwunz May 21, 2024
b9de676
feat(app): added basic requirement card
Demwunz May 21, 2024
8a3ad87
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
Demwunz May 21, 2024
1e071b0
fix(app): remove whitespace
Demwunz May 21, 2024
7a699a7
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
Demwunz May 23, 2024
ae0bc84
feat(app): ensure index is correct
Demwunz May 23, 2024
6762b5c
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
Demwunz May 23, 2024
18867cc
feat(app): cleanup var names
Demwunz May 23, 2024
d6fe389
refactor: check presenter maps a specific object to the view
jonathangoulding May 29, 2024
2279f9f
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
robertparkinson May 30, 2024
02a9c50
test: requirement property
jonathangoulding May 30, 2024
a02d39d
test: requirement property
jonathangoulding May 30, 2024
022b34e
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
jonathangoulding May 30, 2024
871cf63
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
jonathangoulding May 30, 2024
a4e51e5
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
robertparkinson May 31, 2024
f51c93d
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
jonathangoulding May 31, 2024
4017d5c
Merge branch 'main' into WATER-4386-returns-required-journey-check-yo…
jonathangoulding May 31, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions app/presenters/return-requirements/check.presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @module CheckPresenter
*/

const { formatLongDate } = require('../base.presenter.js')
const { formatAbstractionDate, formatLongDate } = require('../base.presenter.js')
const { returnRequirementReasons } = require('../../lib/static-lookups.lib.js')

function go (session) {
Expand Down Expand Up @@ -39,19 +39,28 @@ function _requirements (session) {

const completedRequirements = []

for (const requirement of requirements) {
const { siteDescription, agreementsExceptions } = requirement

for (const [index, requirement] of requirements.entries()) {
const { agreementsExceptions } = requirement
// NOTE: We determine a requirement is complete because agreement exceptions is populated and it is the last step in
// the journey
if (agreementsExceptions) {
completedRequirements.push({ siteDescription })
requirement.abstractionPeriod = _abstractionPeriod(requirement.abstractionPeriod)
requirement.index = index
completedRequirements.push(requirement)
}
}

return completedRequirements
}

function _abstractionPeriod (abstractionPeriod) {
const { 'start-abstraction-period-day': startDay, 'start-abstraction-period-month': startMonth, 'end-abstraction-period-day': endDay, 'end-abstraction-period-month': endMonth } = abstractionPeriod
const startDate = formatAbstractionDate(startDay, startMonth)
const endDate = formatAbstractionDate(endDay, endMonth)

return `From ${startDate} to ${endDate}`
}

function _startDate (session) {
const { licence, startDateOptions, startDateDay, startDateMonth, startDateYear } = session

Expand Down
164 changes: 155 additions & 9 deletions app/views/return-requirements/check.njk
Original file line number Diff line number Diff line change
Expand Up @@ -108,18 +108,164 @@
preventDoubleClick: true
}) }}
</form>

{% for requirement in requirements %}
{# Set an easier to use index #}
{% set rowIndex = loop.index0 %}
{% set rowIndex = requirement.index %}
robertparkinson marked this conversation as resolved.
Show resolved Hide resolved
<div>
<h3 class="govuk-body">{{requirement.siteDescription}}</h3>
{{ govukButton({
text: "Remove requirement",
classes: "govuk-button--warning",
preventDoubleClick: true,
href: "/system/return-requirements/" + sessionId + "/remove/" + rowIndex
}) }}
{{ govukSummaryList({
card: {
title: {
text: requirement.siteDescription
}
},
classes: "govuk-summary-list--no-border",
rows: [
{
key: {
text: "Purpose"
},
value: {
html: "requirement.purposes"
},
actions: {
items: [
{
href: "purpose/" + rowIndex,
robertparkinson marked this conversation as resolved.
Show resolved Hide resolved
text: "Change",
visuallyHiddenText: "Purpose"
}
]
}
},
{
key: {
text: "Point"
},
value: {
html: "requirement.points"
},
actions: {
items: [
{
href: "points/" + rowIndex,
text: "Change",
visuallyHiddenText: "Point"
}
]
}
},
{
key: {
text: "Abstraction period"
},
value: {
html: requirement.abstractionPeriod
},
actions: {
items: [
{
href: "abstraction-period/" + rowIndex,
text: "Change",
visuallyHiddenText: "Abstraction period"
}
]
}
},
{
key: {
text: "Returns cycle"
},
value: {
html: "requirement.returnsCycle"
},
actions: {
items: [
{
href: "returns-cycle/" + rowIndex,
text: "Change",
visuallyHiddenText: "Returns cycle"
}
]
}
},
{
key: {
text: "Site description"
},
value: {
html: requirement.siteDescription
},
actions: {
items: [
{
href: "site-description/" + rowIndex,
text: "Change",
visuallyHiddenText: "Site description"
}
]
}
},
{
key: {
text: "Collection"
},
value: {
html: requirement.frequencyCollected | capitalize
},
actions: {
items: [
{
href: "frequency-collected/" + rowIndex,
text: "Change",
visuallyHiddenText: "Collection"
}
]
}
},
{
key: {
text: "Reporting"
},
value: {
html: requirement.frequencyReported | capitalize
},
actions: {
items: [
{
href: "frequency-reported/" + rowIndex,
text: "Change",
visuallyHiddenText: "Reporting"
}
]
}
},
{
key: {
text: "Agreements exceptions"
},
value: {
html: "requirement.agreementsExceptions"
},
actions: {
items: [
{
href: "agreements-exceptions/" + rowIndex,
text: "Change",
visuallyHiddenText: "Agreements exception"
}
]
}
}
]
}) }}
{% if requirements.length >= 2 %}
{{ govukButton({
text: "Remove requirement",
classes: "govuk-button--warning",
preventDoubleClick: true,
href: "/system/return-requirements/" + sessionId + "/remove/" + rowIndex
}) }}
{% endif %}
</div>
{% endfor %}
</div>
Expand Down
Loading