{% extends "base.html" %}
{% from "macros.html" import render_field, form_tag %}

{% block content %}
  {% call form_tag(form) %}
    <div class="row">
      <div class="col-md-9 col-sm-8 col-xs-12">
        <h1>{{ title|default("Email template", true) }}</h1>
      </div>
    </div>
    <div class="row">
      <div class="col-md-6 col-sm-6 col-xs-12">
        {{ render_field(form.email_template_enabled, data_toggle="collapse", data_target="#template-row") }}
      </div>
    </div>
    <div class="{{'row collapse in' if form.email_template_enabled.data else 'row collapse'}}" id="template-row">
      <div class="col-md-10 col-sm-10 col-xs-12">
        {{ render_field(form.email_template) }}
      </div>
      <div class="col-md-4 col-sm-4 col-xs-8">
        The available template fields are:
        <dl>
          <dt>{BASE_URL}</dt>
          <dd>The ORCID Hub base URL</dd>
          <dt>{INCLUDED_URL}</dt>
          <dd>The invitation URL or status update detail URL</dd>
          <dt>{EMAIL}</dt>
          <dd>Recepient email address</dd>
          <dt>{LOGO}</dt>
          <dd>Organisation logo</dd>
          <dt>{MESSAGE}</dt>
          <dd>Core message that will be sent to the recepient</dd>
        </dl>
      </div>
    </div>
    <div class="row">
      <div class="col-md-6 col-sm-6 col-xs-12">
        <div class="form-group">
          {{ form.prefill(**{"data-toggle": "tooltip", "title": "Prefill or reset the email template"}) }}
          {#{ form.cancel }#}
          {{ form.save }}
          {{ form.send(**{"data-toggle": "tooltip", "title": "Send a test email to yourself"}) }}
        </div>
      </div>
    </div>
  {% endcall %}
{% endblock %}
