Skip to content

Commit

Permalink
readonly select stations and zones
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulJKim committed Jan 24, 2025
1 parent 0854af6 commit 46441fa
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 13 deletions.
12 changes: 12 additions & 0 deletions assets/css/dashboard/new-pa-message/select-zones-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@
.btn {
padding: 6px 12px;
height: fit-content;

&:disabled:not(.button-active) {
background-color: inherit;
border-color: inherit;
color: $text-secondary;
}
}
}
}
Expand Down Expand Up @@ -222,6 +228,12 @@
.btn {
padding: 6px 12px;
height: fit-content;

&:disabled:not(.button-active) {
background-color: inherit;
border-color: inherit;
color: $text-secondary;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface PlaceZonesRow {
rightZones: Screen[];
route: string;
branches?: string[];
disabled?: boolean;
}

const PlaceZonesRow = ({
Expand All @@ -29,6 +30,7 @@ const PlaceZonesRow = ({
rightZones,
route,
branches = [],
disabled = false,
}: PlaceZonesRow) => {
if (allSignsForRouteAtPlace.length === 0) return null;

Expand Down Expand Up @@ -76,6 +78,7 @@ const PlaceZonesRow = ({
);
}
}}
disabled={disabled}
>
All
</Button>
Expand All @@ -86,13 +89,15 @@ const PlaceZonesRow = ({
onSignButtonClick={onSignButtonClick}
leftIcon={<ArrowLeftShort />}
allSelectedSigns={allSelectedSigns}
disabled={disabled}
/>
</td>
<td className="cell middle-cell">
<SignButtonGroup
signs={middleZones}
onSignButtonClick={onSignButtonClick}
allSelectedSigns={allSelectedSigns}
disabled={disabled}
/>
</td>
<td className="cell right-cell">
Expand All @@ -101,6 +106,7 @@ const PlaceZonesRow = ({
onSignButtonClick={onSignButtonClick}
rightIcon={<ArrowRightShort />}
allSelectedSigns={allSelectedSigns}
disabled={disabled}
/>
</td>
</tr>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const RouteColumn = ({
value,
onChange,
reverse = false,
disabled = false,
}: {
label: string;
routeIds: string[];
Expand All @@ -20,6 +21,7 @@ const RouteColumn = ({
value: string[];
onChange: (signIds: string[]) => void;
reverse?: boolean;
disabled?: boolean;
}) => {
const signsIdsAtRoutes = places.flatMap((place) =>
place.screens
Expand All @@ -46,6 +48,7 @@ const RouteColumn = ({
}
}}
checked={signsIdsAtRoutes.every((signId) => value.includes(signId))}
disabled={disabled}
/>
</div>
<div className="col-content">
Expand Down Expand Up @@ -74,6 +77,7 @@ const RouteColumn = ({
checked={value.some((signId) =>
signIdsAtPlace.includes(signId),
)}
disabled={disabled}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ interface Props {
page: Page;
busRoutes: string[];
onError: (message: string | null) => void;
isReadOnly?: boolean;
}

const SelectStationsAndZones = ({
Expand All @@ -23,6 +24,7 @@ const SelectStationsAndZones = ({
page,
busRoutes,
onError,
isReadOnly = false,
}: Props) => {
const dispatch = useScreenplayDispatchContext();
const [signIds, setSignIds] = useState(value);
Expand All @@ -41,6 +43,7 @@ const SelectStationsAndZones = ({
onChange={setSignIds}
busRoutes={busRoutes}
onError={onError}
isReadOnly={isReadOnly}
/>
) : (
<SelectZonesPage
Expand All @@ -49,6 +52,7 @@ const SelectStationsAndZones = ({
onChange={setSignIds}
places={places}
onSubmit={onChange}
isReadOnly={isReadOnly}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface Props {
navigateTo: (page: Page) => void;
busRoutes: string[];
onError: (message: string | null) => void;
isReadOnly?: boolean;
}

const SelectStationsPage = ({
Expand All @@ -45,6 +46,7 @@ const SelectStationsPage = ({
navigateTo,
busRoutes,
onError,
isReadOnly = false,
}: Props) => {
const routeNameToRouteIds = useRouteToRouteIDsMap();

Expand Down Expand Up @@ -85,13 +87,13 @@ const SelectStationsPage = ({
return (
<div className="select-stations-page">
<div className="header">
<div>Select Stations</div>
<div>{isReadOnly ? "Stations" : "Select Stations"}</div>
<div className="buttons">
<Button
className="cancel-button"
onClick={() => navigateTo(Page.MAIN)}
>
Cancel
{isReadOnly ? "Back" : "Cancel"}
</Button>
<Button
className="submit-button button-primary"
Expand All @@ -112,6 +114,7 @@ const SelectStationsPage = ({
value={value}
onChange={onChange}
busRoutes={busRoutes}
isReadOnly={isReadOnly}
/>
<Container fluid>
<div className="station-groups-col col">
Expand All @@ -127,6 +130,7 @@ const SelectStationsPage = ({
stations={GL_CENTRAL_SUBWAY}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="GL D Branch"
Expand All @@ -136,6 +140,7 @@ const SelectStationsPage = ({
stations={GL_D_BRANCH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="GL E Branch"
Expand All @@ -145,6 +150,7 @@ const SelectStationsPage = ({
stations={GL_E_BRANCH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="GLX"
Expand All @@ -154,6 +160,7 @@ const SelectStationsPage = ({
stations={GLX}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<hr />
</div>
Expand All @@ -167,6 +174,7 @@ const SelectStationsPage = ({
stations={RED_BRAINTREE_BRANCH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="Ashmont Branch"
Expand All @@ -176,6 +184,7 @@ const SelectStationsPage = ({
stations={RED_ASHMONT_BRANCH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="Red Line Trunk"
Expand All @@ -185,6 +194,7 @@ const SelectStationsPage = ({
stations={RED_TRUNK}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<hr />
</div>
Expand All @@ -198,6 +208,7 @@ const SelectStationsPage = ({
stations={ORANGE_NORTH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
<StationGroupCheckbox
title="South"
Expand All @@ -207,6 +218,7 @@ const SelectStationsPage = ({
stations={ORANGE_SOUTH}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
</div>
</div>
Expand All @@ -225,6 +237,7 @@ const SelectStationsPage = ({
}
}}
checked={greenLineSignIds.every((signId) => value.includes(signId))}
disabled={isReadOnly}
/>

<div className="branches-col">
Expand All @@ -241,6 +254,7 @@ const SelectStationsPage = ({
places={placesByRoute[route]}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
);
})}
Expand All @@ -260,6 +274,7 @@ const SelectStationsPage = ({
value={value}
onChange={onChange}
reverse={route === "Blue"}
disabled={isReadOnly}
/>
</div>
))}
Expand All @@ -271,6 +286,7 @@ const SelectStationsPage = ({
places={placesByRoute["Bus"]}
value={value}
onChange={onChange}
disabled={isReadOnly}
/>
</div>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ interface Props {
onSubmit: (signIds: string[]) => void;
navigateTo: (page: Page) => void;
places: Place[];
isReadOnly?: boolean;
}

const SelectZonesPage = ({
Expand All @@ -40,6 +41,7 @@ const SelectZonesPage = ({
onSubmit,
navigateTo,
places,
isReadOnly = false,
}: Props) => {
const routeToRouteIDMap = useRouteToRouteIDsMap();
const getInitialPlacesWithSelectedSigns = () =>
Expand Down Expand Up @@ -190,17 +192,19 @@ const SelectZonesPage = ({
className="edit-button"
onClick={() => navigateTo(Page.STATIONS)}
>
Edit Stations
{isReadOnly ? "Return to Select" : "Edit"} Stations
</Button>
</div>
</div>
<div className="buttons">
<Button
className="cancel-button"
onClick={() => navigateTo(Page.MAIN)}
>
Cancel
</Button>
{!isReadOnly && (
<Button
className="cancel-button"
onClick={() => navigateTo(Page.MAIN)}
>
Cancel
</Button>
)}
<Button
className="button-primary"
onClick={() => {
Expand Down Expand Up @@ -276,6 +280,7 @@ const SelectZonesPage = ({
onClick={() =>
onChange(fp.uniq([...value, ...signIDs(allScreens)]))
}
disabled={isReadOnly}
>
{massSelectButtonLabels.left}
</Button>
Expand All @@ -284,6 +289,7 @@ const SelectZonesPage = ({
"button-active": isLeftSelected,
})}
onClick={() => selectDirectionGroup(0)}
disabled={isReadOnly}
>
{massSelectButtonLabels.middle}
</Button>
Expand All @@ -292,6 +298,7 @@ const SelectZonesPage = ({
"button-active": isRightSelected,
})}
onClick={() => selectDirectionGroup(1)}
disabled={isReadOnly}
>
{massSelectButtonLabels.right}
</Button>
Expand Down Expand Up @@ -350,6 +357,7 @@ const SelectZonesPage = ({
rightZones={signsGroupedByZone.right}
route={selectedRouteFilter}
branches={branches}
disabled={isReadOnly}
/>
{selectedRouteFilter !== "Bus" && (
<PlaceZonesRow
Expand All @@ -361,6 +369,7 @@ const SelectZonesPage = ({
middleZones={busSignsGroupedByZone.middle}
rightZones={busSignsGroupedByZone.right}
route={"Bus"}
disabled={isReadOnly}
/>
)}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ interface Props {
onChange: (signIds: string[]) => void;
places: Place[];
busRoutes: string[];
isReadOnly?: boolean;
}

const SelectedStationsSummary = ({
value,
places,
busRoutes,
onChange,
isReadOnly = false,
}: Props) => {
return (
<div className="selected-stations-summary">
Expand All @@ -29,6 +31,7 @@ const SelectedStationsSummary = ({
value={value}
onChange={onChange}
busRoutes={busRoutes}
isReadOnly={isReadOnly}
/>
</div>
)}
Expand Down
Loading

0 comments on commit 46441fa

Please sign in to comment.