From 6c4b6774aa1aa9d4d0a2e5e222ef79cc097df0a9 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 12 Nov 2018 14:43:47 +0000 Subject: [PATCH] =?UTF-8?q?Label=20folders=20to=20show=20what=E2=80=99s=20?= =?UTF-8?q?in=20them?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- .../components/message-count-label.html | 23 ++++++++++++++ .../views/templates/_template_list.html | 8 ++++- tests/app/main/views/test_template_folders.py | 30 ++++++++++++++----- 3 files changed, 53 insertions(+), 8 deletions(-) diff --git a/app/templates/components/message-count-label.html b/app/templates/components/message-count-label.html index 14b997665..0e5cfeedc 100644 --- a/app/templates/components/message-count-label.html +++ b/app/templates/components/message-count-label.html @@ -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 %} diff --git a/app/templates/views/templates/_template_list.html b/app/templates/views/templates/_template_list.html index 96ecbff53..ca4b7c57a 100644 --- a/app/templates/views/templates/_template_list.html +++ b/app/templates/views/templates/_template_list.html @@ -1,4 +1,5 @@ {% from "components/checkbox.html" import unlabelled_checkbox %} +{% from "components/message-count-label.html" import folder_contents_count %}