{% load i18n %}
{% load django_tables2 %}


<div class="cruditor-table">
	{% block table.pagination.top %}
		{% if table.page %}
			{% include 'cruditor/includes/table-pagination.html' %}
		{% endif %}
	{% endblock %}
	{% block table %}
		<table {% render_attrs table.attrs class="table" %}>
		{% block table.thead %}
			{% if table.show_header %}
				<thead {% render_attrs table.attrs.thead class="thead-light" %}>
					<tr>
						{% for column in table.columns %}
							{% if column.orderable %}
								<th {{ column.attrs.th.as_html }} scope="col"><a href="{% querystring table.prefixed_order_by_field=column.order_by_alias.next %}">{{ column.header }}</a></th>
							{% else %}
								<th {{ column.attrs.th.as_html }} scope="col">{{ column.header }}</th>
							{% endif %}
						{% endfor %}
					</tr>
				</thead>
			{% endif %}
		{% endblock %}
		{% block table.tbody %}
			<tbody{% if table.attrs.tbody %} {{ table.attrs.tbody.as_html }}{% endif %}>
				{% for row in table.page.object_list|default:table.rows %}
					{% block table.tbody.row %}
						<tr {{ row.attrs.as_html }}>
							{% for column, cell in row.items %}
								{% if forloop.first %}
									<th scope="row" {{ column.attrs.td.as_html }}>
								{% else %}
									<td {{ column.attrs.td.as_html }}>
								{% endif %}
								{% if column.localize == None %}{{ cell }}{% else %}{% if column.localize %}{{ cell|localize }}{% else %}{{ cell|unlocalize }}{% endif %}{% endif %}
								{% if forloop.first %}
									</th>
								{% else %}
									</td>
								{% endif %}
							{% endfor %}
						</tr>
					{% endblock %}
				{% empty %}
					{% block table.tbody.empty_text %}
						{% trans 'No data available.' as default_table_empty_text %}
						<tr><td colspan="{{ table.columns|length }}">{{ table.empty_text|default:default_table_empty_text }}</td></tr>
					{% endblock %}
				{% endfor %}
			</tbody>
		{% endblock %}
		{% block table.tfoot %}
			{% if table.has_footer %}
				<tfoot{% if table.attrs.tfoot %} {{ table.attrs.tfoot.as_html }}{% endif %}>
					<tr>
						{% for column in table.columns %}
							<td {{ column.attrs.tf.as_html }}>{{ column.footer }}</td>
						{% endfor %}
					</tr>
				</tfoot>
			{% endif %}
		{% endblock %}
		</table>
	{% endblock %}
	{% block table.pagination.bottom %}
		{% if table.page %}
			{% include 'cruditor/includes/table-pagination.html' %}
		{% endif %}
	{% endblock %}
</div>
