Add per-exercise personal record tracking
Session tracking only ever stored a done boolean - no record of what weight or reps were actually performed, so there was no way to derive real progress data even though the dashboard implied "progress tracking" was a thing. Workout templates only hold a static planned value, not a history of performance. Adds actual_weight/actual_reps to workout_session_items, captured inline when checking off a set in a session (defaults to the workout's planned weight/reps, editable before confirming). The exercise detail page now shows the user's personal best (heaviest completed set, tie broken by reps) computed from their completed session history across all workouts containing that exercise. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
<form method="POST" action="{{ route('sessions.items.toggle', [$session, $item]) }}" class="session-toggle-form" data-item-id="{{ $item->id }}" data-initial-done="{{ $isDone ? '1' : '0' }}">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<input type="hidden" name="actual_weight" class="actual-weight-input" value="{{ old('actual_weight', $si->actual_weight ?? $item->weight) }}">
|
||||
<input type="hidden" name="actual_reps" class="actual-reps-input" value="{{ old('actual_reps', $si->actual_reps ?? $item->reps) }}">
|
||||
<button type="submit" class="h-6 w-6 rounded-md border flex items-center justify-center transition-colors duration-150"
|
||||
aria-pressed="{{ $isDone ? 'true' : 'false' }}"
|
||||
title="{{ $isDone ? __('app.sessions.mark_complete') : __('app.sessions.progress') }}">
|
||||
@@ -40,6 +42,17 @@
|
||||
</form>
|
||||
<div>
|
||||
<div class="exercise-title text-base font-semibold {{ $isDone ? 'line-through text-gray-500 dark:text-gray-400' : 'text-gray-900 dark:text-white' }}">{{ $item->exercise->display_name }}</div>
|
||||
<div class="mt-2 flex items-center gap-3 text-sm">
|
||||
<label class="flex items-center gap-1.5 text-gray-600 dark:text-gray-300">
|
||||
{{ __('app.sessions.weight_lifted') }}
|
||||
<input type="number" step="0.5" min="0" class="actual-weight-field w-20 rounded-lg border-gray-300 dark:border-gray-700 bg-white/80 dark:bg-gray-900 text-gray-900 dark:text-gray-100 px-2 py-1" value="{{ $si->actual_weight ?? $item->weight }}">
|
||||
kg
|
||||
</label>
|
||||
<label class="flex items-center gap-1.5 text-gray-600 dark:text-gray-300">
|
||||
{{ __('app.sessions.reps_done') }}
|
||||
<input type="number" min="0" class="actual-reps-field w-16 rounded-lg border-gray-300 dark:border-gray-700 bg-white/80 dark:bg-gray-900 text-gray-900 dark:text-gray-100 px-2 py-1" value="{{ $si->actual_reps ?? $item->reps }}">
|
||||
</label>
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-gray-600 dark:text-gray-300">
|
||||
@if($item->sets) {{ $item->sets }} {{ __('app.sessions.sets') }} @endif
|
||||
@if($item->reps) · {{ $item->reps }} {{ __('app.sessions.reps') }} @endif
|
||||
@@ -130,6 +143,17 @@
|
||||
const next = !wasDone;
|
||||
updateBtnState(btn, next);
|
||||
|
||||
// Sync the visible weight/reps fields (outside the form) into the hidden form inputs
|
||||
const row = btn.closest('li');
|
||||
if (row) {
|
||||
const weightField = row.querySelector('.actual-weight-field');
|
||||
const repsField = row.querySelector('.actual-reps-field');
|
||||
const weightInput = form.querySelector('.actual-weight-input');
|
||||
const repsInput = form.querySelector('.actual-reps-input');
|
||||
if (weightField && weightInput) weightInput.value = weightField.value;
|
||||
if (repsField && repsInput) repsInput.value = repsField.value;
|
||||
}
|
||||
|
||||
fetch(form.action, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user