Skip to content

Commit

Permalink
feat: elevator backup route summaries
Browse files Browse the repository at this point in the history
Each station in the list of elevator closures has a backup route
summary, derived from our hand-authored redundancy data. Also, if any
of an elevator's backup ("alternate") elevators are also closed, it is
no longer filtered out of the list, even if it has "nearby" redundancy.

Additional changes:

* Remove some unused fields from the elevator closure widget.

* Simplify how elevator closure widgets are built and avoid unneeded
  data fetching in the event the "current" elevator is closed.

* Add a warning in case conditions we expect to always be true about
  alerts are proven false.
  • Loading branch information
digitalcora committed Dec 23, 2024
1 parent 371f151 commit 1749066
Show file tree
Hide file tree
Showing 13 changed files with 293 additions and 285 deletions.
20 changes: 8 additions & 12 deletions assets/css/v2/elevator/elevator_closures_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
display: flex;
flex: 1;
flex-direction: column;
font-size: 48px;
line-height: 64px;
color: $cool-black-30;

.in-station-summary {
position: relative;
display: flex;
justify-content: space-between;
padding: 24px 48px;
font-size: 48px;
font-weight: 400;
line-height: 64px;
color: $cool-black-30;

.text {
margin-right: 82px;
Expand Down Expand Up @@ -123,14 +122,18 @@
}

&__elevator-name {
line-height: 64px;
font-weight: 500;
}

&__elevator-name.list-item {
display: list-item;
margin-bottom: 8px;
margin-left: 48px;
}

&__summary.important {
font-weight: 700;
}
}
}
}
Expand All @@ -149,12 +152,5 @@
padding: 0 48px 20px;
}
}

.paging-info-container,
.closure-row__elevator-name {
font-size: 48px;
font-weight: 400;
color: $cool-black-30;
}
}
}
2 changes: 0 additions & 2 deletions assets/src/components/v2/elevator/current_elevator_closed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import makePersistent, {
WrappedComponentProps,
} from "Components/v2/persistent_wrapper";
import PagingIndicators from "Components/v2/elevator/paging_indicators";
import { type Closure } from "Components/v2/elevator/types";
import useClientPaging from "Hooks/v2/use_client_paging";
import useTextResizer from "Hooks/v2/use_text_resizer";
import CurrentLocationMarker from "Images/svgr_bundled/current-location-marker.svg";
Expand All @@ -29,7 +28,6 @@ const PulsatingDot = ({ x, y }: Coordinates) => {
};

interface Props extends WrappedComponentProps {
closure: Closure;
alternate_direction_text: string;
accessible_path_direction_arrow: Direction;
accessible_path_image_url: string | null;
Expand Down
8 changes: 6 additions & 2 deletions assets/src/components/v2/elevator/elevator_closures_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ClosureRowProps {
}

const ClosureRow = ({
station: { id, name, closures, route_icons },
station: { id, name, closures, route_icons, summary },
isCurrentStation,
}: ClosureRowProps) => {
return (
Expand All @@ -45,9 +45,13 @@ const ClosureRow = ({
"list-item": closures.length > 1,
})}
>
{closure.elevator_name} ({closure.elevator_id})
{closure.name} ({closure.id})
</div>
))}

<div className={cx("closure-row__summary", { important: summary })}>
{summary ?? "Accessible route available"}
</div>
</div>
);
};
Expand Down
6 changes: 2 additions & 4 deletions assets/src/components/v2/elevator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ export type StationWithClosures = {
name: string;
route_icons: Pill[];
closures: Closure[];
summary: string | null;
};

export type Closure = {
id: string;
elevator_name: string;
elevator_id: string;
description: string;
header_text: string;
name: string;
};
5 changes: 1 addition & 4 deletions lib/screens/alerts/alert.ex
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@ defmodule Screens.Alerts.Alert do
| :unknown

@type informed_entity :: %{
optional(:facility) => %{
id: String.t() | nil,
name: String.t() | nil
},
facility: %{id: String.t(), name: String.t()} | nil,
stop: String.t() | nil,
route: String.t() | nil,
route_type: non_neg_integer() | nil,
Expand Down
13 changes: 9 additions & 4 deletions lib/screens/alerts/parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,14 @@ defmodule Screens.Alerts.Parser do
stop: get_in(ie, ["stop"]),
route: get_in(ie, ["route"]),
route_type: get_in(ie, ["route_type"]),
direction_id: get_in(ie, ["direction_id"])
direction_id: get_in(ie, ["direction_id"]),
facility: nil
}
end

defp parse_informed_entity_with_facilities(ie, facilities) do
parsed = parse_informed_entity(ie)

facility_id = get_in(ie, ["facility"])

facility_name =
Expand All @@ -85,9 +88,11 @@ defmodule Screens.Alerts.Parser do
:error -> nil
end

ie
|> parse_informed_entity()
|> Map.put(:facility, %{id: facility_id, name: facility_name})
if not is_nil(facility_id) and not is_nil(facility_name) do
Map.put(parsed, :facility, %{id: facility_id, name: facility_name})
else
parsed
end
end

defp parse_and_sort_active_periods(periods) do
Expand Down
Loading

0 comments on commit 1749066

Please sign in to comment.