2022-04-23 20:03:09 +02:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block content %}
|
2022-07-26 22:34:33 +02:00
|
|
|
|
2022-07-29 17:53:59 +02:00
|
|
|
{% if not render_partial or render_partial == false %}
|
2022-07-26 22:34:33 +02:00
|
|
|
<article>
|
|
|
|
<div class="grid">
|
2022-07-29 17:53:59 +02:00
|
|
|
<div>
|
|
|
|
<details role="list">
|
|
|
|
<summary aria-haspopup="listbox" role="button">
|
2022-07-31 16:33:02 +02:00
|
|
|
Actions
|
2022-07-29 17:53:59 +02:00
|
|
|
</summary>
|
|
|
|
<ul role="listbox">
|
2022-07-31 16:33:02 +02:00
|
|
|
<li><a href="create">Create</a></li>
|
|
|
|
<li><a>Delete Selected</a></li>
|
2022-07-29 17:53:59 +02:00
|
|
|
</ul>
|
|
|
|
</details>
|
2022-07-31 16:33:02 +02:00
|
|
|
</div>
|
2022-07-29 17:53:59 +02:00
|
|
|
<div>
|
|
|
|
<input type="search" id="search" name="search" placeholder="Search"
|
|
|
|
hx-get="/admin/{{ entity_name }}/list?render_partial=true&entities_per_page={{ entities_per_page }}&page={{ page }}"
|
|
|
|
hx-trigger="keyup changed delay:500ms, search" hx-target="#{{ entity_name }}table"
|
2022-07-31 16:33:02 +02:00
|
|
|
hx-indicator=".htmx-indicator"
|
2022-07-29 17:53:59 +02:00
|
|
|
>
|
2022-07-26 22:34:33 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-07-29 17:53:59 +02:00
|
|
|
<figure id="{{ entity_name }}table">
|
|
|
|
{% endif %}
|
|
|
|
<table role="grid">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>
|
2022-07-31 16:33:02 +02:00
|
|
|
<div class="htmx-indicator">{% include "spinner.svg" %}</div>
|
2022-07-29 17:53:59 +02:00
|
|
|
</th>
|
|
|
|
<th>{{ view_model.primary_key | title }}</th>
|
|
|
|
{% for model_field in view_model.fields -%}
|
|
|
|
<th>{{ model_field.field_name | split(pat="_") | join(sep=" ") | title }}</th>
|
|
|
|
{%- endfor %}
|
|
|
|
<th>
|
|
|
|
<!-- Edit Action -->
|
|
|
|
<!-- Delete Action -->
|
|
|
|
</th>
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody hx-confirm="Are you sure?" hx-target="closest tr" hx-swap="outerHTML">
|
|
|
|
{% for entity in entities -%}
|
|
|
|
<tr>
|
|
|
|
<td><input type="checkbox" id="entity{{ entity.primary_key }}" name="terms"></td>
|
|
|
|
<td>{{ entity.primary_key }}</td>
|
|
|
|
{% for model_field in view_model.fields -%}
|
|
|
|
<td>{{ entity.values | get(key=model_field.field_name) }}</td>
|
2022-06-02 18:46:24 +02:00
|
|
|
{%- endfor %}
|
2022-07-29 17:53:59 +02:00
|
|
|
<td>
|
|
|
|
<a href="edit/{{ entity.primary_key }}">✎</a>
|
|
|
|
<a href="#" hx-post="delete/{{ entity.primary_key }}">🗑</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
{%- endfor %}
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<td colspan="{{ view_model.fields | length + 3 }}">
|
|
|
|
<a href="?page={{ page - 1 }}&entities_per_page={{ entities_per_page }}">«</a>
|
|
|
|
{% for i in range(end=num_pages) %}
|
|
|
|
<a href="?page={{ i + 1 }}&entities_per_page={{ entities_per_page }}">{{ i + 1 }}</a>
|
|
|
|
{%- endfor %}
|
|
|
|
<a href="?page={{ page + 1 }}&entities_per_page={{ entities_per_page }}">»</a>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
|
|
|
{% if not render_partial or render_partial == false %}
|
|
|
|
</figure>
|
2022-07-26 22:34:33 +02:00
|
|
|
<div class="grid">
|
2022-07-29 17:53:59 +02:00
|
|
|
<div></div>
|
|
|
|
<div></div>
|
|
|
|
<div></div>
|
2022-07-26 22:34:33 +02:00
|
|
|
<div>
|
|
|
|
<form>
|
|
|
|
<label for="entities_per_page">Entities per Page
|
|
|
|
<select name="entities_per_page" onchange="this.form.submit()">
|
|
|
|
{% for a in [10,20,50,100,] %}
|
2022-07-29 17:53:59 +02:00
|
|
|
<option {% if entities_per_page==a %}selected{% endif %} value="{{ a }}">{{ a }}</option>
|
2022-07-26 22:34:33 +02:00
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
</label>
|
|
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</article>
|
2022-07-29 17:53:59 +02:00
|
|
|
{% endif %}
|
2022-04-23 20:03:09 +02:00
|
|
|
{% endblock content %}
|