diff --git a/app.py b/app.py index 3d9669f..81b2d1b 100644 --- a/app.py +++ b/app.py @@ -399,8 +399,8 @@ def get_most_recent_topset_for_exercise(person_id, workout_id): if not topset: 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 - 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) + (repetitions, weight, exercise_name) = topset + return render_template('partials/new_set_form.html', person_id=person_id, workout_id=workout_id, has_value=True, exercise_id=exercise_id, exercise_name=exercise_name, repetitions=repetitions, weight=weight) def calculate_relative_positions(start_dates): diff --git a/db.py b/db.py index ad52bf2..e69e630 100644 --- a/db.py +++ b/db.py @@ -448,9 +448,11 @@ class DataBase(): topset = self.execute(""" SELECT t.repetitions, - t.weight + t.weight, + e.name as "exercise_name" FROM topset t JOIN workout w ON t.workout_id = w.workout_id + JOIN exercise e ON t.exercise_id = e.exercise_id WHERE w.person_id = %s AND t.exercise_id = %s ORDER BY @@ -461,7 +463,7 @@ class DataBase(): if not topset: return None else: - return (topset['repetitions'], topset['weight']) + return (topset['repetitions'], topset['weight'], topset['exercise_name']) def get_all_exercises(self): exercises = self.execute( diff --git a/templates/partials/exercise/exercise_list_item.html b/templates/partials/exercise/exercise_list_item.html index 559f37c..cf76034 100644 --- a/templates/partials/exercise/exercise_list_item.html +++ b/templates/partials/exercise/exercise_list_item.html @@ -1,8 +1,7 @@ -
  • + on click call htmx.trigger(document.body, 'exerciseSelected')"> {{ exercise.name }} diff --git a/templates/partials/exercise/exercise_select.html b/templates/partials/exercise/exercise_select.html index 0b82e27..72b4c4d 100644 --- a/templates/partials/exercise/exercise_select.html +++ b/templates/partials/exercise/exercise_select.html @@ -3,13 +3,15 @@ class="appearance-none block w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-3 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500" id="exercise-search" type="text" name="query" placeholder="Search exercises..." hx-get="{{ url_for('get_exercises', person_id=person_id) }}" hx-target="#exercise-results" - hx-trigger="keyup changed delay:500ms" hx-swap="innerHTML" autocomplete="off"> + hx-trigger="keyup changed delay:500ms" hx-swap="innerHTML" autocomplete="off" {% if has_value==True %} + value="{{ exercise_name }}" {% endif %}>
    - + \ No newline at end of file diff --git a/templates/partials/new_set_form.html b/templates/partials/new_set_form.html index 1ae0a62..913fcac 100644 --- a/templates/partials/new_set_form.html +++ b/templates/partials/new_set_form.html @@ -7,12 +7,13 @@ then reset() me then trigger clearNewSetInputs"> -
    +
    - {{ render_partial('partials/exercise/exercise_select.html', person_id=person_id) }} + {{ render_partial('partials/exercise/exercise_select.html', person_id=person_id, has_value=has_value, + exercise_id=exercise_id, exercise_name=exercise_name) }}
    @@ -50,9 +51,18 @@ +
    +
    + {% if has_value==True %} -