Add dropdown exercise selection to Doris Barbell logs
This commit is contained in:
@@ -133,6 +133,7 @@ def routine_log_sheet(request: Request, routine_id: str):
|
||||
'title': f"Log {routine['name']}",
|
||||
'routine': routine,
|
||||
'routine_sheet': _build_routine_log_sheet(routine),
|
||||
'exercise_options': _exercise_options_for_routine(request, routine),
|
||||
'routine_action_label': _routine_action_label(routine['name']),
|
||||
'default_performed_at': _default_performed_at_value(),
|
||||
},
|
||||
@@ -285,6 +286,24 @@ def _build_routine_log_sheet(routine: dict) -> list[dict]:
|
||||
return sheet
|
||||
|
||||
|
||||
def _exercise_options_for_routine(request: Request, routine: dict) -> list[str]:
|
||||
routine_names = [exercise['exercise_name'] for exercise in routine.get('exercises', []) if exercise.get('exercise_name')]
|
||||
template_names = [
|
||||
template['name']
|
||||
for template in request.app.state.store.list_exercise_templates()
|
||||
if template.get('name')
|
||||
]
|
||||
ordered = []
|
||||
seen = set()
|
||||
for name in [*routine_names, *template_names]:
|
||||
normalized = name.strip().lower()
|
||||
if normalized in seen:
|
||||
continue
|
||||
ordered.append(name)
|
||||
seen.add(normalized)
|
||||
return ordered
|
||||
|
||||
|
||||
def _default_reps_value(target_reps: str | None) -> str:
|
||||
if target_reps is None:
|
||||
return ''
|
||||
|
||||
@@ -52,13 +52,18 @@
|
||||
|
||||
{% for exercise in routine_sheet %}
|
||||
<section class="evidence-slab">
|
||||
<input type="hidden" name="exercise_{{ exercise.exercise_index }}_name" value="{{ exercise.exercise_name }}">
|
||||
<input type="hidden" name="exercise_{{ exercise.exercise_index }}_set_count" value="{{ exercise.target_sets }}">
|
||||
<div class="case-legend">
|
||||
<span class="section-label">Exercise {{ loop.index }}</span>
|
||||
<span class="pill">{{ exercise.target_sets }} sets</span>
|
||||
</div>
|
||||
<h3>{{ exercise.exercise_name }}</h3>
|
||||
<label>Exercise
|
||||
<select name="exercise_{{ exercise.exercise_index }}_name">
|
||||
{% for option_name in exercise_options %}
|
||||
<option value="{{ option_name }}" {% if option_name == exercise.exercise_name %}selected{% endif %}>{{ option_name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<p class="muted">Target reps: {{ exercise.target_reps or 'enter manually' }}</p>
|
||||
<div class="grid cols-2 compact-grid">
|
||||
{% for set in exercise.sets %}
|
||||
|
||||
Reference in New Issue
Block a user