bookforge/templates/index.html
2026-01-29 17:06:50 +01:00

67 lines
2.2 KiB
HTML

{% extends "base.html" %}
{% import "components/typography.html" as typography %}
{% import "components/dropdown.html" as dropdown %}
{% import "components/cards.html" as cards %}
{% block main %}
{{ typography::heading("All books") }}
{% call cards::card() %}
<table class="table table-hover">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Name</th>
<th scope="col">Author(s)</th>
<th scope="col">Owner</th>
<th scope="col">Current Holder</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
{% for book_with_user in books_with_user %}
<tr>
<th scope="row">{{ book_with_user.book.id }}</th>
<td>{{ book_with_user.book.title }}</td>
<td>{{ book_with_user.book.authors }}</td>
<td>{{ book_with_user.owner.name }}</td>
<td>
{% match book_with_user.current_holder %}
{% when Some with (current_holder) %}
{{ current_holder.name }}
{% when None %}
-
{% endmatch %}
</td>
<td>
{{ dropdown::book_dropdown_button(book_with_user.book) }}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% if total_page > 1 %}
<nav aria-label="Page navigation">
<ul class="pagination">
<li class="page-item {% if current_page <= 1 %}disabled{% endif %}">
<a class="page-link" href="/?page={% if current_page > 1 %}{{ current_page - 1 }}{% else %}1{% endif %}">Prev</a>
</li>
{% for page in 1..(total_page + 1) %}
{% if page >= current_page - 1 && page <= current_page + 1 %}
<li class="page-item {% if page == current_page %}active{% endif %}">
<a class="page-link" href="/?page={{ page }}">{{ page }}</a>
</li>
{% endif %}
{% endfor %}
<li class="page-item {% if current_page == total_page %}disabled{% endif %}">
<a class="page-link" href="/?page={{ current_page + 1 }}">Next</a>
</li>
</ul>
</nav>
{% endif %}
{% endcall %}
{% endblock %}