{% extends "layout.html" %}

{% block content_header %}
  {{ build_breadcrumbs([
    { 'name': _('Voicemail'), 'link': url_for('.VoicemailView:index'), 'icon': 'envelope' }
  ]) }}
{% endblock %}

{% block content %}
  <section class="content">
    {% call build_list_containers(_('Voicemails'), 'envelope') %}
      {% call build_list_table() %}
        {% call build_list_table_headers(get=url_for('.VoicemailView:get', id=''), delete=url_for('.VoicemailView:delete', id='')) %}
          <th>{{ _('Name') }}</th>
          <th>{{ _('Number') }}</th>
          <th>{{ _('Email') }}</th>
        {% endcall %}
        {% call(voicemail) build_list_table_rows(resource_list['items']) %}
          <td>{{ voicemail.name }}</td>
          <td>{{ voicemail.number }}</td>
          <td>{{ voicemail.email or '-' }}</td>
        {% endcall %}
      {% endcall %}
    {% endcall %}

    {% call build_hidden_add_containers(_('Add Voicemail')) %}
      {% call build_form() %}
        {% call add_default_fields(form=form, submit_value=_('Add')) %}
          {{ render_field(form.name) }}
          {{ render_field(form.context,
                          data_listing_href=url_for(listing_urls['context_by_type'], type_='internal')) }}
          {{ render_field(form.number) }}
          {{ render_field(form.password, autocomplete="off") }}
          {{ render_field(form.email) }}
          {{ render_field(form.language) }}
          {{ render_field(form.timezone) }}
          {{ render_field(form.user_uuid, data_listing_href=url_for(listing_urls['uuid_user'])) }}
        {% endcall %}
      {% endcall %}
    {% endcall %}
  </section>
{% endblock %}
