Skip to content

Commit 805beaa

Browse files
Regional interface changes (#135)
This adds the ability for regions to delete organisations. --------- Co-authored-by: johnrimmer2 <[email protected]>
1 parent 99e5859 commit 805beaa

File tree

4 files changed

+78
-2
lines changed

4 files changed

+78
-2
lines changed

app/assets/sass/components/_table.scss

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ table {
33
max-width: 100%;
44
}
55

6-
table td {
6+
.app-table__cell--break-all {
77
word-break: break-all;
88
}
99

10-
1110
.app-table__header--min-width-100 {
1211
min-width: 100px;
1312
}

app/routes/regions.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,29 @@ module.exports = router => {
196196
})
197197
})
198198

199+
// Delete an organisation confirmation page
200+
router.get('/regions/v1/organisations/:code/delete', (req, res) => {
201+
const organisationsAdded = req.session.data.organisationsAdded || []
202+
const organisation = organisationsAdded.find((org) => org.code === req.params.code)
203+
if (!organisation) { res.redirect('/regions/v1/'); return }
204+
205+
res.render('regions/v1/delete-organisation', {
206+
organisation
207+
})
208+
})
209+
210+
// Deleting an organisation
211+
router.post('/regions/v1/organisations/:code/deleted', (req, res) => {
212+
const organisationsAdded = req.session.data.organisationsAdded || []
213+
const organisation = organisationsAdded.find((org) => org.code === req.params.code)
214+
if (!organisation) { res.redirect('/regions/v1/'); return }
215+
216+
// Remove organisation from the array of organisations added
217+
req.session.data.organisationsAdded.splice(req.session.data.organisationsAdded.indexOf(organisation), 1)
218+
219+
res.redirect('/regions/v1')
220+
})
221+
199222
// Add another lead user to an organisation form
200223
router.get('/regions/v1/organisations/:code/add-email', (req, res) => {
201224
const organisationsAdded = req.session.data.organisationsAdded || []
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends 'layout.html' %}
2+
3+
{% block pageTitle %}
4+
Delete organisation
5+
{% endblock %}
6+
7+
{% set currentSection = "delete-organisation" %}
8+
9+
{% block beforeContent %}
10+
<br>
11+
{{ backLink({
12+
href: "/regions/v1",
13+
text: "Back"
14+
}) }}
15+
{% endblock %}
16+
17+
18+
19+
{% block content %}
20+
<div class="nhsuk-grid-row">
21+
<div class="nhsuk-grid-column-two-thirds">
22+
23+
<h1 class="nhsuk-heading-l">Delete {{ organisation.name }}</h1>
24+
25+
<p>Once you delete this organisation, no one at {{ organisation.name }} will be able to record vaccinations.</p>
26+
27+
<p>You can add this organisation back at any time.</p>
28+
29+
<form action="/regions/v1/organisations/{{ organisation.code }}/deleted" method="post" novalidate="true">
30+
{{ button({
31+
"text": "Delete organisation",
32+
classes: "nhsuk-button--warning"
33+
}) }}
34+
</form>
35+
36+
</div>
37+
</div>
38+
39+
40+
{% endblock %}

app/views/regions/v1/index.html

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ <h1 class="nhsuk-heading-xl">North West</h1>
1818

1919
<p class="nhsuk-body-l">Once they’re set up, they can add other users and vaccination sites.</p>
2020

21+
{% from 'inset-text/macro.njk' import insetText %}
22+
23+
{{ insetText({
24+
html: "<p>You can only delete an organisation if they have not recorded any vaccinations.</p>"
25+
}) }}
26+
2127
{{ button({
2228
"text": "Invite an organisation",
2329
"href": "/regions/v1/add-organisation"
@@ -46,6 +52,8 @@ <h1 class="nhsuk-heading-xl">North West</h1>
4652
<th role="columnheader" class="" scope="col">
4753
Status
4854
</th>
55+
<th role="columnheader" class="" scope="col"></th>
56+
4957
</tr>
5058
</thead>
5159
<tbody class="nhsuk-table__body">
@@ -63,6 +71,12 @@ <h1 class="nhsuk-heading-xl">North West</h1>
6371
<td class="nhsuk-table__cell ">
6472
{{ organisation.status }}
6573
</td>
74+
<td class="nhsuk-table__cell app-table__cell--right-aligned">
75+
<a href="/regions/v1/organisations/{{ organisation.code }}/delete" class="nhsuk-link">Delete</a>
76+
</td>
77+
78+
79+
</td>
6680
</tr>
6781
{% endfor %}
6882
</tbody>

0 commit comments

Comments
 (0)