mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-05 22:21:34 -04:00
For someone who has retrieved a template ID from their system the only way to find it in Notify is: - hack the URL - click through every template, visually inspecting the ID shown on the page until you find the right one Neither of these is ideal. This commit adds searching by ID, for those services who have an API integration. This means we don’t need to confuse teams who aren’t using the API by talking about IDs. This is similar to how we let these teams search for notifications by reference[1] 1. https://github.com/alphagov/notifications-admin/pull/3223/files
104 lines
4.2 KiB
HTML
104 lines
4.2 KiB
HTML
{% macro format_item_name(name, separators=True) -%}
|
|
{%- if name is string -%}
|
|
{{- name -}}
|
|
{%- else -%}
|
|
{%- for part in name -%}
|
|
{{- format_item_name(part, separators) -}}
|
|
{%- if not loop.last -%}
|
|
{%- if separators %}
|
|
<span class="message-name-separator"></span>{%- else %} {% endif -%}
|
|
{% endif -%}
|
|
{%- endfor -%}
|
|
{% endif %}
|
|
{%- endmacro %}
|
|
|
|
{% if template_list.template_folder_id and not template_list.templates_to_show %}
|
|
<p class="template-list-empty">
|
|
{% if template_list.folder_is_empty %}
|
|
This folder is empty
|
|
{% else %}
|
|
There are no {{ 1|message_count_label(template_type, suffix='') }} templates in this folder
|
|
{% endif %}
|
|
</p>
|
|
{% else %}
|
|
<nav id="template-list" class="{{ 'govuk-!-margin-top-1' if (not show_template_nav and not show_search_box) else 'govuk-!-margin-top-6' }}">
|
|
{% set checkboxes_data = [] %}
|
|
|
|
{% if not current_user.has_permissions('manage_templates') %}
|
|
<ul>
|
|
{% endif %}
|
|
|
|
{% for item in template_list %}
|
|
|
|
{% set item_link_content %}
|
|
{% 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) }}" class="govuk-link govuk-link--no-visited-state template-list-folder">
|
|
{{- format_item_name(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) }}" class="govuk-link govuk-link--no-visited-state template-list-folder">
|
|
<span class="live-search-relevant">{{- format_item_name(item.name) -}}</span>
|
|
</a>
|
|
{% else %}
|
|
<a href="{{ url_for('.view_template', service_id=current_service.id, template_id=item.id) }}" class="govuk-link govuk-link--no-visited-state template-list-template">
|
|
<span class="live-search-relevant">
|
|
{%- if current_service.api_keys -%}
|
|
<span class="govuk-!-display-none">{{ item.id }} </span>
|
|
{%- endif -%}
|
|
{{- format_item_name(item.name) -}}
|
|
</span>
|
|
</a>
|
|
{% endif %}
|
|
{% endset %}
|
|
|
|
{% set label_content %}
|
|
<span class="govuk-visually-hidden">
|
|
{%- for ancestor in item.ancestors %}{{ format_item_name(ancestor.name, separators=False) }} {% endfor -%}
|
|
{{ format_item_name(item.name, separators=False) -}}
|
|
</span>
|
|
{% endset %}
|
|
|
|
{% set item_meta %}
|
|
<span id="{{ item.id }}-item-hint" class="govuk-hint govuk-checkboxes__hint template-list-item-hint">
|
|
{{ item.hint }}
|
|
</span>
|
|
{% endset %}
|
|
|
|
{# create the item config now to include the label content -#}
|
|
{# TODO: "attributes": { "aria-describedby": item.id ~ "-hint" } needs to be added but govuk-frontend-jinja doesn't currently support this -#}
|
|
{% set checkbox_config = {
|
|
"html": label_content,
|
|
"label": {
|
|
"classes": "template-list-item-label",
|
|
},
|
|
"id": "templates-or-folder-" ~ item.id,
|
|
"classes": "template-list-item template-list-item-with-checkbox {}".format(
|
|
"template-list-item-hidden-by-default" if item.ancestors else "template-list-item-without-ancestors"),
|
|
"after": item_link_content ~ item_meta
|
|
} %}
|
|
{% set _ = checkboxes_data.append(checkbox_config) %}
|
|
|
|
{% if not current_user.has_permissions('manage_templates') %}
|
|
<li class="template-list-item {%- if item.ancestors %} template-list-item-hidden-by-default {%- else %} template-list-item-without-ancestors{%- endif %}">
|
|
{{ item_link_content }}
|
|
<p class="template-list-item-hint govuk-!-margin-bottom-4">
|
|
{{ item.hint }}
|
|
</p>
|
|
</li>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% if not current_user.has_permissions('manage_templates') %}
|
|
</ul>
|
|
{% endif %}
|
|
|
|
{% if current_user.has_permissions('manage_templates') %}
|
|
{{ templates_and_folders_form.templates_and_folders(param_extensions={
|
|
"items": checkboxes_data,
|
|
"formGroup": False
|
|
}) }}
|
|
{% endif %}
|
|
</nav>
|
|
{% endif %}
|