From 50c32d20a464f32a5e79c0665a2a890487fda011 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Fri, 16 Dec 2022 21:20:18 +1100 Subject: [PATCH] Attempt to fix person link highlight --- app.py | 10 +++++++--- templates/partials/page/person.html | 3 ++- templates/partials/people_link.html | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app.py b/app.py index 7e92b9f..24a183e 100644 --- a/app.py +++ b/app.py @@ -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//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//workout//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 '' diff --git a/templates/partials/page/person.html b/templates/partials/page/person.html index 3a03c1a..b543787 100644 --- a/templates/partials/page/person.html +++ b/templates/partials/page/person.html @@ -155,5 +155,6 @@ + C15.952,9,16,9.447,16,10z"> + \ No newline at end of file diff --git a/templates/partials/people_link.html b/templates/partials/people_link.html index f199c33..7b7c0e1 100644 --- a/templates/partials/people_link.html +++ b/templates/partials/people_link.html @@ -1,7 +1,8 @@ {% for p in people %}
  • - +