Files
notifications-admin/app/templates/components/folder-path.html
Chris Hill-Scott 88ad982bf7 Improve display of folder path when deeply nested
It’s a bit rudimentary to only show the current place in the hierarchy
and the parent. You lose a sense of how deep you are.

But we can’t just show the full path, because it can be arbitrarily
long. So what this commit does is show the full path, but truncates the
display of any items. Further-up than the current folder or its parent.

This also helps disambiguate between folders and templates, because
folders are always shown with the folder icon.

This probably won’t affect many teams, because we don’t anticipate a lot
of deep nesting.
2019-02-01 10:28:29 +00:00

88 lines
3.3 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% macro folder_path(
folders,
service_id,
template_type,
fallback_page_title=None,
show_fallback_page_title=False,
link_current_item=False
) %}
{% if show_fallback_page_title %}
<h1 class="heading-large">
{{ fallback_page_title }}
</h1>
{% else %}
<h1 class="heading-medium folder-heading">
{% for folder in folders %}
{% if loop.last and not link_current_item %}
{% if folder.template_type or not folder.id %}
<span class="folder-heading-template">{{ folder.name }}</span>
{% else %}
<span class="folder-heading-folder">{{ folder.name }}</span>
{% endif %}
{% else %}
{% if folder.id %}
<a href="{{ url_for('.choose_template', service_id=service_id, template_type=template_type, template_folder_id=folder.id) }}" class="folder-heading-folder {% if loop.index < (loop.length - 1) %}folder-heading-folder-truncated{% endif %}" title="{{ folder.name }}">{{ folder.name }}</a>
{% else %}
<a href="{{ url_for('.choose_template', service_id=service_id, template_type=template_type) }}" class="{% if loop.length > 2 %}folder-heading-folder-root-truncated{% endif %}">Templates</a>
{% endif %}
{% if not loop.last %}{{ folder_path_separator() }}{% endif %}
{% endif %}
{% endfor %}
</h1>
{% endif %}
{% endmacro %}
{% macro copy_folder_path(
folder_path,
current_service_id,
from_service
) %}
{% if folder_path %}
<h2 class="heading-medium folder-heading">
{% if folder_path|length == 1 %}
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service_id) }}">Services</a>
{{ folder_path_separator() }}
{% endif %}
{% for folder in folder_path %}
{% if loop.last %}
<span class="folder-heading-folder">
{{ folder.name if folder.id else from_service.name }}
</span>
{% else %}
{% if folder.id %}
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service_id, from_service=from_service.id, from_folder=folder.id) }}" class="folder-heading-folder">{{ folder.name }}</a> {% if not loop.last %}{{ folder_path_separator() }}{% endif %}
{% elif folder.parent_id == None %}
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service_id, from_service=from_service.id, from_folder=folder.id) }}" class="folder-heading-folder">{{ from_service.name }}</a> {% if not loop.last %}{{ folder_path_separator() }}{% endif %}
{% else %}
<a href="{{ url_for('.choose_template_to_copy', service_id=current_service_id, from_service=from_service.id) }}">{{ from_service.name }}</a> {% if not loop.last %}{{ folder_path_separator() }}{% endif %}
{% endif %}
{% endif %}
{% endfor %}
</h2>
{% endif %}
{% endmacro %}
{% macro page_title_folder_path(
folders,
fallback_page_title=None,
show_fallback_page_title=False
) %}
{% if show_fallback_page_title %}
{{ fallback_page_title }}
{% else %}
{% for folder in folders|reverse %}
{{ folder.name }}
{% if not loop.last %}
{% endif %}
{% endfor %}
{% endif %}
{% endmacro %}
{% macro folder_path_separator() %}
<span class="folder-heading-separator">/</span>
{% endmacro %}