-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TP2000-1067 Fix measure edit footnote save (#1050)
* Tidy up template * Move constants, rename variable, re-order code * Catch footnote submitted directly on saving * Add test * Amend comment * Remove check for POST in request
- Loading branch information
1 parent
949f547
commit 30f4da0
Showing
7 changed files
with
100 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,46 @@ | ||
{% with form_footnotes = form.request.session["instance_footnotes_" ~ form.instance.sid] %} | ||
{% if form_footnotes %} | ||
{% set table_rows = [] %} | ||
{% for footnote in footnotes %} | ||
{% if footnote.pk in form.request.session["instance_footnotes_"~form.instance.sid]%} | ||
{% set footnote_link -%} | ||
<a class="govuk-link govuk-!-font-weight-bold" href="{{ footnote.get_url() }}">{{ footnote|string }}</a> | ||
{%- endset %} | ||
{% set remove_button -%} | ||
<button formaction={{ form.instance.get_url('edit-footnotes') }} class="govuk-link govuk-!-font-weight-bold fake-link" name="remove" value={{ footnote.pk }}>Remove</a> | ||
{%- endset %} | ||
{{ table_rows.append([ | ||
{"html": footnote_link}, | ||
{"text": footnote.get_description().description|default("")}, | ||
{"html": remove_button} | ||
]) or "" }} | ||
{% endif %} | ||
{% endfor %} | ||
{{ govukTable({ | ||
"head": [ | ||
{"text": "ID"}, | ||
{"text": "Description"}, | ||
{"text": ""} | ||
], | ||
"rows": table_rows, | ||
"caption": "Footnotes currently assigned to the measure", | ||
"captionClasses": "govuk-table__caption--m" | ||
}) }} | ||
{% else %} | ||
<p class="govuk-label">No footnotes found.</p> | ||
<br></br> | ||
{% endif %} | ||
{% with measure_footnotes = form.request.session["instance_footnotes_" ~ form.instance.sid] %} | ||
{% if measure_footnotes %} | ||
{% set table_rows = [] %} | ||
{% for footnote in footnotes %} | ||
{% if footnote.pk in measure_footnotes %} | ||
{% set footnote_link -%} | ||
<a class="govuk-link govuk-!-font-weight-bold" href="{{ footnote.get_url() }}">{{ footnote|string }}</a> | ||
{%- endset %} | ||
{% set remove_button -%} | ||
<button formaction={{ form.instance.get_url('edit-footnotes') }} class="govuk-link govuk-!-font-weight-bold fake-link" name="remove" value={{ footnote.pk }}>Remove</a> | ||
{%- endset %} | ||
{{ table_rows.append([ | ||
{"html": footnote_link}, | ||
{"text": footnote.get_description().description|default("")}, | ||
{"html": remove_button} | ||
]) or "" }} | ||
{% endif %} | ||
{% endfor %} | ||
{{ govukTable({ | ||
"head": [ | ||
{"text": "ID"}, | ||
{"text": "Description"}, | ||
{"text": ""} | ||
], | ||
"rows": table_rows, | ||
"caption": "Footnotes currently assigned to the measure", | ||
"captionClasses": "govuk-table__caption--m" | ||
}) }} | ||
{% endif %} | ||
{% endwith %} | ||
|
||
{{ crispy(footnotes_formset.management_form, no_form_tags) }} | ||
<label class="govuk-label">Add a footnote</label> | ||
<div id="sort-code-hint" class="govuk-hint">Start typing the ID of the footnote or terms used in the description</div> | ||
{% for form in footnotes_formset %} | ||
{{ crispy(form) }} | ||
{% endfor %} | ||
|
||
{% if footnotes_formset.data[footnotes_formset.prefix ~ "-ADD"] %} | ||
{{ crispy(footnotes_formset.empty_form)|replace("__prefix__", footnotes_formset.forms|length)|safe }} | ||
{% endif %} | ||
{% for form in footnotes_formset %} | ||
{{ crispy(form) }} | ||
{% endfor %} | ||
|
||
{% if footnotes_formset.data[footnotes_formset.prefix ~ "-ADD"] %} | ||
{{ crispy(footnotes_formset.empty_form)|replace("__prefix__", footnotes_formset.forms|length)|safe }} | ||
{% endif %} | ||
|
||
{% call govukFieldset({"legend": {}, "classes": "govuk-!-padding-top-3"}) %} | ||
<button class="govuk-button govuk-button--secondary" data-module="govuk-button" value=1, name={{ footnotes_formset.prefix ~ "-ADD" }}, formaction={{ object.get_url("edit-footnotes") }}> | ||
Add another footnote | ||
</button | ||
|
||
{% endcall %} | ||
{% call govukFieldset({"legend": {}, "classes": "govuk-!-padding-top-3"}) %} | ||
<button class="govuk-button govuk-button--secondary" data-module="govuk-button" value=1, name={{ footnotes_formset.prefix ~ "-ADD" }}, formaction={{ object.get_url("edit-footnotes") }}> | ||
Add another footnote | ||
</button | ||
{% endcall %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters