Create blueprint for exercises
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
{% if is_edit|default(false, true) == false %}
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-get="{{ url_for('get_exercise_edit_form', exercise_id=exercise_id) }}">
|
||||
hx-get="{{ url_for('exercises.get_exercise_edit_form', exercise_id=exercise_id) }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round"
|
||||
@@ -50,7 +50,7 @@
|
||||
</button>
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-delete="{{ url_for('delete_exercise', exercise_id=exercise_id) }}"
|
||||
hx-delete="{{ url_for('exercises.delete_exercise', exercise_id=exercise_id) }}"
|
||||
hx-confirm="Are you sure you wish to delete {{ name }} from exercises?">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
@@ -63,7 +63,7 @@
|
||||
{% else %}
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-put="{{ url_for('update_exercise', exercise_id=exercise_id) }}" hx-include="closest tr">
|
||||
hx-put="{{ url_for('exercises.update_exercise', exercise_id=exercise_id) }}" hx-include="closest tr">
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
@@ -74,7 +74,7 @@
|
||||
|
||||
<button
|
||||
class="inline-flex justify-center p-2 text-blue-600 rounded-full cursor-pointer hover:bg-blue-100 dark:text-blue-500 dark:hover:bg-gray-600"
|
||||
hx-get="{{ url_for('get_exercise', exercise_id=exercise_id) }}">
|
||||
hx-get="{{ url_for('exercises.get_exercise', exercise_id=exercise_id) }}">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
|
||||
stroke="currentColor" class="w-5 h-5">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
class="w-full bg-gray-200 text-gray-700 border border-gray-200 rounded py-2 px-4 leading-tight focus:outline-none focus:bg-white focus:border-gray-500"
|
||||
_="on click from me call event.stopPropagation()">
|
||||
<!-- Save Icon -->
|
||||
<button hx-post="{{ url_for('edit_exercise_name', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
<button
|
||||
hx-post="{{ url_for('exercises.edit_exercise_name', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
hx-target="closest li" hx-swap="outerHTML" hx-include="closest li"
|
||||
class="text-gray-500 hover:text-gray-700 ml-2" _="on click from me call event.stopPropagation()">
|
||||
<!-- Tick icon SVG -->
|
||||
@@ -14,7 +15,8 @@
|
||||
</svg>
|
||||
</button>
|
||||
<!-- Delete Icon -->
|
||||
<button hx-delete="{{ url_for('delete_exercise', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
<button
|
||||
hx-delete="{{ url_for('exercises.delete_exercise', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
hx-target="closest li" hx-swap="outerHTML" class="text-red-500 hover:text-red-700 ml-2"
|
||||
hx-confirm="Are you sure you wish to delete {{ exercise.name }} from exercises?"
|
||||
_="on click from me call event.stopPropagation()">
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
<div class="py-2 px-4 text-gray-500 flex items-center justify-between border border-gray-200">
|
||||
<span>No results found</span>
|
||||
<!-- Add Exercise Button -->
|
||||
<button hx-post="{{ url_for('add_exercise', person_id=person_id) }}" hx-target="closest div" hx-swap="outerHTML"
|
||||
hx-include="[name='query']" class="text-blue-500 hover:text-blue-700 font-semibold"
|
||||
<button hx-post="{{ url_for('exercises.add_exercise', person_id=person_id) }}" 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>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<!-- Exercise Name -->
|
||||
<span>{{ exercise.name }}</span>
|
||||
<!-- Edit Icon -->
|
||||
<a hx-get="{{ url_for('edit_exercise_name', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
<a hx-get="{{ url_for('exercises.edit_exercise_name', exercise_id=exercise.exercise_id, person_id=person_id) }}"
|
||||
hx-target="closest li" hx-swap="outerHTML" class="text-gray-500 hover:text-gray-700"
|
||||
_="on click from me call event.stopPropagation()">
|
||||
<!-- Edit icon SVG -->
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<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="exercise-search" type="search" name="query" placeholder="Search exercises..."
|
||||
hx-get="{{ url_for('get_exercises', person_id=person_id) }}" hx-target="#exercise-results"
|
||||
hx-get="{{ url_for('exercises.get_exercises', person_id=person_id) }}" hx-target="#exercise-results"
|
||||
hx-trigger="keyup changed delay:500ms" hx-swap="innerHTML" autocomplete="off" {% if exercise_name %}
|
||||
value="{{ exercise_name }}" {% endif %} _="
|
||||
on input
|
||||
|
||||
@@ -213,7 +213,8 @@
|
||||
<div class="mt-10">
|
||||
<h4 class="text-lg font-semibold text-gray-900 mb-4">Add New Exercise</h4>
|
||||
<form class="bg-gray-50 p-6 rounded-lg border border-gray-100"
|
||||
hx-post="{{ url_for('create_exercise') }}" hx-swap="beforeend" hx-target="#new-exercise" _="on htmx:afterRequest
|
||||
hx-post="{{ url_for('exercises.create_exercise') }}" hx-swap="beforeend" hx-target="#new-exercise"
|
||||
_="on htmx:afterRequest
|
||||
render #notification-template with (message: 'Exercise added') then append it to #notifications-container
|
||||
then call _hyperscript.processNode(#notifications-container)
|
||||
then reset() me">
|
||||
|
||||
Reference in New Issue
Block a user