From ad2a7f2f1302589690b0c450097889cea1719076 Mon Sep 17 00:00:00 2001 From: Anthony Shull Date: Fri, 6 Dec 2024 08:30:04 -0600 Subject: [PATCH] Add walking legs to the trip plan details (#2246) * walking leg nearly complete * update to use the latest metro * docs * format * remove extra * remove id from accordion * change gray color * mix lock * mix format more files --- lib/dotcom_web/components/components.ex | 6 +-- .../live_components/trip_planner_form.ex | 18 +++---- .../trip_planner_results_section.ex | 8 +-- lib/dotcom_web/components/route_symbols.ex | 2 +- .../trip_planner/itinerary_detail.ex | 31 ++++++----- .../trip_planner/itinerary_summary.ex | 12 ++--- lib/dotcom_web/components/trip_planner/leg.ex | 16 +++--- .../components/trip_planner/walking_leg.ex | 53 +++++++++++++++++++ lib/dotcom_web/live/admin.ex | 4 +- .../live/admin/trip_plan_feedback.ex | 4 +- lib/dotcom_web/live/trip_planner.ex | 8 +-- lib/dotcom_web/templates/alert/show.html.heex | 26 ++++----- .../templates/error/error_layout.html.heex | 12 ++--- .../fare/proposed_sales_locations.html.heex | 26 ++++----- .../fare/retail_sales_locations.html.heex | 12 ++--- .../templates/layout/_new_header.html.heex | 8 +-- .../layout/_new_nav_mobile.html.heex | 10 ++-- .../templates/layout/admin.html.heex | 6 +-- .../templates/layout/preview.html.heex | 2 +- lib/dotcom_web/templates/page/menu.html.heex | 6 +-- .../trip_plan/_leg_summary.html.heex | 16 +++--- .../trip_plan/_mobile_trip_summary.html.heex | 4 +- .../templates/trip_plan/_options.html.heex | 8 +-- .../trip_plan/_time_inputs.html.heex | 2 +- .../templates/trip_plan/index.html.heex | 6 +-- lib/dotcom_web/templates/vote/show.html.heex | 12 ++--- mix.exs | 4 +- mix.lock | 4 +- test/dotcom_web/components_test.exs | 4 +- 29 files changed, 191 insertions(+), 139 deletions(-) create mode 100644 lib/dotcom_web/components/trip_planner/walking_leg.ex diff --git a/lib/dotcom_web/components/components.ex b/lib/dotcom_web/components/components.ex index 2861ccc4b3..65ab9aed98 100644 --- a/lib/dotcom_web/components/components.ex +++ b/lib/dotcom_web/components/components.ex @@ -66,7 +66,7 @@ defmodule DotcomWeb.Components do />
- <%= render_slot(@inner_block) %> + {render_slot(@inner_block)} """ end @@ -81,8 +81,8 @@ defmodule DotcomWeb.Components do ~H"""
-

<%= @title %>

- <%= render_slot(@inner_block) %> +

{@title}

+ {render_slot(@inner_block)}
""" end diff --git a/lib/dotcom_web/components/live_components/trip_planner_form.ex b/lib/dotcom_web/components/live_components/trip_planner_form.ex index 7ff7142b4d..0d37f2e01d 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_form.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_form.ex @@ -73,7 +73,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do /> <.error_container :for={{msg, _} <- f[field].errors} :if={used_input?(f[field])}> - <%= msg %> + {msg} @@ -93,7 +93,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do :for={{msg, _} <- f[:datetime_type].errors} :if={used_input?(f[:datetime_type])} > - <%= msg %> + {msg} <.live_component :if={@show_datepicker} @@ -103,14 +103,14 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do id={:datepicker} /> <.error_container :for={{msg, _} <- f[:datetime].errors} :if={used_input?(f[:datetime])}> - <%= msg %> + {msg}
<.fieldset id="modes" legend="Modes"> - <.accordion id="accordion"> + <.accordion variant="contained"> <:heading> - <%= Modes.selected_modes(input_value(f, :modes)) %> + {Modes.selected_modes(input_value(f, :modes))} <:content>
@@ -124,12 +124,10 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerForm do
- <:extra :if={used_input?(f[:modes])}> - <.error_container :for={{msg, _} <- f[:modes].errors}> - <%= msg %> - - + <.error_container :for={{msg, _} <- f[:modes].errors}> + {msg} +
<.input type="checkbox" field={f[:wheelchair]} label="Prefer accessible routes" /> diff --git a/lib/dotcom_web/components/live_components/trip_planner_results_section.ex b/lib/dotcom_web/components/live_components/trip_planner_results_section.ex index 321f041078..0d0f9362d5 100644 --- a/lib/dotcom_web/components/live_components/trip_planner_results_section.ex +++ b/lib/dotcom_web/components/live_components/trip_planner_results_section.ex @@ -28,7 +28,7 @@ defmodule DotcomWeb.Components.LiveComponents.TripPlannerResultsSection do "border border-solid border-slate-400" ]}>
- <%= inspect(@error) %> + {inspect(@error)}
<.async_result :let={results} assign={@results}>
- <%= summary.tag %> + {summary.tag}
<.itinerary_summary summary={summary} />
0} class="grow text-sm text-grey-dark"> - Similar trips depart at <%= Enum.map(summary.next_starts, &format_datetime_short/1) - |> Enum.join(", ") %> + Similar trips depart at {Enum.map(summary.next_starts, &format_datetime_short/1) + |> Enum.join(", ")}
""" end diff --git a/lib/dotcom_web/components/trip_planner/itinerary_detail.ex b/lib/dotcom_web/components/trip_planner/itinerary_detail.ex index 0cef0b9786..56a677b9ae 100644 --- a/lib/dotcom_web/components/trip_planner/itinerary_detail.ex +++ b/lib/dotcom_web/components/trip_planner/itinerary_detail.ex @@ -6,7 +6,8 @@ defmodule DotcomWeb.Components.TripPlanner.ItineraryDetail do use DotcomWeb, :component - import DotcomWeb.Components.TripPlanner.Leg + import DotcomWeb.Components.TripPlanner.Leg, only: [leg: 1] + import DotcomWeb.Components.TripPlanner.WalkingLeg, only: [walking_leg: 1] alias Dotcom.TripPlan.PersonalDetail @@ -30,7 +31,7 @@ defmodule DotcomWeb.Components.TripPlanner.ItineraryDetail do phx-value-trip-index={index} phx-target={@target} > - <%= Timex.format!(itinerary.start, "%-I:%M%p", :strftime) %> + {Timex.format!(itinerary.start, "%-I:%M%p", :strftime)}
<.specific_itinerary_detail itinerary={@selected_itinerary} /> @@ -55,7 +56,7 @@ defmodule DotcomWeb.Components.TripPlanner.ItineraryDetail do ]} {@rest} > - <%= render_slot(@inner_block) %> + {render_slot(@inner_block)} """ end @@ -73,19 +74,23 @@ defmodule DotcomWeb.Components.TripPlanner.ItineraryDetail do ~H"""
- Depart at <%= Timex.format!(@itinerary.start, "%-I:%M%p", :strftime) %> + Depart at {Timex.format!(@itinerary.start, "%-I:%M%p", :strftime)} <.route_symbol :for={route <- @all_routes} route={route} class="ml-2" />
- <.leg - start_time={leg.start} - end_time={leg.stop} - from={leg.from} - to={leg.to} - mode={leg.mode} - realtime={leg.realtime} - realtime_state={leg.realtime_state} - /> + <%= if match?(%PersonalDetail{}, leg.mode) do %> + <.walking_leg leg={leg} /> + <% else %> + <.leg + start_time={leg.start} + end_time={leg.stop} + from={leg.from} + to={leg.to} + mode={leg.mode} + realtime={leg.realtime} + realtime_state={leg.realtime_state} + /> + <% end %>
""" diff --git a/lib/dotcom_web/components/trip_planner/itinerary_summary.ex b/lib/dotcom_web/components/trip_planner/itinerary_summary.ex index efaf7a6db6..8d497b3354 100644 --- a/lib/dotcom_web/components/trip_planner/itinerary_summary.ex +++ b/lib/dotcom_web/components/trip_planner/itinerary_summary.ex @@ -11,12 +11,10 @@ defmodule DotcomWeb.Components.TripPlanner.ItinerarySummary do
- <%= format_datetime_full(@summary.first_start) %> - <%= format_datetime_full( - @summary.first_stop - ) %> + {format_datetime_full(@summary.first_start)} - {format_datetime_full(@summary.first_stop)}
- <%= @summary.duration %> min + {@summary.duration} min
@@ -32,12 +30,12 @@ defmodule DotcomWeb.Components.TripPlanner.ItinerarySummary do
<.icon name="person-walking" class="h-3 w-3" /> - <%= @summary.walk_distance %> mi + {@summary.walk_distance} mi
0} class="inline-flex items-center gap-0.5"> <.icon name="circle" class="h-0.5 w-0.5 mx-1" /> <.icon name="wallet" class="h-3 w-3" /> - <%= Fares.Format.price(@summary.total_cost) %> + {Fares.Format.price(@summary.total_cost)}
@@ -56,7 +54,7 @@ defmodule DotcomWeb.Components.TripPlanner.ItinerarySummary do @class ]}> <.icon name="person-walking" class="h-4 w-4" /> - <%= @walk_minutes %> min + {@walk_minutes} min """ end diff --git a/lib/dotcom_web/components/trip_planner/leg.ex b/lib/dotcom_web/components/trip_planner/leg.ex index 88f8563171..3d8dd12cbf 100644 --- a/lib/dotcom_web/components/trip_planner/leg.ex +++ b/lib/dotcom_web/components/trip_planner/leg.ex @@ -31,16 +31,16 @@ defmodule DotcomWeb.Components.TripPlanner.Leg do ~H"""
- <%= @from.name %> - <%= format_time(@start_time) %> + {@from.name} + {format_time(@start_time)}
-

Realtime data: <%= @realtime_state %>

+

Realtime data: {@realtime_state}

<.mode mode={@mode} />
- <%= @to.name %> - <%= format_time(@end_time) %> + {@to.name} + {format_time(@end_time)}
""" @@ -71,11 +71,11 @@ defmodule DotcomWeb.Components.TripPlanner.Leg do def transit(assigns) do ~H"""
- <.route_symbol route={@route} /> (<%= @route.name %>) on trip <%= @trip_id %> + <.route_symbol route={@route} /> ({@route.name}) on trip {@trip_id}