Attempt to fix person link highlight

This commit is contained in:
Peter Stockings
2022-12-16 21:20:18 +11:00
parent dac5e99f05
commit 50c32d20a4
3 changed files with 12 additions and 6 deletions

10
app.py
View File

@@ -8,6 +8,7 @@ from db import DataBase
from utils import get_people_and_exercise_rep_maxes, convert_str_to_date, get_earliest_and_latest_workout_date, filter_workout_topsets, get_exercise_ids_from_workouts, first_and_last_visible_days_in_month
from flask_htmx import HTMX
import minify_html
from urllib.parse import urlparse
app = Flask(__name__)
app.config.from_pyfile('config.py')
@@ -75,7 +76,7 @@ def get_person(person_id):
return render_template('partials/page/person.html',
person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date), 200, {"HX-Trigger": "updatedPeople"}
return render_template('person.html', person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date)
return render_template('person.html', person=person, selected_exercise_ids=active_exercise_ids, max_date=max_date, min_date=min_date), 200, {"HX-Trigger": "updatedPeople"}
@ app.route("/person/<int:person_id>/calendar")
@@ -114,8 +115,8 @@ def get_calendar(person_id):
if htmx:
return render_template('partials/page/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)
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), 200, {"HX-Trigger": "updatedPeople"}
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), 200, {"HX-Trigger": "updatedPeople"}
@ app.route("/person/<int:person_id>/workout/<int:workout_id>/modal", methods=['GET'])
@@ -290,6 +291,9 @@ def settings():
def my_utility_processor():
def is_selected_page(url):
if htmx:
parsed_url = urlparse(htmx.current_url)
return 'bg-gray-200' if url == parsed_url.path else ''
if url == request.path:
return 'bg-gray-200'
return ''

View File

@@ -155,5 +155,6 @@
<svg viewBox="0 0 20 20" enable-background="new 0 0 20 20" class="w-6 h-6 inline-block">
<path fill="#FFFFFF" d="M16,10c0,0.553-0.048,1-0.601,1H11v4.399C11,15.951,10.553,16,10,16c-0.553,0-1-0.049-1-0.601V11H4.601
C4.049,11,4,10.553,4,10c0-0.553,0.049-1,0.601-1H9V4.601C9,4.048,9.447,4,10,4c0.553,0,1,0.048,1,0.601V9h4.399
C15.952,9,16,9.447,16,10z" />
C15.952,9,16,9.447,16,10z">
</svg>
</button>

View File

@@ -1,7 +1,8 @@
{% for p in people %}
<li>
<a hx-get="{{ url_for('get_calendar' ,person_id=p['PersonId']) }}" hx-push-url="true" hx-target="#container" class="text-base text-gray-900 font-normal rounded-lg hover:bg-gray-100 flex items-center p-2 group cursor-pointer {% if
p['IsActive']==1 %} bg-gray-200 {% endif %}">
<a hx-get="{{ url_for('get_calendar' ,person_id=p['PersonId']) }}" hx-push-url="true" hx-target="#container"
class="text-base text-gray-900 font-normal rounded-lg hover:bg-gray-100 flex items-center p-2 group cursor-pointer {% if
p['IsActive']==1 %} bg-gray-200 {% endif %} {{ is_selected_page(url_for('get_calendar' ,person_id=p['PersonId'])) }}">
<svg class="w-6 h-6 text-gray-500 flex-shrink-0 group-hover:text-gray-900 transition duration-75"
fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd">