From ec79bc2ca366faf89770463121e0750768e873d2 Mon Sep 17 00:00:00 2001 From: ijuanes Date: Thu, 4 Jun 2026 01:00:17 +0100 Subject: [PATCH 1/9] feat(loans): add search and expandable past loans to user loans view MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add search box to filter by user name, ID, tablet brand/model/serial - Split loans into Current Loans (always visible) and Past Loans (collapsible) - Past loans toggle with ▶/▼ indicator showing count - All searchable data embedded in data-search attributes Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe --- templates/user_loans.html | 182 +++++++++++++++++++++++++++++++------- 1 file changed, 150 insertions(+), 32 deletions(-) diff --git a/templates/user_loans.html b/templates/user_loans.html index 8c10045..07fac86 100644 --- a/templates/user_loans.html +++ b/templates/user_loans.html @@ -7,45 +7,98 @@ This page demonstrates the many-to-many relationship between users and tablets via the loans table.

-
+ +
+ + +
+ +
{% for user_data in users_with_loans %} {% set user = user_data.user %} {% set loans = user_data.loans %} + {% set active_loans = loans|selectattr('status', 'equalto', 'active')|list %} + {% set returned_loans = loans|selectattr('status', 'equalto', 'returned')|list %} -
+

{{ user.name }} ({{ user.identification }})

- {{ loans|length }} tablet{{ 's' if loans|length != 1 else '' }} loaned + + {{ active_loans|length }} active, {{ returned_loans|length }} past +
- {% if loans %} - - - - - - - - - - - - {% for loan in loans %} - - - - - - + {% if active_loans %} +
+

Current Loans

+
TabletSerial NumberLoan DateReturn DateStatus
{{ loan.brand }} {{ loan.model }}{{ loan.serial_number }}{{ loan.loan_date }}{{ loan.return_date or '-' }} - - {{ loan.status }} - -
+ + + + + + - {% endfor %} - -
TabletSerial NumberLoan DateStatus
- {% else %} + + + {% for loan in active_loans %} + + {{ loan.brand }} {{ loan.model }} + {{ loan.serial_number }} + {{ loan.loan_date }} + + + {{ loan.status }} + + + + {% endfor %} + + +
+ {% endif %} + + {% if returned_loans %} +
+

+ +

+ +
+ {% endif %} + + {% if not active_loans and not returned_loans %}

No loans recorded for this user.

{% endif %}
@@ -56,6 +109,32 @@ {% endif %}
+ +