mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-24 08:16:51 -04:00
Fix search box show/hide logic
The search box should only be shown if there are too many items to quickly scan on the page. This number is judged to be 7; see the original PR for more context: https://github.com/alphagov/notifications-admin/pull/1195 This commit makes that logic work in the world of folders, by explicitly counting the templates shown on the screen, not all the templates a service has (which may be spread across multiple folders).
This commit is contained in:
@@ -121,14 +121,16 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
|
|||||||
)
|
)
|
||||||
return redirect(request.url)
|
return redirect(request.url)
|
||||||
|
|
||||||
|
templates_on_page = current_service.get_templates(template_type, template_folder_id)
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
'views/templates/choose.html',
|
'views/templates/choose.html',
|
||||||
current_template_folder_id=template_folder_id,
|
current_template_folder_id=template_folder_id,
|
||||||
can_manage_folders=can_manage_folders(),
|
can_manage_folders=can_manage_folders(),
|
||||||
template_folder_path=current_service.get_template_folder_path(template_folder_id),
|
template_folder_path=current_service.get_template_folder_path(template_folder_id),
|
||||||
template_folders=current_service.get_template_folders(template_type, template_folder_id),
|
template_folders=current_service.get_template_folders(template_type, template_folder_id),
|
||||||
templates=current_service.get_templates(template_type, template_folder_id),
|
templates=templates_on_page,
|
||||||
show_search_box=(len(current_service.get_templates(template_type)) > 7),
|
show_search_box=(len(templates_on_page) > 7),
|
||||||
show_template_nav=(
|
show_template_nav=(
|
||||||
current_service.has_multiple_template_types
|
current_service.has_multiple_template_types
|
||||||
and (len(current_service.all_templates) > 2)
|
and (len(current_service.all_templates) > 2)
|
||||||
|
|||||||
Reference in New Issue
Block a user