2022-01-03 19:31:34 +01:00
|
|
|
{% extends "base.html" %}
|
|
|
|
|
|
|
|
{% block content %}
|
2022-08-06 20:13:26 +02:00
|
|
|
|
|
|
|
{% if not render_partial or render_partial == false %}
|
|
|
|
<div class="columns">
|
|
|
|
<div class="column">
|
|
|
|
<div class="buttons">
|
2022-10-07 21:32:59 +02:00
|
|
|
<a class="button is-primary" href="create" hx-boost="true" hx-indicator="#loading">Create</a>
|
2022-08-06 20:13:26 +02:00
|
|
|
|
2023-01-13 21:11:42 +01:00
|
|
|
<div class="dropdown is-hoverable">
|
2022-08-06 20:13:26 +02:00
|
|
|
<div class="dropdown-trigger">
|
|
|
|
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu4">
|
|
|
|
<span>With selected</span>
|
|
|
|
<span class="icon is-small">
|
|
|
|
<i class="fas fa-angle-down" aria-hidden="true"></i>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="dropdown-menu" id="dropdown-menu4">
|
|
|
|
<div class="dropdown-content">
|
|
|
|
<div class="dropdown-item">
|
2023-01-13 21:11:42 +01:00
|
|
|
<a hx-include="#table_form" hx-target="#{{ entity_name }}table" href="#"
|
|
|
|
hx-indicator="#loading" hx-confirm="Are you sure?" hx-delete="delete">Delete</a>
|
2022-08-06 20:13:26 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-13 21:11:42 +01:00
|
|
|
<form id="search_form" action="/admin/{{ entity_name }}/list" hx-boost="true" hx-indicator="#loading"
|
|
|
|
hx-target="#{{ entity_name }}table" hx-trigger="reload_table from:#entities_per_page"
|
|
|
|
hx-vals='{ "render_partial" : "true" }'>
|
|
|
|
<input type="hidden" id="sort_by" name="sort_by" value="{{ sort_by }}">
|
|
|
|
<input type="hidden" id="sort_order" name="sort_order" value="{{ sort_order }}">
|
|
|
|
<div class="column is-narrow">
|
|
|
|
<div class="field is-horizontal">
|
|
|
|
{% if view_model.show_search %}
|
|
|
|
<p class="control has-icons-left has-icons-right">
|
|
|
|
<input class="input is-rounded" type="search" id="search" value="{{ search }}" name="search"
|
|
|
|
placeholder="Search" hx-get="/admin/{{ entity_name }}/list"
|
|
|
|
hx-trigger="keyup changed delay:500ms, search">
|
|
|
|
<span class="icon is-small is-left">
|
|
|
|
<i class="fas fa-search"></i>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
{% endif %}
|
2022-08-06 20:13:26 +02:00
|
|
|
<div class="select">
|
2023-01-13 21:11:42 +01:00
|
|
|
<div class="ml-1 control has-icons-left has-icons-right">
|
|
|
|
<select id="entities_per_page" class="select" name="entities_per_page"
|
|
|
|
onchange="this.dispatchEvent(new Event('reload_table'));">
|
2022-08-06 20:13:26 +02:00
|
|
|
{% for a in [10,20,50,100,] %}
|
|
|
|
<option {% if entities_per_page==a %}selected{% endif %} value="{{ a }}">{{ a }}</option>
|
|
|
|
{% endfor %}
|
|
|
|
</select>
|
|
|
|
<p class="help">Entities per Page</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-13 21:11:42 +01:00
|
|
|
</div>
|
2022-08-06 20:13:26 +02:00
|
|
|
</div>
|
2023-01-13 21:11:42 +01:00
|
|
|
</form>
|
2022-08-06 20:13:26 +02:00
|
|
|
</div>
|
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
<div id="{{ entity_name }}table">
|
2023-01-13 21:11:42 +01:00
|
|
|
<div class="is-relative">
|
|
|
|
{% include "loader.html" %}
|
|
|
|
<form id="table_form" hx-indicator="#loading" hx-get="/admin/{{ entity_name }}/list"
|
|
|
|
hx-vals='{ "render_partial" : "true" }' hx-target="#{{ entity_name }}table">
|
|
|
|
<input type="hidden" id="sort_by" name="sort_by" value="{{ sort_by }}">
|
|
|
|
<input type="hidden" id="sort_order" name="sort_order" value="{{ sort_order }}">
|
|
|
|
<input type="hidden" name="entities_per_page" value="{{ entities_per_page }}">
|
|
|
|
<input type="hidden" name="search" value="{{ search }}">
|
|
|
|
<input type="hidden" name="page" value="{{ page }}">
|
|
|
|
<table class="table is-relative is-fullwidth is-hoverable is-striped">
|
|
|
|
<thead>
|
2023-01-08 15:45:28 +01:00
|
|
|
<tr>
|
|
|
|
<th>
|
|
|
|
<input type="checkbox" onclick="checkAll(this)">
|
|
|
|
</th>
|
|
|
|
<th onclick="sort_by('{{ view_model.primary_key }}');" class="is-clickable">{{
|
|
|
|
view_model.primary_key | title }}
|
|
|
|
{% if sort_by == view_model.primary_key %}
|
2023-01-13 21:11:42 +01:00
|
|
|
{% if sort_order == "Asc" %}
|
2023-01-06 16:12:51 +01:00
|
|
|
<i class="ml-1 fa-solid fa-caret-up"></i>
|
2023-01-13 21:11:42 +01:00
|
|
|
{% elif sort_order == "Desc" %}
|
2023-01-06 16:12:51 +01:00
|
|
|
<i class="ml-1 fa-solid fa-caret-down"></i>
|
2023-01-08 15:45:28 +01:00
|
|
|
{% endif %}
|
|
|
|
{% endif %}
|
|
|
|
</th>
|
2023-01-15 14:18:46 +01:00
|
|
|
{% for model_field in view_model.fields | filter(attribute="list_hide_column", value=false) | sort(attribute="list_sort_position") -%}
|
2023-01-08 15:45:28 +01:00
|
|
|
<th onclick="sort_by('{{ model_field.field_name }}');" class="is-clickable">{{
|
|
|
|
model_field.field_name | split(pat="_") | join(sep=" ") | title }}
|
|
|
|
{% if sort_by == model_field.field_name %}
|
2023-01-13 21:11:42 +01:00
|
|
|
{% if sort_order == "Asc" %}
|
2023-01-08 15:45:28 +01:00
|
|
|
<i class="ml-1 fa-solid fa-caret-up"></i>
|
2023-01-13 21:11:42 +01:00
|
|
|
{% elif sort_order == "Desc" %}
|
2023-01-08 15:45:28 +01:00
|
|
|
<i class="ml-1 fa-solid fa-caret-down"></i>
|
|
|
|
{% endif %}
|
2023-01-06 16:12:51 +01:00
|
|
|
{% endif %}
|
2023-01-08 15:45:28 +01:00
|
|
|
</th>
|
|
|
|
{%- endfor %}
|
|
|
|
<th>
|
|
|
|
<!-- Edit Action -->
|
|
|
|
<!-- Delete Action -->
|
|
|
|
</th>
|
|
|
|
</tr>
|
2023-01-13 21:11:42 +01:00
|
|
|
</form>
|
|
|
|
</thead>
|
|
|
|
<tbody hx-indicator="#loading" hx-boost="true">
|
2023-01-08 15:45:28 +01:00
|
|
|
{% for entity in entities -%}
|
|
|
|
<tr>
|
|
|
|
<td><input type="checkbox" name="ids" value="{{ entity.primary_key }}"></td>
|
|
|
|
<td>
|
|
|
|
<a href="show/{{ entity.primary_key }}">
|
|
|
|
<i class="fa-solid fa-magnifying-glass"></i> {{ entity.primary_key }}
|
|
|
|
</a>
|
|
|
|
</td>
|
2023-01-15 14:18:46 +01:00
|
|
|
{% for model_field in view_model.fields | filter(attribute="list_hide_column", value=false) | sort(attribute="list_sort_position") -%}
|
2023-01-08 15:45:28 +01:00
|
|
|
{% if model_field.field_type == "Checkbox" %}
|
|
|
|
<td>{{ entity.values | get(key=model_field.field_name) | get_icon | safe }}</td>
|
|
|
|
{% elif model_field.field_type == "FileUpload" %}
|
2023-01-11 20:30:33 +01:00
|
|
|
<td><a href="file/{{ entity.primary_key }}/{{ model_field.field_name }}">{{
|
2023-01-08 15:45:28 +01:00
|
|
|
entity.values
|
|
|
|
| get(key=model_field.field_name) }}</a></td>
|
|
|
|
{% else %}
|
|
|
|
<td>{{ entity.values | get(key=model_field.field_name) }}</td>
|
2023-01-06 16:12:51 +01:00
|
|
|
{% endif %}
|
2023-01-08 15:45:28 +01:00
|
|
|
{%- endfor %}
|
|
|
|
<td>
|
2023-01-13 21:11:42 +01:00
|
|
|
<a hx-target="body" href="edit/{{ entity.primary_key }}"><i class="fa-solid fa-pen-to-square"></i></a>
|
|
|
|
<a hx-target="closest tr" hx-confirm="Are you sure?"
|
|
|
|
hx-delete="delete/{{ entity.primary_key }}"><i class="fa-solid fa-trash"></i></a>
|
2023-01-08 15:45:28 +01:00
|
|
|
</td>
|
|
|
|
</tr>
|
2022-08-06 20:13:26 +02:00
|
|
|
{%- endfor %}
|
2023-01-13 21:11:42 +01:00
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr>
|
|
|
|
<td colspan="{{ view_model.fields | length + 3 }}">
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tfoot>
|
|
|
|
</table>
|
2022-08-06 20:13:26 +02:00
|
|
|
</form>
|
2023-01-13 21:11:42 +01:00
|
|
|
</div>
|
|
|
|
<nav hx-boost="true"
|
|
|
|
hx-push-url="true"
|
|
|
|
hx-target="#{{ entity_name }}table"
|
|
|
|
hx-vals='{
|
|
|
|
"entities_per_page" : "{{ entities_per_page }}",
|
|
|
|
"search" : "{{ search }}",
|
|
|
|
"sort_by" : "{{ sort_by }}",
|
|
|
|
"sort_order" : "{{ sort_order }}",
|
|
|
|
"render_partial" : "true"
|
|
|
|
}' hx-indicator="#loading" class="pagination is-rounded is-centered" role="pagination"
|
2023-01-08 16:06:49 +01:00
|
|
|
aria-label="pagination">
|
2023-01-08 15:45:28 +01:00
|
|
|
{% if page > 1 %}
|
2023-01-13 21:11:42 +01:00
|
|
|
<a href="?&page={{ page - 1 }}"
|
2023-01-08 15:45:28 +01:00
|
|
|
class="pagination-previous left-arrow-click"><i class="fa-solid fa-arrow-left"></i>
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
2023-01-08 16:06:49 +01:00
|
|
|
{% if page < num_pages %} <a
|
2023-01-13 21:11:42 +01:00
|
|
|
href="?page={{ page + 1 }}"
|
2023-01-08 15:45:28 +01:00
|
|
|
class="pagination-next right-arrow-click"><i class="fa-solid fa-arrow-right"></i>
|
2023-01-08 16:06:49 +01:00
|
|
|
</a>
|
|
|
|
{% endif %}
|
|
|
|
<ul class="pagination-list">
|
|
|
|
<li>
|
|
|
|
<a class="pagination-link {% if page == 1 %}is-current{% endif %}"
|
2023-01-13 21:11:42 +01:00
|
|
|
href="?page={{ 1 }}"
|
2023-01-08 16:06:49 +01:00
|
|
|
aria-label="Goto page 1">1</a>
|
|
|
|
</li>
|
|
|
|
<li>
|
|
|
|
<span class="pagination-ellipsis">…</span>
|
|
|
|
</li>
|
|
|
|
{% for i in range(start=min_show_page,end=max_show_page) %}
|
|
|
|
<li><a class="pagination-link {% if page == i+1 %}is-current{% endif %}"
|
|
|
|
aria-label="Goto page {{ i + 1 }}"
|
2023-01-13 21:11:42 +01:00
|
|
|
href="?page={{ i + 1 }}">{{
|
2023-01-08 16:06:49 +01:00
|
|
|
i + 1 }}</a></li>
|
|
|
|
{%- endfor %}
|
|
|
|
<li>
|
|
|
|
<span class="pagination-ellipsis">…</span>
|
|
|
|
</li>
|
|
|
|
<li>
|
2023-01-13 21:11:42 +01:00
|
|
|
<a href="?page={{ num_pages }}"
|
2023-01-08 16:06:49 +01:00
|
|
|
class="pagination-link is-rounded {% if page == num_pages %}is-current{% endif %}"
|
|
|
|
aria-label="Goto page {{ num_pages }}">{{ num_pages }} </a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
2022-08-06 20:13:26 +02:00
|
|
|
</nav>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% if not render_partial or render_partial == false %}
|
|
|
|
|
|
|
|
{% endif %}
|
|
|
|
|
2022-01-03 19:31:34 +01:00
|
|
|
{% endblock content %}
|