{% macro list_form(form, isnew) %}

<form method="POST">
  {{ form.csrf_token }}

  {{ form.name.label }}
  {{ form.name }}

  {{ form.address.label }}
  {%- if isnew %}
  {{ form.address(value="@" + config.IMAP_DEFAULT_USER_DOMAIN) }}
  {%- else %}
  {{ form.address }}
  {%- endif %}

  <fieldset>
    {{ form.avoid_duplicates(role="switch") }}
    {{ form.avoid_duplicates.label }}
  </fieldset>

  <details name="mode" open="open">
    <summary>{{ _('Mode Settings') }}</summary>

    <fieldset id="select-mode">
      {{ form.mode.label }}
      {{ form.mode }}
    </fieldset>

    <fieldset class="mode-group">
      {{ form.only_subscribers_send(role="switch") }}
      {{ form.only_subscribers_send.label }}
    </fieldset>

    <fieldset class="mode-broadcast">
      {{ form.from_addr.label }}
      {{ form.from_addr(placeholder=("John Doe <john.doe@example.com>")) }}
      <small>{{ (form.from_addr.description) }}</small>

      {{ form.allowed_senders.label }}
      {{ form.allowed_senders(placeholder=("user@example.com,another@example.com")) }}
      <small>{{ (form.allowed_senders.description) }}</small>

      {{ form.sender_auth.label }}
      {{ form.sender_auth(placeholder=("password1,password2")) }}
      <small>{{ (form.sender_auth.description) }}</small>
    </fieldset>
  </details>

  <hr />

  <details>
    <summary>{{ _('IMAP Settings') }}</summary>
    {{ form.imap_host.label }}
    {{ form.imap_host(placeholder=config.IMAP_DEFAULT_HOST) }}

    {{ form.imap_port.label }}
    {{ form.imap_port(placeholder=config.IMAP_DEFAULT_PORT) }}

    {{ form.imap_user.label }}
    {%- if isnew %}
    {{ form.imap_user(placeholder=_("Leave empty to use list address")) }}
    {%- else %}
    {{ form.imap_user }}
    {%- endif %}

    {{ form.imap_pass.label }}
    {%- if isnew %}
    {{ form.imap_pass(placeholder=_("Leave empty to use configured default")) }}
    {%- else %}
    {{ form.imap_pass(placeholder=_("Leave empty to not update password")) }}
    {%- endif %}
  </details>

  <br />

  {{ form.submit(value=_('Save List')) }}
</form>

{% endmacro %}


{% macro subscriber_list_buttons(email) %}
{%- if is_email_a_list(email) %}
<p>
    <a href="{{ url_for('lists.edit', list_id=is_email_a_list(email).id) }}" role="button" class="">
        {{ _('Edit List Settings') }}
    </a>
    <a href="{{ url_for('lists.subscribers_manage', list_id=is_email_a_list(email).id) }}" role="button" class="secondary">
        {{ _('View List Subscribers') }}
    </a>
</p>
{%- endif %}
{% endmacro %}
