{% load dynamicforms %}
{% if serializer.render_type != 'table rows' %}
  {% block tablestart-includes %}{% endblock %}
  <table id="list-{{ serializer.uuid }}" class="table table-striped">
  <thead>
  <tr>
    {% table_columns_count serializer as columns_count %}
    {# TODO: Remove "Actions" strings #}
    {% render_table_commands serializer "thead_rowstart" %}
    {% for column in serializer.fields.values %}
      {% if column.display_table == DYNAMICFORMS.DisplayMode.FULL or column.display_table == DYNAMICFORMS.DisplayMode.INVISIBLE %}
        <th class="{{ column.table_classes }}{% if column.display_table == DYNAMICFORMS.DisplayMode.INVISIBLE %}d-none{% endif %}">{{ column.label }}</th>{% endif %}{% endfor %}
    {% render_table_commands serializer "thead_rowend" %}
  </tr>
  {% if serializer.show_filter %}
    {% render_form serializer.filter_data form_template=DYNAMICFORMS.table_filter_base_template %}
  {% endif %}
  </thead>
  <tbody>
{% endif %}
{% include DYNAMICFORMS.table_body_base_template %}
{% if serializer.render_type != 'table rows' %}
  </tbody>
  <tfoot>
  <tr id="loading-{{ serializer.uuid }}" style="display: none">
    <td colspan="{{ columns_count }}" align="center">Loading...</td>
  </tr>
  </tfoot>
  </table>
  {% block tableend-includes %}{% endblock %}
  {% render_table_commands serializer "onrowclick" %}
  {#TODO: Unit test: check if on_click & on_right_click declare properly, when table rows dynamically load#}
  <script type="application/javascript">
    {% if serializer.show_filter %}
      dynamicforms.registerFilterRowKeypress("{{ serializer.uuid }}", "{% url url_reverse|add:'-list' format='html'%}");
    {% endif %}
    dynamicforms.paginatorInitTable("{{ serializer.uuid }}", "{{ link_next }}", "{{ link_prev }}");
    dynamicforms.setRecordURL("{{ serializer.uuid }}", "{% url url_reverse|add:'-list' format='html' %}");
    {% block scriptend-includes %}{% endblock %}
  </script>
{% endif %}
