Add filtering functionality to inventory listing and enhance templates for better data presentation

This commit is contained in:
Yaro Kasear 2025-06-12 11:29:18 -05:00
parent a7708ce9c5
commit 5df5f86fd2
8 changed files with 64 additions and 9 deletions

View file

@ -1,4 +1,5 @@
{% macro render_table(headers, rows, entry_route=None, title=None) %}
{% if rows %}
<div class="table-responsive">
<table
class="table table-bordered table-sm table-hover table-striped table-light m-0{% if title %} caption-top{% endif %}">
@ -32,6 +33,9 @@
</tbody>
</table>
</div>
{% else %}
<div class="container text-center">No data.</div>
{% endif %}
{% endmacro %}
{% macro render_pagination(endpoint, page, has_prev, has_next, total_pages, page_variable='page', extra_args={}) %}
@ -43,6 +47,7 @@
{% set _ = next_args.update({page_variable: page + 1}) %}
{% set _ = first_args.update({page_variable: 1}) %}
{% set _ = last_args.update({page_variable: total_pages}) %}
{% if total_pages > 1 %}
<div class="d-flex justify-content-between pt-3 px-5 align-items-center">
<div>
@ -72,4 +77,5 @@
class="btn btn-primary{% if not has_next %} disabled{% endif %}">Last &raquo;</a>
</div>
</div>
{% endif %}
{% endmacro %}

View file

@ -132,7 +132,7 @@ submit_button=True) }}
total_pages=worklog_pagination['total_pages'],
endpoint='main.inventory_item',
page_variable='worklog_page',
extra_args={'id': item.id, 'worklog_page': worklog_page}
extra_args={'id': item.id, 'worklog_page': worklog_page, 'filter_by': filter_by, 'id': id}
) }}
{% endif %}
</div>

View file

@ -77,6 +77,18 @@ title=title
By Type
</a></div>
</div>
{% else %}
<div class="container">
{% for line in listing %}
<div class="row my-3">
{% for id, name in line %}
<div class="col text-center">
<a href="{{ url_for('main.list_inventory', filter_by='user', id=id) }}" class="link-success link-underline-opacity-0">{{ name }}</a>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% endblock %}

View file

@ -13,5 +13,5 @@
) }}
{{ tables.render_table(header, rows, entry_route) }}
{{ tables.render_pagination(endpoint, page, has_prev, has_next, total_pages) }}
{{ tables.render_pagination(endpoint, page, has_prev, has_next, total_pages, extra_args=extra_args) }}
{% endblock %}