mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
Label folders to show what’s in them
It feels like a solid reckon that knowing what’s in a folder before you click on it will help you navigate around. However, what do you show in a folder if you’re filtering by template type? We think that: - if you’re not filtering you should see all folders, even empty ones - if you’re filtering you should only see folders that will get you to relevant templates This matches what happens when you filter templates, we don’t ‘grey out’ the non-email templates, we hide them completely. The logic then extends to how we describe the contents of a folder, ie we won’t count its subfolders if they don’t contain templates of the type we’re looking for. This means that however you see the folder described (eg ‘3 templates, 1 folder’) will match what you see when you click into it.
This commit is contained in:
@@ -55,3 +55,26 @@
|
||||
{%- endif -%}
|
||||
{%- endif %}
|
||||
{%- endmacro %}
|
||||
|
||||
|
||||
{% macro folder_contents_count(number_of_folders, number_of_templates) %}
|
||||
|
||||
{% if number_of_folders == number_of_templates == 0 %}
|
||||
Empty
|
||||
{% endif %}
|
||||
|
||||
{% if number_of_templates == 1 %}
|
||||
{{ number_of_templates }} template
|
||||
{%- elif number_of_templates > 1 -%}
|
||||
{{ number_of_templates }} templates
|
||||
{%- endif -%}
|
||||
|
||||
{%- if number_of_folders and number_of_templates %}, {% endif -%}
|
||||
|
||||
{%- if number_of_folders == 1 -%}
|
||||
{{ number_of_folders }} folder
|
||||
{%- elif number_of_folders > 1 -%}
|
||||
{{ number_of_folders }} folders
|
||||
{% endif %}
|
||||
|
||||
{%- endmacro %}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{% from "components/checkbox.html" import unlabelled_checkbox %}
|
||||
{% from "components/message-count-label.html" import folder_contents_count %}
|
||||
|
||||
<nav id=template-list>
|
||||
{% for template_folder in template_folders %}
|
||||
@@ -15,7 +16,12 @@
|
||||
{{ template_folder.name }}
|
||||
</a>
|
||||
</h2>
|
||||
<p class="message-type">Folder containing {{ template_count }} template{% if template_count != 1 %}s{% endif %}</p>
|
||||
<p class="message-type">
|
||||
{{ folder_contents_count(
|
||||
current_service.get_template_folders(template_folder.id, template_type)|length,
|
||||
current_service.get_templates(template_type, template_folder.id)|length,
|
||||
) }}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for template in templates %}
|
||||
|
||||
@@ -106,8 +106,8 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
|
||||
{},
|
||||
['Text message', 'Email', 'Letter'],
|
||||
[
|
||||
'folder_one Folder containing templates',
|
||||
'folder_two Folder containing templates',
|
||||
'folder_one 2 folders',
|
||||
'folder_two Empty',
|
||||
'sms_template_one Text message template',
|
||||
'sms_template_two Text message template',
|
||||
'email_template_one Email template',
|
||||
@@ -121,25 +121,41 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
|
||||
{'template_type': 'sms'},
|
||||
['All', 'Email', 'Letter'],
|
||||
[
|
||||
'folder_one Folder containing templates',
|
||||
'folder_one 1 folder',
|
||||
'sms_template_one Text message template',
|
||||
'sms_template_two Text message template',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Templates / folder_one',
|
||||
{'template_folder_id': PARENT_FOLDER_ID},
|
||||
['Text message', 'Email', 'Letter'],
|
||||
[
|
||||
'folder_one_one 1 template, 1 folder',
|
||||
'folder_one_two Empty',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Templates / folder_one',
|
||||
{'template_type': 'sms', 'template_folder_id': PARENT_FOLDER_ID},
|
||||
['All', 'Email', 'Letter'],
|
||||
[
|
||||
'folder_one_one Folder containing templates',
|
||||
'folder_one_one 1 folder',
|
||||
],
|
||||
),
|
||||
(
|
||||
'Templates / folder_one',
|
||||
{'template_type': 'email', 'template_folder_id': PARENT_FOLDER_ID},
|
||||
['All', 'Text message', 'Letter'],
|
||||
[],
|
||||
),
|
||||
(
|
||||
'Templates / folder_one / folder_one_one',
|
||||
{'template_folder_id': CHILD_FOLDER_ID},
|
||||
['Text message', 'Email', 'Letter'],
|
||||
[
|
||||
'folder_one_one_one Folder containing templates',
|
||||
'folder_one_one_one 1 template',
|
||||
'letter_template_nested Letter template',
|
||||
],
|
||||
),
|
||||
(
|
||||
@@ -164,7 +180,6 @@ def test_should_show_templates_folder_page(
|
||||
expected_nav_links,
|
||||
expected_items,
|
||||
):
|
||||
|
||||
mock_get_template_folders.return_value = [
|
||||
_folder('folder_two'),
|
||||
_folder('folder_one', PARENT_FOLDER_ID),
|
||||
@@ -181,7 +196,8 @@ def test_should_show_templates_folder_page(
|
||||
_template('email', 'email_template_two'),
|
||||
_template('letter', 'letter_template_one'),
|
||||
_template('letter', 'letter_template_two'),
|
||||
_template('sms', 'sms_template_nested', parent=GRANDCHILD_FOLDER_ID)
|
||||
_template('letter', 'letter_template_nested', parent=CHILD_FOLDER_ID),
|
||||
_template('sms', 'sms_template_nested', parent=GRANDCHILD_FOLDER_ID),
|
||||
]}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user