Skip to content

Commit 51b8464

Browse files
Pass config via attributes
1 parent 44b42a1 commit 51b8464

3 files changed

Lines changed: 36 additions & 12 deletions

File tree

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{% macro app_breast_diagram(version, attributes) %}
2-
{%- include 'components/breast-diagram/template.jinja' -%}
1+
{% macro app_breast_diagram(params) %}
2+
{%- include "components/breast-diagram/template.jinja" -%}
33
{% endmacro %}

manage_breast_screening/core/jinja2/components/breast-diagram/template.jinja

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,18 @@
55
<span>Left</span>
66
</div>
77

8-
<figure class="app-breast-diagram__image-map nhsuk-u-width-full" data-module="app-image-map" {{- nhsukAttributes(attributes) }}>
9-
{% if version == 1 %}
8+
<figure
9+
{{- nhsukAttributes({
10+
"class": "app-breast-diagram__image-map nhsuk-u-width-full",
11+
"data-module": "app-image-map",
12+
"data-read-only": {
13+
"value": "true" if params.read_only else false,
14+
"optional": true
15+
}
16+
}) -}}
17+
18+
{{- nhsukAttributes(params.attributes) -}}>
19+
{% if params.version == 1 %}
1020
{% include "components/breast-diagram/v1.svg" %}
1121
{% endif %}
1222
</figure>

manage_breast_screening/mammograms/jinja2/mammograms/medical_information/breast_features/form.jinja

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,23 @@
99

1010
{% from "components/breast-diagram/macro.jinja" import app_breast_diagram %}
1111

12-
{% set form_attributes = { "data-module": "app-breast-diagram" } %}
12+
{% set form_attributes = {
13+
"class": "app-breast-diagram",
14+
"action": request.path,
15+
"method": "post",
16+
"data-module": "app-breast-diagram",
17+
"data-debug": {
18+
"value": "true" if "debug" in request.GET else false,
19+
"optional": true
20+
},
21+
"novalidate": {
22+
"value": true,
23+
"optional": true
24+
}
25+
} %}
1326

1427
{% block page_content %}
15-
<div class="nhsuk-u-reading-width">
28+
<div class="nhsuk-u-reading-width">
1629
{{ form_error_summary(form) }}
1730

1831
<h1 class="nhsuk-heading-l">
@@ -24,7 +37,7 @@
2437
{{ heading }}
2538
</h1>
2639

27-
<form class="app-breast-diagram" action="{{ request.path }}" method="post" novalidate {{ nhsukAttributes(form_attributes) }}>
40+
<form {{- nhsukAttributes(form_attributes) }}>
2841
{{ csrf_input }}
2942

3043
<p class="nhsuk-body" id="breast-diagram-description">
@@ -35,12 +48,13 @@
3548
<h2 class="nhsuk-heading-m">Where is the feature?</h2>
3649
</div>
3750

38-
{{ app_breast_diagram(
39-
version=diagram_version,
40-
attributes={
51+
{{ app_breast_diagram({
52+
"read_only": false,
53+
"version": diagram_version,
54+
"attributes": {
4155
"aria-labelledby": "breast-diagram-description"
4256
}
43-
) }}
57+
}) }}
4458

4559
{{ form.features }}
4660

@@ -100,5 +114,5 @@
100114
</a>
101115
</p>
102116
</form>
103-
</div>
117+
</div>
104118
{% endblock %}

0 commit comments

Comments
 (0)