-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Convert itinerary legs to segments for easier rendering #2262
refactor: Convert itinerary legs to segments for easier rendering #2262
Conversation
…itinerary_detail /> doesn't have to think about them
@@ -0,0 +1,37 @@ | |||
defmodule DotcomWeb.Components.TripPlanner.LegToSegmentHelper do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sold on either this name or this location for this file, but I couldn't think of a better one off the top of my head.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since it's not technically a rendered component, you can move this to the Dotcom.TripPlan.
namespace. I don't mind the current name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💥 5caf9b7 💥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so elegant 🤩
I think you should move the helper module. And as the linter says you can add a @moduledoc
to it too. And don't forget the formatting!
Otherwise I think this looks great.
@thecristen I think I addressed everything - want to take another look? |
lib/dotcom/trip_plan/input_form.ex
Outdated
@@ -49,6 +49,7 @@ defmodule Dotcom.TripPlan.InputForm do | |||
date: PlanParams.to_date_param(datetime), | |||
time: PlanParams.to_time_param(datetime), | |||
transportModes: __MODULE__.Modes.selected_mode_keys(modes) |> PlanParams.to_modes_param(), | |||
numItineraries: 40, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda wanna let this slide, but 40 seems kinda excessive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh oops - didn't mean to include this change. I've been using that to get more itineraries so that the one I'm looking for is more likely to actually show up.
Pure refactor.
No ticket.
The point of this refactor is that the data returned from OpenTripPlanner is subtly different from what we want to render on the screen. Even in a simple case, when OTP returns
[walking, transit, walking]
, what we actually want to draw on the screen is[location, walking, transit, walking, location]
*, and there are some corner-cases that make this even more complicated.*I'm making the assumption that drawing
transit
on the screen actually means drawing the transit leg's start location and end location, each with the right icon for that transit leg, on either side of the transit leg details itself. This works out, since all transit legs are bracketed by locations indicating their stops or stations.This'll enable follow-ups to address two use cases:
[transit, walking, transit]
or something like that, where the first or last leg of an itinerary is transit, then we want to draw[transit, walking, transit]
- in other words, we don't want to showlocation
right next to transit. Ticket for this, which includes a screenshot of what it looks like now.[walking, transit, transit, walking]
, that is, when there's a transfer that involves no walking, then we want to add in a "waiting leg", so the end result should be[location, walking, transit, waiting, transit, walking, location]
. Ticket for this (same deal - has a screenshot).