Refactorr topset into template partial
This commit is contained in:
@@ -1,36 +1,56 @@
|
||||
<tr class="text-gray-500">
|
||||
<th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">
|
||||
<tr>
|
||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
{{ exercise_name }}
|
||||
{% else %}
|
||||
<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 exercise in exercises %}
|
||||
<option value="{{ exercise['ExerciseId'] }}" {% if topset['ExerciseId']==exercise['ExerciseId'] %} selected
|
||||
{% endif %}>{{
|
||||
name="exercise_id">
|
||||
{% for exercise in exercises|default([], true) %}
|
||||
<option value="{{ exercise['ExerciseId'] }}" {% if exercise['ExerciseId']==exercise_id %} selected {% endif
|
||||
%}>{{
|
||||
exercise['Name']}}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</th>
|
||||
<td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
{{ repetitions }} x {{ weight }}kg
|
||||
{% else %}
|
||||
<div class="flex items-center">
|
||||
<input type="number"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full md:w-1/4"
|
||||
name="repetitions" value="{{ topset['Repetitions'] }}">
|
||||
name="repetitions" value="{{ repetitions }}">
|
||||
<p class="px-2">x</p>
|
||||
<input type="number"
|
||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full pl-10 p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500 w-full md:w-1/4"
|
||||
name="weight" value="{{ topset['Weight'] }}">
|
||||
name="weight" value="{{ weight }}">
|
||||
<p class="px-2">kg</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
|
||||
<a hx-put="{{ url_for('update_topset', person_id=topset['PersonId'], workout_id=topset['WorkoutId'], topset_id=topset['TopSetId']) }}"
|
||||
<td class="p-4 whitespace-nowrap text-sm font-semibold text-gray-900">
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
<a hx-get="{{ url_for('get_topset_edit_form',person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Edit
|
||||
</a>
|
||||
<a hx-delete="{{ url_for('delete_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Delete
|
||||
</a>
|
||||
{% else %}
|
||||
<a hx-put="{{ url_for('update_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
hx-include="[name='exercise_id'], [name='repetitions'], [name='weight']"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Update
|
||||
</a>
|
||||
<a hx-get="{{ url_for('get_topset', person_id=topset['PersonId'], workout_id=topset['WorkoutId'], topset_id=topset['TopSetId']) }}"
|
||||
<a hx-get="{{ url_for('get_topset', person_id=person_id, workout_id=workout_id, topset_id=topset_id) }}"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Cancel
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
@@ -52,23 +52,10 @@
|
||||
<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'] %}
|
||||
<tr class="text-gray-500">
|
||||
<th class="border-t-0 px-4 align-middle text-l font-normal whitespace-nowrap p-4 text-left">
|
||||
{{ t['ExerciseName'] }}</th>
|
||||
</th>
|
||||
<td class="border-t-0 px-4 align-middle text-l font-medium text-gray-900 whitespace-nowrap p-4">
|
||||
{{ t['Repetitions'] }} x {{ t['Weight'] }}kg</td>
|
||||
<td class="border-t-0 px-4 align-middle text-xs whitespace-nowrap p-4">
|
||||
<a hx-get="{{ url_for('get_topset_edit_form', person_id=workout['PersonId'], workout_id=workout['WorkoutId'], topset_id=t['TopSetId']) }}"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Edit
|
||||
</a>
|
||||
<a hx-delete="{{ url_for('delete_topset', person_id=workout['PersonId'], workout_id=workout['WorkoutId'], topset_id=t['TopSetId'])}}"
|
||||
class="text-sm font-medium text-cyan-600 hover:bg-gray-100 rounded-lg inline-flex items-center p-2 cursor-pointer">
|
||||
Delete
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{ 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>
|
||||
|
||||
Reference in New Issue
Block a user