mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05:00
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.
88 lines
3.3 KiB
HTML
88 lines
3.3 KiB
HTML
{% 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 %}
|