Add context to banner button text

Needs flash messaging system changes.
This commit is contained in:
Tom Byers
2020-08-05 11:28:56 +01:00
parent 0933485995
commit f608d5e979
3 changed files with 8 additions and 6 deletions

View File

@@ -690,7 +690,7 @@ def delete_service_template(service_id, template_id):
else:
raise e
flash(["Are you sure you want to delete {}?".format(template['name']), message], 'delete')
flash(["Are you sure you want to delete {}?".format(template['name']), message, template['name']], 'delete')
return render_template(
'views/templates/template.html',
template=get_template(

View File

@@ -1,7 +1,7 @@
{% from "components/form.html" import form_wrapper %}
{% from "components/button/macro.njk" import govukButton %}
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None) %}
{% macro banner(body, type=None, with_tick=False, delete_button=None, subhead=None, context=None, action=None, id=None, thing=None) %}
<div
class='banner{% if type %}-{{ type }}{% endif %}{% if with_tick %}-with-tick{% endif %}'
{% if type == 'dangerous' %}
@@ -25,7 +25,8 @@
{% call form_wrapper(action=action) %}
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
{{ govukButton({
"text": delete_button,
"text": "" if thing else delete_button,
"html": delete_button + "<span class=\"govuk-visually-hidden\"> " + thing + "</span>" if thing else "",
"name": "delete",
"classes": "govuk-button--warning govuk-!-margin-top-2",
}) }}
@@ -34,6 +35,6 @@
</div>
{% endmacro %}
{% macro banner_wrapper(type=None, with_tick=False, delete_button=None, subhead=None, action=None, id=None) %}
{{ banner(caller()|safe, type=type, with_tick=with_tick, delete_button=delete_button, subhead=subhead, action=action, id=id) }}
{% macro banner_wrapper(type=None, with_tick=False, delete_button=None, subhead=None, action=None, id=None, thing=None) %}
{{ banner(caller()|safe, type=type, with_tick=with_tick, delete_button=delete_button, subhead=subhead, action=action, id=id, thing=thing) }}
{% endmacro %}

View File

@@ -15,7 +15,8 @@
'default' if ((category == 'default') or (category == 'default_with_tick')) else 'dangerous',
delete_button=delete_button_text,
with_tick=True if category == 'default_with_tick' else False,
context=message[1] if message is not string
context=message[1] if message is not string,
thing=message[2] if message is not string and message[2]
)}}
</div>
{% endfor %}