Put all nested items on page

So that the live search can filter things, they need to be on the page
when it loads. We want to make search work across folders, so all the
things in subfolders need to be in the page.

They also need the full path appending to them, so that you can tell
which ones are in which folders.

This won’t show items that are in a folder above the one you’re
currently in – my reckon is that when you’re narrowing down by clicking
into a folder that you only want to search for things in that folder.
This commit is contained in:
Chris Hill-Scott
2018-11-22 17:22:32 +00:00
parent 82d8207612
commit 148492a635
3 changed files with 38 additions and 25 deletions

View File

@@ -5,11 +5,19 @@
margin: 0;
a {
display: block;
display: inline-block;
margin-bottom: -$gutter;
padding-bottom: $gutter;
}
&-separator {
display: inline-block;
vertical-align: top;
color: $secondary-text-colour;
padding: 0 4px 0 5px;
font-weight: normal;
}
}
&-type {
@@ -44,7 +52,7 @@
&-folder {
a {
a:first-child {
text-indent: 40px;
background-image: file-url('folder-blue-bold.svg');
background-repeat: no-repeat;

View File

@@ -12,7 +12,7 @@
{% else %}
<nav id=template-list>
{% for item in template_list %}
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %} {% if item.ancestors %}template-list-item-hidden-by-default{% endif %}">
{% if can_manage_folders %}
{{ unlabelled_checkbox(
id='templates-or-folder-{}'.format(item.id),
@@ -20,17 +20,22 @@
value=item.id,
) }}
{% endif %}
{% if item.is_folder %}
<h2 class="message-name template-list-folder">
<h2 class="message-name {% if item.is_folder or (item.ancestors and not item.is_folder) %}template-list-folder{% endif %}">
{% for ancestor in item.ancestors %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=ancestor.id) }}">
{{ ancestor.name }}
</a> <span class="message-name-separator">/</span>
{% endfor %}
{% if item.is_folder %}
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=item.id) }}">
{{ item.name }}
</a>
</h2>
{% else %}
<h2 class="message-name">
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.id) }}">{{ item.name }}</a>
</h2>
{% endif %}
{% else %}
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.id) }}">
{{ item.name }}
</a>
{% endif %}
</h2>
<p class="message-type">
{{ item.hint }}
</p>

View File

@@ -118,11 +118,11 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
['Text message', 'Email', 'Letter'],
[
'folder_one 2 folders',
'folder_one_one 1 template, 1 folder',
'folder_one_one_one 1 template',
'sms_template_nested Text message template',
'letter_template_nested Letter template',
'folder_one_two Empty',
'folder_one / folder_one_one 1 template, 1 folder',
'folder_one / folder_one_one / folder_one_one_one 1 template',
'folder_one / folder_one_one / folder_one_one_one / sms_template_nested Text message template',
'folder_one / folder_one_one / letter_template_nested Letter template',
'folder_one / folder_one_two Empty',
'folder_two Empty',
'sms_template_one Text message template',
'sms_template_two Text message template',
@@ -141,9 +141,9 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
['All', 'Email', 'Letter'],
[
'folder_one 1 folder',
'folder_one_one 1 folder',
'folder_one_one_one 1 template',
'sms_template_nested Text message template',
'folder_one / folder_one_one 1 folder',
'folder_one / folder_one_one / folder_one_one_one 1 template',
'folder_one / folder_one_one / folder_one_one_one / sms_template_nested Text message template',
'sms_template_one Text message template',
'sms_template_two Text message template',
],
@@ -157,9 +157,9 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
['Text message', 'Email', 'Letter'],
[
'folder_one_one 1 template, 1 folder',
'folder_one_one_one 1 template',
'sms_template_nested Text message template',
'letter_template_nested Letter template',
'folder_one_one / folder_one_one_one 1 template',
'folder_one_one / folder_one_one_one / sms_template_nested Text message template',
'folder_one_one / letter_template_nested Letter template',
'folder_one_two Empty',
],
None,
@@ -172,8 +172,8 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
['All', 'Email', 'Letter'],
[
'folder_one_one 1 folder',
'folder_one_one_one 1 template',
'sms_template_nested Text message template',
'folder_one_one / folder_one_one_one 1 template',
'folder_one_one / folder_one_one_one / sms_template_nested Text message template',
],
None,
),
@@ -194,7 +194,7 @@ def test_post_add_template_folder_page(client_request, service_one, mocker, pare
['Text message', 'Email', 'Letter'],
[
'folder_one_one_one 1 template',
'sms_template_nested Text message template',
'folder_one_one_one / sms_template_nested Text message template',
'letter_template_nested Letter template',
],
None,