From 3e335c32504a5c6a207788837214569d2359a7a2 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Fri, 23 Jun 2017 13:51:22 +0100 Subject: [PATCH] Hide template nav if service has one of each MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are a bunch of services that just have one text message template and one email template. In this case the template navigation is essentially the same as the list of templates – a user can just differentiate by looking at the two templates. Adding the nav would just be noise in this case. --- app/main/views/templates.py | 13 ++++++++----- app/templates/views/templates/choose.html | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/main/views/templates.py b/app/main/views/templates.py index ab917225e..a9e74658f 100644 --- a/app/main/views/templates.py +++ b/app/main/views/templates.py @@ -102,13 +102,16 @@ def choose_template(service_id, template_type='all'): ]) ] + templates_on_page = [ + template for template in templates + if template_type in ['all', template['template_type']] + ] + return render_template( 'views/templates/choose.html', - templates=[ - template for template in templates - if template_type in ['all', template['template_type']] - ], - show_template_nav=has_multiple_template_types, + templates=templates_on_page, + show_search_box=(len(templates_on_page) > 7), + show_template_nav=has_multiple_template_types and (len(templates) > 2), template_nav_items=template_nav_items, template_type=template_type, search_form=SearchTemplatesForm(), diff --git a/app/templates/views/templates/choose.html b/app/templates/views/templates/choose.html index e055c8b71..8641db60b 100644 --- a/app/templates/views/templates/choose.html +++ b/app/templates/views/templates/choose.html @@ -54,7 +54,7 @@ {% endif %} - {% if templates|length > 7 %} + {% if show_search_box %}