Files
workout/templates/partials/new_set_form.html
T

91 lines
4.7 KiB
HTML

<div id="new-set-form-container-{{ workout_id }}" class="w-full">
<form class="w-full" id="new-set-workout-{{ workout_id }}"
hx-post="{{ url_for('workout.create_topset', person_id=person_id, workout_id=workout_id) }}" hx-swap="beforeend"
hx-target="#new-workout" _="on htmx:afterOnLoad
if detail.xhr.status == 200
set #validation-error-{{ workout_id }}.innerText to ''
add .hidden to #validation-error-{{ workout_id }}
else
set #validation-error-{{ workout_id }}.innerText to detail.xhr.responseText
remove .hidden from #validation-error-{{ workout_id }}
end
on topsetAdded
render #notification-template with (message: 'Topset added') then append it to #notifications-container
then call _hyperscript.processNode(#notifications-container)
then reset() me
then trigger clearNewSetInputs">
<div id="validation-error-{{ workout_id }}"
class="hidden text-red-500 text-xs italic mb-4 p-2 bg-red-50 border border-red-200 rounded"></div>
<div class="workout-set-fields">
<div class="workout-set-field">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="exercise-search">
Exercise
</label>
{{ render_partial('partials/exercise/exercise_select.html', person_id=person_id,
exercise_id=exercise_id, exercise_name=exercise_name) }}
</div>
<div class="workout-set-field">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-city">
Reps
</label>
<input
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="grid-city" type="number" name="repetitions" {% if repetitions %} placeholder="{{ repetitions }}"
_="on clearNewSetInputs set my.placeholder to ''" {% endif %}>
</div>
<div class="workout-set-field">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2" for="grid-zip">
Weight (kg)
</label>
<input
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="grid-zip" type="number" name="weight" step="any" {% if weight %} placeholder="{{ weight }}"
_="on clearNewSetInputs set my.placeholder to ''" {% endif %}>
</div>
<div class="workout-set-submit">
<button
class="workout-add-button"
type="submit">
<svg xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 24 24" class="w-5 h-5">
<path
d="M12 4a1 1 0 011 1v6h6a1 1 0 110 2h-6v6a1 1 0 11-2 0v-6H5a1 1 0 110-2h6V5a1 1 0 011-1z" />
</svg>
<span>Add set</span>
</button>
</div>
</div>
</form>
<div hx-trigger="exerciseSelected from:body"
hx-get="{{ url_for('workout.get_most_recent_topset_for_exercise', person_id=person_id, workout_id=workout_id) }}"
hx-target="#new-set-form-container-{{ workout_id }}" hx-swap="outerHTML" hx-include="[name='exercise_id']">
</div>
{% if exercise_id %}
<details class="workout-previous-details">
<summary>
<span class="workout-previous-label">Previous performance</span>
{% if repetitions %}<span class="workout-previous-value">{{ repetitions }} &times; {{ weight }} kg</span>{% endif %}
{% if stalled_sessions|default(0) > 0 %}
<span class="workout-stall-badge" title="Consecutive repeats of the same weight and reps">Stalled {{ stalled_sessions }} {{ 'time' if stalled_sessions == 1 else 'times' }}</span>
{% endif %}
</summary>
<div class="w-full">
<div class="hidden"
hx-get="{{ url_for('get_exercise_progress_for_user', person_id=person_id, exercise_id=exercise_id) }}"
hx-trigger="toggle once from:closest details" hx-target="this" hx-swap="outerHTML">
</div>
</div>
</details>
{% endif %}
</div>