{% extends 'series-set-template-layout.html' %}

{% from 'macros.html' import alerter, menu %}
{% from 'series-set-template-form.html' import series_sets_preview %}

{% block menu %}
{{ series_set_template_menu('Series sets') }}
{% endblock %}

{% block series_set_template_content %}

{% if template.short_help_text != "" or template.origin.value == 'ui' %}
<div class="pt-3">
    {% if template.short_help_text != "" %}
    <p>
        {{ template.short_help_text }}
        <a data-bs-toggle="offcanvas"
           href="#series-set-template-help-text"
           aria-controls="series-set-template-help-text"
           aria-expanded="false">
            {{ bootstrap_icon('question-circle') }}
        </a>
    </p>
    {% else %}
        {% if template.origin.value == 'ui' %}
        <p>
            No description provided
            <a href="{{ url_for('.edit_template', templatereferencename=template.name, sourcename=source_name) }}">
                (add)
            </a>.
        </p>
        {% endif %}
    {% endif %}

    <div class="offcanvas offcanvas-end" tabindex="-1" id="series-set-template-help-text">
        <div class="offcanvas-header">
            <h3 class="offcanvas-title h5">{{ template.name }}</h3>
            <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
        </div>
        <div class="offcanvas-body">
            <p>{{ template.short_help_text }}</p>
            <div>{{ template.html_help_text|safe }}</div>
            {% if template.origin.value == 'ui' %}
            <p class="mt-3">
                <a class="btn btn-primary" href="{{ url_for('.edit_template', templatereferencename=template.name, sourcename=source_name) }}">
                    Edit description
                </a>
            </p>
            {% endif %}
        </div>
    </div>
</div>
{% endif %}

<div class="my-3 py-3">
    {{ alerter() }}

    {% if series_sets|count > 0 %}
    {{ series_sets_preview(series_sets) }}
    {% else %}
    <div class="alert alert-info">
        No series sets found.
    </div>
    {% endif %}
</div>
{% endblock %}
