Display workout in modal from calendar (styling not complete)
This commit is contained in:
7
app.py
7
app.py
@@ -102,6 +102,13 @@ def get_calendar(person_id):
|
|||||||
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date)
|
return render_template('calendar.html', person=person, selected_date=selected_date, selected_view=selected_view, next_date=next_date, previous_date=previous_date, start_date=start_date, end_date=end_date)
|
||||||
|
|
||||||
|
|
||||||
|
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/modal", methods=['GET'])
|
||||||
|
@ validate_workout
|
||||||
|
def get_workout_modal(person_id, workout_id):
|
||||||
|
workout = db.get_workout(person_id, workout_id)
|
||||||
|
return render_template('partials/workout_modal.html', workout=workout)
|
||||||
|
|
||||||
|
|
||||||
@ app.route("/person/<int:person_id>/workout", methods=['POST'])
|
@ app.route("/person/<int:person_id>/workout", methods=['POST'])
|
||||||
@ validate_person
|
@ validate_person
|
||||||
def create_workout(person_id):
|
def create_workout(person_id):
|
||||||
|
|||||||
@@ -1,4 +1,106 @@
|
|||||||
tr.htmx-swapping td {
|
tr.htmx-swapping td {
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
transition: opacity 0.5s ease-out;
|
transition: opacity 0.5s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal {
|
||||||
|
/* Underlay covers entire screen. */
|
||||||
|
position: fixed;
|
||||||
|
top: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
background-color: rgba(0,0,0,0.9);
|
||||||
|
z-index: 1000;
|
||||||
|
/* Flexbox centers the .modal-content vertically and horizontally */
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
/* Animate when opening */
|
||||||
|
animation-name: fadeIn;
|
||||||
|
animation-duration: 150ms;
|
||||||
|
animation-timing-function: ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal > .modal-underlay {
|
||||||
|
/* underlay takes up the entire viewport. This is only
|
||||||
|
required if you want to click to dismiss the popup */
|
||||||
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
top: 0px;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0px;
|
||||||
|
right: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal > .modal-content {
|
||||||
|
/* Position visible dialog near the top of the window */
|
||||||
|
margin-top: 5vh;
|
||||||
|
/* Sizing for visible dialog */
|
||||||
|
max-width: 80%;
|
||||||
|
max-height:90%;
|
||||||
|
/* Display properties for visible dialog*/
|
||||||
|
border: solid 1px #999;
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0px 0px 20px 0px rgba(0,0,0,0.3);
|
||||||
|
background-color: white;
|
||||||
|
padding: 20px;
|
||||||
|
/* Animate when opening */
|
||||||
|
animation-name: zoomIn;
|
||||||
|
animation-duration: 150ms;
|
||||||
|
animation-timing-function: ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal.closing {
|
||||||
|
/* Animate when closing */
|
||||||
|
animation-name: fadeOut;
|
||||||
|
animation-duration: 150ms;
|
||||||
|
animation-timing-function: ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
#modal.closing > .modal-content {
|
||||||
|
/* Aniate when closing */
|
||||||
|
animation-name: zoomOut;
|
||||||
|
animation-duration: 150ms;
|
||||||
|
animation-timing-function: ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeOut {
|
||||||
|
0% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes zoomIn {
|
||||||
|
0% {
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes zoomOut {
|
||||||
|
0% {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
100% {
|
||||||
|
transform: scale(0.9);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -87,8 +87,8 @@
|
|||||||
date) %}
|
date) %}
|
||||||
<div class="{% if date == datetime.today().date() %}rounded-md border-4 border-green-50{% endif %} border flex flex-col h-40 mx-auto mx-auto overflow-hidden w-full pt-2 pl-2 cursor-pointer {% if selected_date.month != date.month %}bg-gray-100{% endif %}"
|
<div class="{% if date == datetime.today().date() %}rounded-md border-4 border-green-50{% endif %} border flex flex-col h-40 mx-auto mx-auto overflow-hidden w-full pt-2 pl-2 cursor-pointer {% if selected_date.month != date.month %}bg-gray-100{% endif %}"
|
||||||
{% if workout %}
|
{% if workout %}
|
||||||
hx-get="{{ url_for('get_workout' ,person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}"
|
hx-get="{{ url_for('get_workout_modal', person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}"
|
||||||
hx-target="#container" hx-push-url="true" {% endif %}>
|
hx-target='body' hx-swap='beforeend' {% endif %}>
|
||||||
<div class="top h-5 w-full">
|
<div class="top h-5 w-full">
|
||||||
<span class="text-gray-500 font-semibold">{{ date.day }}</span>
|
<span class="text-gray-500 font-semibold">{{ date.day }}</span>
|
||||||
</div>
|
</div>
|
||||||
@@ -143,10 +143,10 @@
|
|||||||
'StartDate',
|
'StartDate',
|
||||||
day_date) %}
|
day_date) %}
|
||||||
{% set is_in_month = day_date.month == first_day_of_month.month%}
|
{% set is_in_month = day_date.month == first_day_of_month.month%}
|
||||||
<div class="{% if day_date == datetime.today().date() and is_in_month %}rounded-md border-4 border-green-50 border{% endif %} py-3 px-4 hover:bg-blue hover:text-white text-center cursor-pointer {% if workout and is_in_month %}bg-green-100{% endif %}"
|
<div class="{% if day_date == datetime.today().date() and is_in_month %}rounded-md border-4 border-green-50 border{% endif %} py-3 px-4 hover:bg-blue hover:text-white text-center cursor-pointer rounded-md {% if workout and is_in_month %}bg-green-100{% endif %}"
|
||||||
{% if workout %}
|
{% if workout %}
|
||||||
hx-get="{{ url_for('get_workout' ,person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}"
|
hx-get="{{ url_for('get_workout_modal', person_id=person['PersonId'], workout_id=workout['WorkoutId']) }}"
|
||||||
hx-target="#container" hx-push-url="true" {% endif %}>
|
hx-target='body' hx-swap='beforeend' {% endif %}>
|
||||||
{% if is_in_month %}
|
{% if is_in_month %}
|
||||||
{{ day_date.day }} {% endif %}</div>
|
{{ day_date.day }} {% endif %}</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
147
templates/partials/workout_modal.html
Normal file
147
templates/partials/workout_modal.html
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
<div id='modal' _='on closeModal
|
||||||
|
add .closing
|
||||||
|
then wait for animationend
|
||||||
|
then remove me
|
||||||
|
then toggle .hide-scrollbar on document.body'>
|
||||||
|
<div class='modal-underlay' _='on click trigger closeModal'></div>
|
||||||
|
<div class='modal-content' _='init toggle .hide-scrollbar on document.body'>
|
||||||
|
<div class="relative w-full h-full max-w-2xl md:h-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">
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<div>
|
||||||
|
<h3 class="text-xl font-bold text-gray-900">{{ workout['PersonName'] }}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="edit-start-date" hx-target="this" hx-swap="innerHTML swap:0.5s">
|
||||||
|
{{ render_partial('partials/start_date.html', person_id=workout['PersonId'],
|
||||||
|
workout_id=workout['WorkoutId'],
|
||||||
|
start_date=workout['StartDate']) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="button"
|
||||||
|
class="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>
|
||||||
|
<!-- Modal body -->
|
||||||
|
<div class="p-6 space-y-6">
|
||||||
|
<table class="items-center w-full bg-transparent border-collapse">
|
||||||
|
<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="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 min-w-140-px w-8">
|
||||||
|
</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 max-w-lg"
|
||||||
|
hx-post="{{ url_for('create_topset', person_id=workout['PersonId'], workout_id=workout['WorkoutId']) }}"
|
||||||
|
hx-swap="beforeend" hx-target="#new-workout"
|
||||||
|
_="on htmx:afterOnLoad add .hidden to #no-workouts">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<select
|
||||||
|
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"
|
||||||
|
id="grid-state" name="exercise_id">
|
||||||
|
{% for e in workout['Exercises'] %}
|
||||||
|
<option value="{{ e['ExerciseId'] }}">{{
|
||||||
|
e['Name']}}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
<div
|
||||||
|
class="pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700">
|
||||||
|
<svg class="fill-current h-4 w-4" xmlns="http://www.w3.org/2000/svg"
|
||||||
|
viewBox="0 0 20 20">
|
||||||
|
<path
|
||||||
|
d="M9.293 12.95l.707.707L15.657 8l-1.414-1.414L10 10.828 5.757 6.586 4.343 8z" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</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="flex justify-between">
|
||||||
|
<button
|
||||||
|
class="sm:inline-flex text-white bg-cyan-600 hover:bg-cyan-700 focus:ring-4 focus:ring-cyan-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center"
|
||||||
|
type="submit">
|
||||||
|
Add top set
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<button
|
||||||
|
hx-delete="{{ url_for('delete_workout', person_id=workout['PersonId'], workout_id=workout['WorkoutId']) }}"
|
||||||
|
hx-target="#container"
|
||||||
|
class="sm:inline-flex text-white bg-red-200 hover:bg-red-700 focus:ring-4 focus:ring-red-200 font-medium rounded-lg text-sm px-5 py-2.5 text-center items-center cursor-pointer">Delete
|
||||||
|
workout</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
Reference in New Issue
Block a user