Fix issue where when selecting a new exercise that doesnt have a previously recorded set resets on selection

This commit is contained in:
Peter Stockings
2023-09-18 17:44:53 +10:00
parent a09504d2e0
commit e2104d05fe
2 changed files with 3 additions and 2 deletions

2
app.py
View File

@@ -418,7 +418,7 @@ def get_most_recent_topset_for_exercise(person_id, workout_id):
topset = db.get_most_recent_topset_for_exercise(person_id, exercise_id) topset = db.get_most_recent_topset_for_exercise(person_id, exercise_id)
if not topset: if not topset:
return render_template('partials/new_set_form.html', person_id=person_id, workout_id=workout_id, exercises=exercises, has_value=False) return render_template('partials/new_set_form.html', person_id=person_id, workout_id=workout_id, exercises=exercises, exercise_id=exercise_id, has_value=False)
(repetitions, weight) = topset (repetitions, weight) = topset
return render_template('partials/new_set_form.html', person_id=person_id, workout_id=workout_id, exercises=exercises, has_value=True, exercise_id=exercise_id, repetitions=repetitions, weight=weight) return render_template('partials/new_set_form.html', person_id=person_id, workout_id=workout_id, exercises=exercises, has_value=True, exercise_id=exercise_id, repetitions=repetitions, weight=weight)

View File

@@ -18,7 +18,8 @@
<select data-te-select-init data-te-select-filter="true" data-te-select-size="lg" name="exercise_id" <select data-te-select-init data-te-select-filter="true" data-te-select-size="lg" name="exercise_id"
class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500" class="block appearance-none w-full bg-gray-200 border border-gray-200 text-gray-700 py-3 px-4 pr-8 rounded leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
hx-get="{{ url_for('get_most_recent_topset_for_exercise', person_id=person_id, workout_id=workout_id) }}" hx-get="{{ url_for('get_most_recent_topset_for_exercise', person_id=person_id, workout_id=workout_id) }}"
hx-target="#new-set-workout-{{ workout_id }}" hx-swap="outerHTML" {% if has_value==True %} _="init js(me) hx-target="#new-set-workout-{{ workout_id }}" hx-swap="outerHTML" {% if has_value==True or
exercise_id %} _="init js(me)
te.Select.getOrCreateInstance(me).setValue('{{ exercise_id | safe }}') te.Select.getOrCreateInstance(me).setValue('{{ exercise_id | safe }}')
end" {% else %} _="init js(me) end" {% else %} _="init js(me)
te.Select.getOrCreateInstance(me) te.Select.getOrCreateInstance(me)