Skip to content

Commit 5e01681

Browse files
authored
Merge pull request #726 from opentripplanner/printable-itin-stop-id
Stop ID in printable itinerary.
2 parents e54f409 + 7331148 commit 5e01681

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

Diff for: lib/components/map/enhanced-stop-marker.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { connect } from 'react-redux'
88
import { FormattedMessage } from 'react-intl'
99
import { MapMarker } from '@styled-icons/fa-solid/MapMarker'
1010
import { Styled as StopsOverlayStyled } from '@opentripplanner/stops-overlay'
11+
import coreUtils from '@opentripplanner/core-utils'
1112
import FromToLocationPicker from '@opentripplanner/from-to-location-picker'
1213
import React, { Component } from 'react'
1314
import styled from 'styled-components'
@@ -93,10 +94,9 @@ class EnhancedStopMarker extends Component {
9394
render() {
9495
const { activeStopId, highlight, languageConfig, modeColors, stop } =
9596
this.props
96-
const { code, id, lat, lon, name } = stop
97-
const [, stopId] = id.split(':')
98-
const stopCode = code || stopId
99-
if (!stopCode) return null
97+
const { id, lat, lon, name } = stop
98+
const displayedStopId = coreUtils.itinerary.getDisplayedStopId(stop)
99+
if (!displayedStopId) return null
100100

101101
const mode = getModeFromStop(stop)
102102
let color = modeColors && modeColors[mode] ? modeColors[mode] : '#121212'
@@ -130,7 +130,7 @@ class EnhancedStopMarker extends Component {
130130
<b>
131131
<FormattedMessage id="components.EnhancedStopMarker.stopID" />
132132
</b>{' '}
133-
{stopCode}
133+
{displayedStopId}
134134
</span>
135135
<ViewStopButton onClick={this.onClickView}>
136136
{languageConfig.stopViewer || (

Diff for: lib/util/state.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,10 @@ export function getTitle(state, intl) {
833833
case MainPanelContent.STOP_VIEWER:
834834
status = intl.formatMessage(
835835
{ id: 'util.state.titleBarStopId' },
836-
{ stopId: viewedStop?.stopCode || viewedStop?.stopId }
836+
{
837+
stopId:
838+
viewedStop && coreUtils.itinerary.getDisplayedStopId(viewedStop)
839+
}
837840
)
838841
break
839842
default:

Diff for: lib/util/viewer.js

+3-11
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
12
/* eslint-disable @typescript-eslint/no-use-before-define */
23
import { getMostReadableTextColor } from '@opentripplanner/core-utils/lib/route'
4+
import coreUtils from '@opentripplanner/core-utils'
35
import tinycolor from 'tinycolor2'
46

57
import { isBlank } from './ui'
@@ -54,17 +56,7 @@ export function routeIsValid(route, routeId) {
5456
}
5557

5658
export function getStopName(stop) {
57-
return `${stop.name} (${getStopCodeToDisplay(stop)})`
58-
}
59-
60-
/**
61-
* Gets stop code for displaying to user.
62-
* @param {Object} stop OTP stop entity
63-
* @return {string} stop_code or cleaned stop_id
64-
*/
65-
export function getStopCodeToDisplay(stop) {
66-
if (!stop) return ''
67-
return stop.code || stop.id.split(':')[1]
59+
return `${stop.name} (${coreUtils.itinerary.getDisplayedStopId(stop)})`
6860
}
6961

7062
/**

0 commit comments

Comments
 (0)