Add button to topsets to show history as a table

This commit is contained in:
Peter Stockings
2026-02-26 23:26:49 +11:00
parent 67009c9603
commit 895b813a35
4 changed files with 127 additions and 19 deletions

View File

@@ -0,0 +1,56 @@
{% if offset == 0 %}
<div
class="w-full bg-gray-50 dark:bg-gray-800 p-4 border-t border-gray-200 dark:border-gray-700 shadow-inner overflow-x-auto">
<h4 class="text-sm font-semibold text-gray-900 dark:text-white mb-2">History</h4>
<table class="w-full text-left text-sm text-gray-500 dark:text-gray-400">
<thead class="text-xs text-gray-700 uppercase bg-gray-100 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" class="px-3 py-2">Date</th>
<th scope="col" class="px-3 py-2">Set & Achievements</th>
</tr>
</thead>
<tbody>
{% endif %}
{% for topset in topsets %}
<tr class="border-b dark:border-gray-700 bg-white dark:bg-gray-800">
<td class="px-3 py-2 text-sm text-gray-900 dark:text-white whitespace-nowrap">
{{ topset.start_date | strftime }}
</td>
<td class="px-3 py-2 text-sm text-gray-900 dark:text-white">
<div class="flex flex-wrap items-center gap-x-2 gap-y-1">
<span class="whitespace-nowrap">{{ topset.repetitions }} x {{ topset.weight }}kg</span>
<div hx-get="{{ url_for('workout.get_topset_achievements', person_id=person_id, workout_id=topset.workout_id, topset_id=topset.topset_id) }}"
hx-trigger="load" hx-target="this" hx-swap="innerHTML"
class="flex flex-wrap items-center gap-1">
<!-- Badges load here -->
</div>
</div>
</td>
</tr>
{% endfor %}
{% if topsets|length == limit %}
<tr id="history-load-more-{{ source_topset_id }}-{{ offset + limit }}">
<td colspan="2" class="px-3 py-3 text-center">
<button
class="text-sm text-blue-600 hover:underline dark:text-blue-500 font-medium px-4 py-2 border border-blue-600 rounded"
hx-get="{{ url_for('workout.get_exercise_history', person_id=person_id, exercise_id=exercise_id, limit=limit, offset=offset + limit, source_topset_id=source_topset_id) }}"
hx-target="#history-load-more-{{ source_topset_id }}-{{ offset + limit }}" hx-swap="outerHTML">
Load More
</button>
</td>
</tr>
{% elif topsets|length == 0 and offset == 0 %}
<tr>
<td colspan="2" class="px-3 py-4 text-center text-gray-500 dark:text-gray-400">
No history found.
</td>
</tr>
{% endif %}
{% if offset == 0 %}
</tbody>
</table>
</div>
{% endif %}