messy filter support

This commit is contained in:
Nicholas Orlowsky 2026-02-16 18:49:47 -05:00
parent 6773e6ae30
commit b7ec6a292f
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B
15 changed files with 445 additions and 103 deletions

View file

@ -10,19 +10,91 @@
{% for route in routes %}
<div style="margin-right: 5px">
{% call scope::route_symbol(route) %}
{% endcall %}
</div>
{% endfor %}
</div>
{#{% if let libseptastic::stop::StopType::MultiPlatform(platforms) = stop.platforms %}
<div>
<p>Platforms at this station:</p>
{% for platform in platforms %}
<p><a href="/stop/{{ platform.id }}">{{ platform.name }}</a></p>
{% endfor %}
</div>
{% endif %}#}
<details>
<summary><p style="font-weight: bold; font-size: large;">Filters</p></summary>
<form hx-trigger="submit" hx-get="/stop/{{ stop.id }}/table" hx-target="#nta-table" hx-swap="outerHTML" hx-push-url="/stop/{{ stop.id}}">
<div style="margin: 5px; padding: 10px; background-color: #eee;">
<div style="display: flex; flex-wrap: wrap;">
<fieldset style="flex-grow: 1;">
<legend>Route</legend>
{% for route in routes %}
{% for dir in route.directions %}
{% if let Some(fil) = filters && let Some(rts) = fil.routes %}
{% let route_filter_id = format!("{},{}", route.id, dir.direction) %}
<input type="checkbox" class="route-checkbox" name="routes" id="{{ route.id }},{{ dir.direction }}" value="{{ route.id }},{{ dir.direction}}" checked="{{ rts.contains(&*route_filter_id) }}">
{% else %}
<input type="checkbox" class="route-checkbox" name="routes" id="{{ route.id }},{{ dir.direction }}" value="{{ route.id }},{{ dir.direction}}" checked="true">
{% endif %}
<div hx-get="/stop/{{ stop.id }}/table" hx-trigger="every 5s">
{% call stop_table::stop_table(trips, current_time) %}
<label for="{{ route.id }},{{ dir.direction }}">
<b>{{ route.short_name }}</b>: {{ dir.direction_destination }}
</label>
<br>
{% endfor %}
{% endfor %}
<input type="checkbox" id="master"
hx-on:click="document.querySelectorAll('.route-checkbox').forEach(c => c.checked = this.checked)">
<label for="master">Select/Deselect All</label>
</fieldset>
<div style="flex-grow: 1;">
<fieldset>
<legend>Ride Options</legend>
{% if let Some(fil) = filters && let Some(lt) = fil.live_tracked %}
<input type="checkbox" name="live_tracked" id="live_tracked" value="true" checked="{{ lt }}">
{% else %}
<input type="checkbox" name="live_tracked" id="live_tracked" value="true" checked="true">
{% endif %}
<label for="live-tracked">
Live Tracked
</label>
<br>
{% if let Some(fil) = filters && let Some(sc) = fil.scheduled %}
<input type="checkbox" name="scheduled" id="scheduled" value="true" checked="{{ sc }}">
{% else %}
<input type="checkbox" name="scheduled" id="scheduled" value="true" checked="true">
{% endif %}
<label for="scheduled">
Scheduled
</label>
<br>
</fieldset>
<fieldset>
<legend>Crowding</legend>
{% for avail in SeatAvailability::iter() %}
{% if let Some(fil) = filters && let Some(crd) = fil.crowding %}
<input type="checkbox" name="crowding" id="{{ avail.to_string() }}" value="{{ avail.to_string() }}" checked="{{ crd.contains(&avail) }}">
{% else %}
<input type="checkbox" name="crowding" id="{{ avail.to_string() }}" value="{{ avail.to_string() }}" checked="true">
{% endif %}
<label for="{{ avail.to_string() }}">
{{ avail.to_human_string() }}
</label>
<br>
{% endfor %}
{% if let Some(fil) = filters && let Some(uc) = fil.unknown_crowding %}
<input type="checkbox" name="unknown_crowding" id="unknown_crowding" value="true" checked="{{ uc }}">
{% else %}
<input type="checkbox" name="unknown_crowding" id="unknown_crowding" value="true" checked="true">
{% endif %}
<label for="scheduled">
Unknown
</label>
</fieldset>
</div>
</div>
<input type="submit" value="Apply">
</div>
</form>
</details>
<div style="overflow-x: scroll; max-width: 100%;">
{% call stop_table::stop_table(trips, current_time, stop.id, query_str) %}
{% endcall %}
</div>