Skip to content

refactor: Extract timetable template to its own component#3229

Merged
joshlarson merged 24 commits into
mainfrom
jdl/refactor/timetable-component
Jun 5, 2026
Merged

refactor: Extract timetable template to its own component#3229
joshlarson merged 24 commits into
mainfrom
jdl/refactor/timetable-component

Conversation

@joshlarson
Copy link
Copy Markdown
Contributor

@joshlarson joshlarson commented Jun 4, 2026

Scope

The end goal of this work is to have a timetable component whose invocation will be (almost) as simple as <.timetable timetable={@timetable} />. That will make it easier to render the Harbor Loop Ferry with two timetables on the same page, and give us more flexibility in how we render different types of timetable pages in the future.

This PR goes about halfway - it splits out a separate component for the timetable (actually two... more on that in a moment), and adds more structure to the %Timetable{} struct, introduced in #3206. The remaining refactor work is to pull the last bits of non-user-interaction data (i.e. alerts) into the Timetables module. Once we do that, rendering a different layout for the Harbor Loop Ferry should be almost trivial.

Two timetables?

We already have two different timetable implementations, although they're currently kind of muddled together, using the somewhat opaquely-named use_pdf_schedules? flag.

  • When use_pdf_schedules? is true, then the timetable template expects @timetable_schedules, @header_stops, and @header_schedules to be set.
  • When use_pdf_schedules? is false, then the timetable still expects @header_stops and @header_schedules to be set, but it gets its cell data from @trip_schedules and @trip_messages instead (along with data from a few other fields, like @track_changes.

A core part of this PR makes is to explicitly separate those two implementations into <.linear_timetable /> (so named because it can't support loops or trips that visit the same stops in different orders, and <.timetable />, which has no such constraint, but has fewer features (e.g. it doesn't support track changes... for now!). Most of the rest of this PR is cleanup around the edges of the contract between <.timetable /> and the template that calls it, as well as the %Timetable{} struct that gets passed in.

Asana Ticket: ⛴️ Make timetable its own component(s)

Implementation

Warning

This PR is quite large, so I'll walk through it commit-by-commit.

Groundwork

Tip

These commits lay the groundwork for all of the upcoming work - converting a bunch of HEEx code into components and updating some out-dated variable names

Cleanup

Tip

A lot of the commits in this PR are relatively minor cleanup's around the edges. This is the first instance of those.

Two timetables!

Tip

See discussion above. This is where I split the timetable glob into two fully different components and trimmed down the attributes passed into each.

%Timetable{} struct

Tip

This section is where I started adding more structure to the %Timetable{} struct and integrating it more tightly with the timetable component.

Screenshots

No visual changes.

How to test

This should have no actual changes, so take a look at some timetables for commuter rail and timetables for ferry (don't forget the loop ferry routes) and compare them to their prod equivalents.

Note

The Harbor Loop Ferry doesn't start until June 29, and doesn't run on weekends, so the fact that it doesn't a show a timetable for today is a feature, not a bug.


joshlarson added 21 commits June 4, 2026 11:10
@joshlarson joshlarson marked this pull request as ready for review June 4, 2026 17:34
@joshlarson joshlarson requested a review from a team as a code owner June 4, 2026 17:34
@joshlarson joshlarson requested a review from thecristen June 4, 2026 17:34
Copy link
Copy Markdown
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are three broken tests from the old timetable view test file, please fix!
I think the rest looks and works great. 🚀

@joshlarson joshlarson requested a review from thecristen June 5, 2026 16:51
Copy link
Copy Markdown
Collaborator

@thecristen thecristen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshlarson joshlarson merged commit 7b89c09 into main Jun 5, 2026
23 checks passed
@joshlarson joshlarson deleted the jdl/refactor/timetable-component branch June 5, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants