Files
workout/templates/partials/workout_modal.html

249 lines
16 KiB
HTML

<div id='modal' _='on closeModal
add .closing
then wait for animationend
then remove me
then toggle .hide-scrollbar on document.body
then send refreshView to #refreshViewElement'>
<div class='modal-underlay' _='on click trigger closeModal'></div>
<div class='modal-content m-4 sm:mt-24 max-h-[95%]' _='init toggle .hide-scrollbar on document.body'>
<div class="relative w-full h-full max-w-2xl md:h-auto overflow-auto">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow dark:bg-gray-700">
<!-- Modal header -->
<div class="flex items-start justify-between p-4 border-b rounded-t dark:border-gray-600">
<div class="flex flex-col w-full">
<div class="flex items-center justify-between">
<div class="w-full">
<h3 class="text-xl font-bold text-gray-900">{{ workout['PersonName'] }}</h3>
<div class="flex">
<span
class="text-xs font-semibold inline-block py-1 px-2 uppercase rounded text-pink-600 bg-pink-200 uppercase last:mr-0 mr-1 max-h-fit ">Push
</span>
<span
class="text-xs font-semibold inline-block py-1 px-2 uppercase rounded text-pink-600 bg-pink-200 uppercase last:mr-0 mr-1 max-h-fit ">Accessories
</span>
<span id="tag-form-show-w-{{ workout['WorkoutId'] }}" class="" _="on click
toggle .hidden on #tag-form-w-{{ workout['WorkoutId'] }}
then toggle .hidden on #tag-form-hide-w-{{ workout['WorkoutId'] }}
then toggle .hidden on me">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="w-6 h-6"
data-darkreader-inline-stroke=""
style="--darkreader-inline-stroke: currentColor;">
<path stroke-linecap="round" stroke-linejoin="round"
d="M12 4.5v15m7.5-7.5h-15"></path>
</svg>
</span>
<span id="tag-form-hide-w-{{ workout['WorkoutId'] }}" _="on click
toggle .hidden on #tag-form-w-{{ workout['WorkoutId'] }}
then toggle .hidden on #tag-form-show-w-{{ workout['WorkoutId'] }}
then toggle .hidden on me" class="hidden">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M19.5 12h-15" />
</svg>
</span>
</div>
<div id="tag-form-w-{{workout['WorkoutId']}}" class="hidden pt-2 pb-3">
<span class="text-base font-normal text-gray-500">Add tag to workout</span>
<div class="flex pt-2">
<div class="w-full md:w-1/2 px-3 mb-6 md:mb-0">
<label
class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="grid-state">
Tag
</label>
<div class="relative">
<div class="w-full">
<select id="workout-tag-select-{{ workout['WorkoutId'] }}"
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">
{% for e in workout['Exercises'] %}
<option value="{{ e['ExerciseId'] }}">{{
e['Name']
}}</option>
{% endfor %}
</select>
</div>
<script>
te.Select.getOrCreateInstance(document.querySelector("#workout-tag-select-{{ workout['WorkoutId'] }}"));
</script>
</div>
</div>
<div class="w-full md:w-1/2 px-3 mb-6 md:mb-0">
<label
class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2">
New tag name
</label>
<div class="flex">
<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"
type="text" name="repetitions">
<button type="submit"
class="p-2.5 ml-2 text-sm font-medium text-white bg-blue-700 rounded-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800">
<svg xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
class="w-6 h-6" data-darkreader-inline-stroke=""
style="--darkreader-inline-stroke: currentColor;">
<path stroke-linecap="round" stroke-linejoin="round"
d="M12 4.5v15m7.5-7.5h-15"></path>
</svg>
<span class="sr-only">Search</span>
</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2">
{{ render_partial('partials/start_date.html', person_id=workout['PersonId'],
workout_id=workout['WorkoutId'],
start_date=workout['StartDate']) }}
{{ render_partial('partials/workout_note.html', person_id=workout['PersonId'],
workout_id=workout['WorkoutId'],
note=workout['Note']) }}
</div>
</div>
<button type="button"
class="absolute right-0 text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white"
data-modal-toggle="defaultModal" _="on click trigger closeModal">
<svg aria-hidden="true" class="w-5 h-5" fill="currentColor" viewBox="0 0 20 20"
xmlns="http://www.w3.org/2000/svg" data-darkreader-inline-fill=""
style="--darkreader-inline-fill:currentColor;">
<path fill-rule="evenodd"
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
clip-rule="evenodd"></path>
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
</div>
<!-- Modal body -->
<div class="p-6 space-y-6">
<table class="items-center w-full bg-transparent border-collapse table-fixed">
<thead>
<tr>
<th
class="px-4 bg-gray-50 text-gray-700 align-middle py-3 text-xs font-semibold text-left uppercase border-l-0 border-r-0 whitespace-nowrap">
Exercise</th>
<th
class="px-4 bg-gray-50 text-gray-700 align-middle py-3 text-xs font-semibold text-left uppercase border-l-0 border-r-0 whitespace-nowrap">
Top Set</th>
<th
class="bg-gray-50 text-gray-700 align-middle py-3 text-xs font-semibold text-left uppercase border-l-0 border-r-0 whitespace-nowrap w-9 sm:w-20">
</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-100" id="new-workout" hx-target="closest tr"
hx-swap="outerHTML swap:0.5s">
{% for t in workout['TopSets'] %}
{{ render_partial('partials/topset.html', person_id=workout['PersonId'],
workout_id=workout['WorkoutId'],
topset_id=t['TopSetId'], exercise_name=t['ExerciseName'], repetitions=t['Repetitions'],
weight=t['Weight']) }}
{% endfor %}
</tbody>
</table>
{% if workout['TopSets']|length == 0 %}
<div class="bg-purple-100 rounded-lg py-5 px-6 mb-4 text-base text-purple-700 mb-3" role="alert"
id="no-workouts">
No topsets found.
</div>
{% endif %}
</div>
<!-- Modal footer -->
<div class="flex items-center p-6 space-x-2 border-t border-gray-200 rounded-b dark:border-gray-600">
<form class="w-full"
hx-post="{{ url_for('create_topset', person_id=workout['PersonId'], workout_id=workout['WorkoutId']) }}"
hx-swap="beforeend" hx-target="#new-workout" _="on htmx:afterOnLoad if #no-workouts add .hidden to #no-workouts end
on htmx:afterRequest
render #notification-template with (message: 'Topset added') then append it to #notifications-container
then call _hyperscript.processNode(#notifications-container)
then reset() me">
<div class="flex flex-wrap -mx-3 mb-2">
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="grid-state">
Exercise
</label>
<div class="relative">
<div class="w-full">
<select id="workout-exercise-select-{{ workout['WorkoutId'] }}" 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">
{% for e in workout['Exercises'] %}
<option value="{{ e['ExerciseId'] }}">{{
e['Name']
}}</option>
{% endfor %}
</select>
</div>
<script>
te.Select.getOrCreateInstance(document.querySelector("#workout-exercise-select-{{ workout['WorkoutId'] }}"));
</script>
</div>
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<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">
</div>
<div class="w-full md:w-1/3 px-3 mb-6 md:mb-0">
<label class="block uppercase tracking-wide text-gray-700 text-xs font-bold mb-2"
for="grid-zip">
Weight
</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">
</div>
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4 pt-2 px-0 sm:px-2">
<button
class="py-2 px-3 mb-3 text-sm font-medium text-center text-gray-900 bg-cyan-600 hover:bg-cyan-700 rounded-lg border border-gray-300 hover:scale-[1.02] transition-transform"
type="submit">
Add top set
</button>
<button hx-confirm="Are you sure you wish to delete this workout?"
hx-delete="{{ url_for('delete_workout', person_id=workout['PersonId'], workout_id=workout['WorkoutId']) }}"
_='on click trigger closeModal'
class="py-2 px-3 mb-3 text-sm font-medium text-center text-gray-900 bg-white rounded-lg border border-gray-300 hover:bg-gray-100 hover:scale-[1.02] transition-transform">Delete
workout</button>
</div>
</form>
</div>
</div>
</div>
</div>
</div>