{% extends 'timeseer.html' %}

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

{% block menu %}
{{ menu_back(url_for('.preview_template', templatename=template_reference_name, sourcename=source_name)) }}
{% endblock %}

{% block main %}
<div class="ts-section py-3 my-3">
    <h2 class="h4">Edit {{ template_reference_name }}</h2>
</div>

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

    {{ series_set_template_form('Save', template, sources, template_reference_name, source_name=source_name) }}

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

{% block scripts_bottom %}
<script src="{{ url_for('static', filename='dist/define-series-set-template.js') }}"></script>
{% endblock %}
