{% extends "base.html" %}
{% block title %}{{ title }} - Laterite{% endblock %}
{% block content %}
<div class="lat-toolbar">
<h1>{{ title }}</h1>
{% if creatable %}{% if let Some(base) = edit_base %}<div class="lat-toolbar__actions"><a class="lat-btn lat-btn--primary" href="{{ base }}/new">+ New</a></div>{% endif %}{% endif %}
</div>
<div class="lat-tablewrap">
<table class="lat-table">
<thead><tr>
{% for c in columns %}<th>{{ c }}</th>{% endfor %}
{% if edit_base.is_some() %}<th></th>{% endif %}
</tr></thead>
<tbody>
{% if rows.is_empty() %}
<tr><td class="lat-table__empty" colspan="99">No records.</td></tr>
{% else %}
{% for row in rows %}
<tr>
{% for cell in row.cells %}<td>{{ cell }}</td>{% endfor %}
{% if let Some(base) = edit_base %}<td class="lat-table__actions"><a href="{{ base }}/{{ row.id }}/edit">Edit</a></td>{% endif %}
</tr>
{% endfor %}
{% endif %}
</tbody>
</table>
</div>
<div class="lat-listfoot">
<span>Displayed records: {{ rows.len() }} of {{ total }}</span>
<span class="lat-pager">
{% if page > 1 %}<a class="lat-btn lat-btn--secondary lat-btn--sm" href="?page={{ page - 1 }}">← Prev</a>{% endif %}
<span style="align-self:center">Page {{ page }} of {{ total_pages }}</span>
{% if page < total_pages %}<a class="lat-btn lat-btn--secondary lat-btn--sm" href="?page={{ page + 1 }}">Next →</a>{% endif %}
</span>
</div>
{% endblock %}