Skip to content
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

Fix alert route selector dev #934

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/gtfs/components/gtfs-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,17 @@ class GtfsSearch extends Component<Props, State> {
stops && stopOptions.push(...stops.map(s => _entityToOption(s, feed)))
routes && routeOptions.push(
...routes
// Remove specified entity ids (route ids in this case) to exclude, except the current value.
.filter(route =>
!excludedEntityIds.includes(route.route_id) ||
// (Extended type checks are for flow validation.)
(route.route_id === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption))
// Keep routes whose ids are not excluded and that are not the one selected in the dropdown.
.filter(route => {
const { route_id: routeId } = route
if (routeId === null || routeId === undefined) return false

const isExcluded = excludedEntityIds && excludedEntityIds.includes(routeId)
const isSameAsCurrent =
// (Extended type checks are for flow validation.)
routeId === (typeof currentOption === 'object' ? currentOption && currentOption.value : currentOption)
return !isExcluded && !isSameAsCurrent
}
)
.map(r => _entityToOption(r, feed))
)
Expand Down