CRUDkit fixes and changes.

This commit is contained in:
Yaro Kasear 2025-09-10 09:18:31 -05:00
parent 9d36d600bb
commit 7ddfe084ba
5 changed files with 98 additions and 43 deletions

View file

@ -1,12 +1,20 @@
<table>
{% if objects %}
{% if rows %}
<thead>
<tr>
{% for field in objects[0].__table__.columns %}<th>{{ field.name }}</th>{% endfor %}
{% if headers %}
{% for header in headers %}<th>{{ header }}</th>{% endfor %}
{% else %}
{% for field in fields if field != "id" %}<th>{{ field }}</th>{% endfor %}
{% endif %}
</tr>
{% for obj in objects %}
<tr>{% for field in obj.__table__.columns %}<td>{{ obj[field.name] }}</td>{% endfor %}</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>{% for _, cell in row.items() if _ != "id" %}<td>{{ cell if cell else "-" }}</td>{% endfor %}</tr>
{% endfor %}
{% else %}
<tr><th>No data.</th></tr>
{% endif %}
{% else %}
<tr><th>No data.</th></tr>
{% endif %}
</tbody>
</table>