Skip to content

Commit 7ec417d

Browse files
Image reading bugfixes (#121)
* Check that symptoms exists before reading the length * Better method of checking if pageNavigation is used
1 parent 90d6eeb commit 7ec417d

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

app/lib/utils/reading.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ const createReadingBatch = (data, options) => {
10281028

10291029
// 3. Apply symptoms filter if specified
10301030
if (filters.hasSymptoms) {
1031-
events = events.filter(event => event?.medicalInformation.symptoms?.length > 0)
1031+
events = events.filter(event => event?.medicalInformation?.symptoms && event?.medicalInformation.symptoms?.length > 0)
10321032
}
10331033
}
10341034

app/views/_templates/layout-app.html

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,23 @@
149149
</div>
150150
{% endif %}
151151

152-
153-
{# This will output excess divs where pageNavigation is not set. I could not find a way to stop this. You can't test for truthiness of the block, nor can you capture the contents with set.
152+
{# Awkwardly test if pageNavigation is set. This is a workaround for Nunjucks
153+
not having a way to check if a block is defined or not.
154154

155155
See related issues:
156156
https://github.com/mozilla/nunjucks/issues/135
157157
https://github.com/mozilla/nunjucks/issues/164#issuecomment-3073581360 #}
158-
<div class="nhsuk-grid-row">
159-
<div class="nhsuk-grid-column-full">
160-
{% block pageNavigation %}{% endblock pageNavigation %}
161-
</div>
162-
</div>
158+
159+
{% macro pageNavigationWrapper() %}
160+
{% if caller() | length > 0 %}
161+
<div class="nhsuk-grid-row">
162+
<div class="nhsuk-grid-column-full">
163+
{{ caller() }}
164+
</div>
165+
</div>
166+
{% endif %}
167+
{% endmacro %}
168+
{% call pageNavigationWrapper() %}{% block pageNavigation %}{% endblock pageNavigation %}{% endcall %}
163169

164170
{% if gridColumn != "none" %}
165171
<div class="nhsuk-grid-row">

app/views/_templates/layout-reading.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
{% set gridColumn = gridColumn or "nhsuk-grid-column-full" %}
55

6+
67
{% set isClinicContext = batch.clinicId %}
78
{% set isBatchContext = not isClinicContext %}
89
{# {% for clinic in clinics %}
@@ -168,6 +169,7 @@
168169
{% endif %}
169170

170171
{% block pageNavigation %}
172+
171173
{% if not hideSecondaryNavigation %}
172174
{% include "reading/opinion-ui.njk" %}
173175
{# <hr class="nhsuk-section-break nhsuk-section-break--m nhsuk-section-break--visible"> #}

0 commit comments

Comments
 (0)