{% 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 %}
		<div class="cruditor-table">
			<table class="table"{% if table.attrs %} {{ table.attrs.as_html }}{% endif %}>
			{% block table.thead %}
				{% if table.show_header %}
					<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.tfoot %}
				{% if table.has_footer %}
					<tfoot>
						<tr>
							{% for column in table.columns %}
								<td {{ column.attrs.tf.as_html }}>{{ column.footer }}</td>
							{% endfor %}
						</tr>
					</tfoot>
				{% endif %}
			{% endblock %}
			{% block table.tbody %}
				<tbody>
					{% 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 %}
		</table>
	{% endblock %}
	{% block table.pagination.bottom %}
		{% if table.page %}
			{% include 'cruditor/includes/table-pagination.html' %}
		{% endif %}
	{% endblock %}
</div>
