mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 16:38:59 -04:00
Only show template navigation when it’s useful
There are lots of services that only send emails, or only send text messages. For these services, being able to filter the list of templates but type is pointless – it won’t cut the list down at all. This commit adds some logic to only show the navigation if the service has some variety of template types.
This commit is contained in:
@@ -88,6 +88,10 @@ def view_template(service_id, template_id):
|
||||
def choose_template(service_id, template_type='all'):
|
||||
templates = service_api_client.get_service_templates(service_id)['data']
|
||||
|
||||
has_multiple_template_types = len({
|
||||
template['template_type'] for template in templates
|
||||
}) > 1
|
||||
|
||||
template_nav_items = [
|
||||
(label, key, url_for('.choose_template', service_id=current_service['id'], template_type=key), '')
|
||||
for label, key in filter(None, [
|
||||
@@ -104,6 +108,7 @@ def choose_template(service_id, template_type='all'):
|
||||
template for template in templates
|
||||
if template_type in ['all', template['template_type']]
|
||||
],
|
||||
show_template_nav=has_multiple_template_types,
|
||||
template_nav_items=template_nav_items,
|
||||
template_type=template_type,
|
||||
search_form=SearchTemplatesForm(),
|
||||
|
||||
@@ -48,9 +48,11 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="bottom-gutter-2-3">
|
||||
{{ pill(template_nav_items, current_value=template_type, show_count=False) }}
|
||||
</div>
|
||||
{% if show_template_nav %}
|
||||
<div class="bottom-gutter-2-3">
|
||||
{{ pill(template_nav_items, current_value=template_type, show_count=False) }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if templates|length > 7 %}
|
||||
<div data-module="autofocus">
|
||||
|
||||
Reference in New Issue
Block a user