diff --git a/src/plainui/jinja2/plainui/components/list_events.html b/src/plainui/jinja2/plainui/components/list_events.html index 054ef1f430aabc551e4a9d6960a78bd0a52d210e..6c09a54fa75a337c91ecb05cbca9dadfc2a8fdee 100644 --- a/src/plainui/jinja2/plainui/components/list_events.html +++ b/src/plainui/jinja2/plainui/components/list_events.html @@ -10,11 +10,30 @@ {% macro list(events, my_favorite_events, my_scheduled_events, assembly_slug=None, msg_none=_("No entries available.")) -%} {% if events %} <ul class="list-unstyled d-flex flex-column gap-3 mb-0"> + {# using a list here to be able to set a value in the nested block #} + {% set first_now_done = [] %} + {% for event in events %} - {{ list_el( event, - faved=true if event.id | safe in my_favorite_events, - scheduled=true if event.id | safe in my_scheduled_events, - first=loop.first ) }} + {% if event.schedule_end < now %} + {% set event_when = 'past' %} + {% elif event.schedule_start > now %} + {% set event_when = 'upcoming' %} + {% else %} + {% set event_when = 'now' %} + {% endif %} + + {{ list_el( + event, + faved=true if event.id | safe in my_favorite_events, + scheduled=true if event.id | safe in my_scheduled_events, + first=loop.first, + event_when=event_when, + first_now=true if event_when == 'now' and not first_now_done[0] + ) }} + + {% if when == 'now' and not first_now_done[0] %} + {% set ignore = first_now_done.append(True) %} + {% endif %} {% endfor %} </ul> {% else %} @@ -22,18 +41,14 @@ {% endif %} {%- endmacro %} -{% macro list_el(event, faved, scheduled, first) -%} +{% macro list_el(event, faved, scheduled, first, event_when, first_now) -%} {% set link = url('plainui:event', event_slug=event.slug ) %} {% set color="transparent" if event.kind == "official" else "transparent" %} - {% set is_past = event.schedule_end < now %} - {% set is_upcomping = event.schedule_start > now %} - {% set is_now = not is_past and not is_upcomping %} <li - class="hub-event rounded-3 px-3 py-2 - {% if is_past %}hub-event--past{% endif %} - {% if is_upcomping %}hub-event--upcoming{% endif %}" - > + class="hub-event rounded-3 px-3 py-2 hub-event--{{ event_when }}" + {% if first_now %}id="now"{% endif %} + > <div class="hub-event__day"> {{ _(event.schedule_start | weekday_abbrev) }} </div> @@ -47,7 +62,7 @@ {{ event.name }} </div> </a> - {% if is_now %} + {% if event_when == 'now' %} <div class="hub-event__now"> {{ _('NOW') }} </div> diff --git a/src/plainui/jinja2/plainui/fahrplan.html b/src/plainui/jinja2/plainui/fahrplan.html index 9b0ca95404917c3503957a8b1aca6408e4d9b1bd..a22f778b1a4c2a440e3f604f6b4a5af24e215672 100644 --- a/src/plainui/jinja2/plainui/fahrplan.html +++ b/src/plainui/jinja2/plainui/fahrplan.html @@ -29,7 +29,7 @@ <a href="#" class="btn m-2">{{ _("QR-Code") }}</a> </div> #} - <form method="GET" class="p-3 mb-2 hub-fahrplan__filter-block bg-black"> + <form method="GET" action="#now" class="p-3 mb-2 hub-fahrplan__filter-block bg-black"> <input type="hidden" name="mode" value="{{mode}}"> {% if show_day_filters %}<input type="hidden" name="show_day_filters" value="y">{% endif %} {% if show_assembly_filters %}<input type="hidden" name="show_assembly_filters" value="y">{% endif %}