mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-19 05:59:44 -04:00
Merge pull request #2513 from alphagov/empty-folder-message
Improve the empty folder state
This commit is contained in:
@@ -54,6 +54,11 @@
|
||||
|
||||
}
|
||||
|
||||
&-empty {
|
||||
color: $secondary-text-colour;
|
||||
padding: $gutter-half 0 $gutter-one-third 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.folder-heading {
|
||||
|
||||
@@ -126,9 +126,10 @@ def choose_template(service_id, template_type='all', template_folder_id=None):
|
||||
current_template_folder_id=template_folder_id,
|
||||
can_manage_folders=can_manage_folders(),
|
||||
template_folder_path=current_service.get_template_folder_path(template_folder_id),
|
||||
template_folder_has_contents=current_service.get_template_folders_and_templates('all', 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),
|
||||
show_search_box=(len(current_service.get_templates(template_type)) > 7),
|
||||
show_search_box=current_service.count_of_templates_and_folders > 7,
|
||||
show_template_nav=(
|
||||
current_service.has_multiple_template_types
|
||||
and (len(current_service.all_templates) > 2)
|
||||
|
||||
@@ -133,7 +133,10 @@ class Service():
|
||||
|
||||
@property
|
||||
def has_templates(self):
|
||||
return len(self.all_templates) > 0
|
||||
return bool(self.all_templates)
|
||||
|
||||
def has_folders(self):
|
||||
return bool(self.all_template_folders)
|
||||
|
||||
@property
|
||||
def has_multiple_template_types(self):
|
||||
@@ -364,6 +367,10 @@ class Service():
|
||||
self.get_template_folders(template_type, template_folder_id)
|
||||
)
|
||||
|
||||
@property
|
||||
def count_of_templates_and_folders(self):
|
||||
return len(self.get_template_folders_and_templates('all', None))
|
||||
|
||||
def move_to_folder(self, ids_to_move, move_to):
|
||||
|
||||
ids_to_move = set(ids_to_move)
|
||||
|
||||
@@ -1,44 +1,54 @@
|
||||
{% from "components/checkbox.html" import unlabelled_checkbox %}
|
||||
{% from "components/message-count-label.html" import folder_contents_count %}
|
||||
{% from "components/message-count-label.html" import folder_contents_count, message_count_label %}
|
||||
|
||||
<nav id=template-list>
|
||||
{% for template_folder in template_folders %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template_folder.id),
|
||||
name='templates_and_folders',
|
||||
value=template_folder.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name template-list-folder">
|
||||
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=template_folder.id) }}">
|
||||
{{ template_folder.name }}
|
||||
</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ folder_contents_count(
|
||||
current_service.get_template_folders(template_type, template_folder.id)|length,
|
||||
current_service.get_templates(template_type, template_folder.id)|length,
|
||||
) }}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for template in templates %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template.id),
|
||||
name='templates_and_folders',
|
||||
value=template.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
{% if service_has_templates_or_folders and not templates and not template_folders %}
|
||||
<p class="template-list-empty">
|
||||
{% if template_folder_has_contents %}
|
||||
There are no {{ message_count_label(1, template_type, suffix='') }} templates in this folder
|
||||
{% else %}
|
||||
This folder is empty
|
||||
{% endif %}
|
||||
</p>
|
||||
{% else %}
|
||||
<nav id=template-list>
|
||||
{% for template_folder in template_folders %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template_folder.id),
|
||||
name='templates_and_folders',
|
||||
value=template_folder.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name template-list-folder">
|
||||
<a href="{{ url_for('.choose_template', service_id=current_service.id, template_type=template_type, template_folder_id=template_folder.id) }}">
|
||||
{{ template_folder.name }}
|
||||
</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ folder_contents_count(
|
||||
current_service.get_template_folders(template_type, template_folder.id)|length,
|
||||
current_service.get_templates(template_type, template_folder.id)|length,
|
||||
) }}
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% for template in templates %}
|
||||
<div class="template-list-item {% if can_manage_folders %}template-list-item-with-checkbox{% endif %}">
|
||||
{% if can_manage_folders %}
|
||||
{{ unlabelled_checkbox(
|
||||
id='templates-or-folder-{}'.format(template.id),
|
||||
name='templates_and_folders',
|
||||
value=template.id,
|
||||
) }}
|
||||
{% endif %}
|
||||
<h2 class="message-name">
|
||||
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=template.id) }}">{{ template.name }}</a>
|
||||
</h2>
|
||||
<p class="message-type">
|
||||
{{ message_count_label(1, template.template_type, suffix='')|capitalize }} template
|
||||
</p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
|
||||
@@ -77,7 +77,13 @@
|
||||
|
||||
{% if can_manage_folders %}
|
||||
<form method="post">
|
||||
{% with templates=templates, template_folders=template_folders %}
|
||||
{% with
|
||||
templates=templates,
|
||||
template_folders=template_folders,
|
||||
service_has_templates_or_folders=(current_service.has_templates or current_service.has_folders),
|
||||
template_type=template_type,
|
||||
template_folder_has_contents=template_folder_has_contents
|
||||
%}
|
||||
{% include 'views/templates/_template_list.html' %}
|
||||
{% endwith %}
|
||||
{% with templates=templates, template_folders=template_folders, templates_and_folders_form=templates_and_folders_form %}
|
||||
@@ -85,7 +91,13 @@
|
||||
{% endwith %}
|
||||
</form>
|
||||
{% else %}
|
||||
{% with templates=templates, template_folders=template_folders %}
|
||||
{% with
|
||||
templates=templates,
|
||||
template_folders=template_folders,
|
||||
service_has_templates_or_folders=(current_service.has_templates or current_service.has_folders),
|
||||
template_type=template_type,
|
||||
template_folder_has_contents=template_folder_has_contents
|
||||
%}
|
||||
{% include 'views/templates/_template_list.html' %}
|
||||
{% endwith %}
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user