Skip to content

Commit e50110c

Browse files
Support interface: Add ability to change region and sync from ODS (#240)
1 parent 69a0692 commit e50110c

File tree

4 files changed

+184
-0
lines changed

4 files changed

+184
-0
lines changed

app/routes/support.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,36 @@ const userId = Math.floor(Math.random() * 10000000).toString()
7676
})
7777
})
7878

79+
// Update details from PDS
80+
router.get('/support/organisations/:id/update-details', (req, res) => {
81+
const { id } = req.params
82+
const organisation = req.session.data.organisations.find((organisation) => organisation.id === id)
83+
84+
res.render('support/organisations/update-details', {
85+
organisation
86+
})
87+
})
88+
89+
// Change an organisation’s region
90+
router.get('/support/organisations/:id/change-region', (req, res) => {
91+
const { id } = req.params
92+
const organisation = req.session.data.organisations.find((organisation) => organisation.id === id)
93+
94+
res.render('support/organisations/change-region', {
95+
organisation
96+
})
97+
})
98+
99+
// Change an organisation’s region
100+
router.get('/support/organisations/:id/update-region', (req, res) => {
101+
const { id } = req.params
102+
const organisation = req.session.data.organisations.find((organisation) => organisation.id === id)
103+
104+
organisation.region = req.session.data.region
105+
106+
res.redirect(`/support/organisations/${id}`)
107+
})
108+
79109
// Updating a feature flag
80110
router.post('/support/organisations/:id/set-feature-flag', (req, res) => {
81111
const { id } = req.params
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{% extends 'layout.html' %}
2+
3+
{% set pageName = "Change region" %}
4+
5+
{% block beforeContent %}
6+
{{ backLink({
7+
href: "/support/organisations/" + organisation.id,
8+
text: "Back"
9+
}) }}
10+
{% endblock %}
11+
12+
{% set currentSection = "organisations" %}
13+
14+
{% block header %}
15+
{% include "includes/header-logged-in-support.html" %}
16+
{% endblock %}
17+
18+
{% block content %}
19+
<div class="nhsuk-grid-row">
20+
<div class="nhsuk-grid-column-two-thirds">
21+
22+
<div class="nhsuk-caption-l">{{ organisation.name }}</div>
23+
24+
<form action="/support/organisations/{{ organisation.id }}/update-region" method="post" novalidate>
25+
26+
{% set items = [] %}
27+
28+
{% for region in data.regions %}
29+
{% set items = (items.push({
30+
text: region.name,
31+
value: region.id
32+
}), items) %}
33+
{% endfor %}
34+
35+
{{ radios({
36+
idPrefix: "region",
37+
name: "region",
38+
fieldset: {
39+
legend: {
40+
text: pageName,
41+
classes: "nhsuk-fieldset__legend--l",
42+
isPageHeading: true
43+
}
44+
},
45+
value: organisation.region,
46+
items: items
47+
}) }}
48+
49+
50+
{{ button({
51+
text: "Save"
52+
}) }}
53+
</form>
54+
55+
</div>
56+
</div>
57+
58+
{% endblock %}
59+

app/views/support/organisations/show.html

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,67 @@
1515
{% include "includes/header-logged-in-support.html" %}
1616
{% endblock %}
1717

18+
{% set region = data.regions | findById(organisation.region) %}
19+
1820
{% block content %}
1921
<div class="nhsuk-grid-row">
2022
<div class="nhsuk-grid-column-two-thirds">
2123

2224
<h1 class="nhsuk-heading-l">{{ pageName }}</h1>
2325

26+
{{ summaryList({
27+
rows: [
28+
{
29+
key: {
30+
text: "ODS code",
31+
classes: "nhsuk-u-font-weight-normal"
32+
},
33+
value: {
34+
html: organisation.id
35+
},
36+
actions: {
37+
items: []
38+
}
39+
},
40+
{
41+
key: {
42+
text: "Name",
43+
classes: "nhsuk-u-font-weight-normal"
44+
},
45+
value: {
46+
text: organisation.name
47+
},
48+
actions: {
49+
items: [
50+
{
51+
href: "/support/organisations/" + organisation.id + "/update-details",
52+
text: "Update",
53+
visuallyHiddenText: "name"
54+
}
55+
]
56+
}
57+
},
58+
{
59+
key: {
60+
text: "Region",
61+
classes: "nhsuk-u-font-weight-normal"
62+
},
63+
value: {
64+
html: "<a href=\"/support/regions/" + region.id + "\">" + region.name + "</a>"
65+
} if region,
66+
actions: {
67+
items: [
68+
{
69+
href: "/support/organisations/" + organisation.id + "/change-region",
70+
text: "Change",
71+
visuallyHiddenText: "region"
72+
}
73+
]
74+
}
75+
}
76+
]
77+
}) }}
78+
2479
<h2 class="nhsuk-heading-m">Beta features enabled</h2>
2580

2681
{% set recordInterface %}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% extends 'layout.html' %}
2+
3+
{% set pageName = "Update details from ODS" %}
4+
5+
{% block beforeContent %}
6+
{{ backLink({
7+
href: "/support/organisations/" + organisation.id,
8+
text: "Back"
9+
}) }}
10+
{% endblock %}
11+
12+
{% set currentSection = "organisations" %}
13+
14+
{% block header %}
15+
{% include "includes/header-logged-in-support.html" %}
16+
{% endblock %}
17+
18+
{% block content %}
19+
<div class="nhsuk-grid-row">
20+
<div class="nhsuk-grid-column-two-thirds">
21+
22+
<div class="nhsuk-caption-l">{{ organisation.name }}</div>
23+
<h1 class="nhsuk-heading-l">{{ pageName }}</h1>
24+
25+
<form action="/support/organisations/{{ organisation.id }}" method="post" novalidate>
26+
27+
<p>Organisations can <a href="https://digital.nhs.uk/services/organisation-data-service/request-a-new-code-or-update-organisation-details">update their details</a> in the NHS Organisation Data Service (ODS).</p>
28+
29+
<p>If these details have recently been updated, you can sync them back to our service.</p>
30+
31+
{{ button({
32+
text: "Sync organisation details from ODS"
33+
}) }}
34+
</form>
35+
36+
</div>
37+
</div>
38+
39+
{% endblock %}
40+

0 commit comments

Comments
 (0)