Add ability to add/delete exercises from dropdown

This commit is contained in:
Peter Stockings
2024-11-04 16:46:22 +11:00
parent 7d43965289
commit 7d65f9b8e8
4 changed files with 42 additions and 3 deletions

View File

@@ -13,4 +13,15 @@
<path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
</svg>
</button>
<!-- Delete Icon -->
<button hx-delete="{{ url_for('delete_exercise', exercise_id=exercise.exercise_id) }}" hx-target="closest li"
hx-swap="outerHTML" class="text-red-500 hover:text-red-700 ml-2"
_="on click from me call event.stopPropagation()">
<!-- Trash icon SVG -->
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"
stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round"
d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M9 7h6m2 0a2 2 0 00-2-2H9a2 2 0 00-2 2h12z" />
</svg>
</button>
</li>

View File

@@ -5,5 +5,13 @@
{% endfor %}
</ul>
{% else %}
<div class="py-2 px-4 text-gray-500">No results found</div>
<div class="py-2 px-4 text-gray-500 flex items-center justify-between">
<span>No results found</span>
<!-- Add Exercise Button -->
<button hx-post="{{ url_for('add_exercise') }}" hx-target="closest div" hx-swap="outerHTML"
hx-include="[name='query']" class="text-blue-500 hover:text-blue-700 font-semibold"
_="on click from me call event.stopPropagation()">
Add Exercise
</button>
</div>
{% endif %}