{% extends "newman/edit_inline/tabular.html" %}

{% block header_fields %}
    {% if not field.is_listing_custom_field %}
    {{ block.super }}
    {% endif %}
{% endblock %}

{% block fieldset %}
    {% for fieldset in inline_admin_form %}
      {% for line in fieldset %}
        {% for field in line %}

          {% ifnotequal field.field.name "listings" %}
              <td class="{{ field.field.name }}">
              {{ field.field.errors.as_ul }}
              {{ field.field }}
              </td>
          {% else %}
{% if inline_admin_form.form.prefix != "placement_set-__prefix__" %}
            {% if inline_admin_formset.formset.can_delete %}
              <td class="delete">{% if inline_admin_form.original %}{{ inline_admin_form.deletion_field.field }}{% endif %}</td>
            {% endif %}
              {# customized listing widget, should be the last one#}
              </tr>
              {# custom row for ListingCustomWidget #}
              <tr class="listing-head">
                <td colspan="{{ inline_admin_form.field_count }}">
                    <h3>{% trans 'Listings' %}</h3>
                </td>
              </tr>
              <tr class="listing-head">
                <th></th>
                <th>{% trans 'Category' %}</th>
                <th>{% trans 'Publish from' %}</th>
                {% if inline_admin_formset.formset.show_commercial_switch %}
                    <th>{% trans 'Commercial' %}?</th>
                {% endif %}
                <th>{% trans 'Delete' %}?</th>
                <th colspan="2"></th>
              </tr>
{% endif %}
                  {{ field.field.errors.as_ul }}
                  {{ field.field }}
{% if inline_admin_form.form.prefix != "placement_set-__prefix__" %}
              <tr> {# open new row due to tabular.html will close row after fieldset block #}
                <td colspan="3"><a class="icn btn add add-listing-button">{% trans "Add" %}</a></td>
{% endif %}
          {% endifnotequal %}

        {% endfor %}
      {% endfor %}
    {% endfor %}
{% endblock %}

{% block tabular_quick_sel %}
<p><a class="icn btn addfav js-placement-main-category">{% trans "Main category" %}</a></p>
{% endblock %}
