Skip to content

Commit 1c08e0c

Browse files
feat(StopScheduleTable): Make displaying the Block column configurable.
1 parent bb270a7 commit 1c08e0c

6 files changed

Lines changed: 42 additions & 3 deletions

File tree

__tests__/components/viewers/__snapshots__/stop-viewer.js.snap

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ exports[`components > viewers > stop viewer should render countdown times after
192192
stopViewerConfig={
193193
Object {
194194
"numberOfDepartures": 3,
195+
"showBlockIds": false,
195196
"timeRange": 345600,
196197
}
197198
}
@@ -671,6 +672,7 @@ exports[`components > viewers > stop viewer should render countdown times after
671672
stopViewerConfig={
672673
Object {
673674
"numberOfDepartures": 3,
675+
"showBlockIds": false,
674676
"timeRange": 345600,
675677
}
676678
}
@@ -821,6 +823,7 @@ exports[`components > viewers > stop viewer should render countdown times after
821823
stopViewerConfig={
822824
Object {
823825
"numberOfDepartures": 3,
826+
"showBlockIds": false,
824827
"timeRange": 345600,
825828
}
826829
}
@@ -1140,6 +1143,7 @@ exports[`components > viewers > stop viewer should render countdown times for st
11401143
stopViewerConfig={
11411144
Object {
11421145
"numberOfDepartures": 3,
1146+
"showBlockIds": false,
11431147
"timeRange": 345600,
11441148
}
11451149
}
@@ -1520,6 +1524,7 @@ exports[`components > viewers > stop viewer should render countdown times for st
15201524
stopViewerConfig={
15211525
Object {
15221526
"numberOfDepartures": 3,
1527+
"showBlockIds": false,
15231528
"timeRange": 345600,
15241529
}
15251530
}
@@ -1580,6 +1585,7 @@ exports[`components > viewers > stop viewer should render countdown times for st
15801585
stopViewerConfig={
15811586
Object {
15821587
"numberOfDepartures": 3,
1588+
"showBlockIds": false,
15831589
"timeRange": 345600,
15841590
}
15851591
}
@@ -1998,6 +2004,7 @@ exports[`components > viewers > stop viewer should render times after midnight w
19982004
stopViewerConfig={
19992005
Object {
20002006
"numberOfDepartures": 3,
2007+
"showBlockIds": false,
20012008
"timeRange": 345600,
20022009
}
20032010
}
@@ -2477,6 +2484,7 @@ exports[`components > viewers > stop viewer should render times after midnight w
24772484
stopViewerConfig={
24782485
Object {
24792486
"numberOfDepartures": 3,
2487+
"showBlockIds": false,
24802488
"timeRange": 345600,
24812489
}
24822490
}
@@ -2627,6 +2635,7 @@ exports[`components > viewers > stop viewer should render times after midnight w
26272635
stopViewerConfig={
26282636
Object {
26292637
"numberOfDepartures": 3,
2638+
"showBlockIds": false,
26302639
"timeRange": 345600,
26312640
}
26322641
}
@@ -3312,6 +3321,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
33123321
stopViewerConfig={
33133322
Object {
33143323
"numberOfDepartures": 3,
3324+
"showBlockIds": false,
33153325
"timeRange": 345600,
33163326
}
33173327
}
@@ -4049,6 +4059,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
40494059
stopViewerConfig={
40504060
Object {
40514061
"numberOfDepartures": 3,
4062+
"showBlockIds": false,
40524063
"timeRange": 345600,
40534064
}
40544065
}
@@ -4197,6 +4208,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
41974208
stopViewerConfig={
41984209
Object {
41994210
"numberOfDepartures": 3,
4211+
"showBlockIds": false,
42004212
"timeRange": 345600,
42014213
}
42024214
}
@@ -4448,6 +4460,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
44484460
stopViewerConfig={
44494461
Object {
44504462
"numberOfDepartures": 3,
4463+
"showBlockIds": false,
44514464
"timeRange": 345600,
44524465
}
44534466
}
@@ -4699,6 +4712,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
46994712
stopViewerConfig={
47004713
Object {
47014714
"numberOfDepartures": 3,
4715+
"showBlockIds": false,
47024716
"timeRange": 345600,
47034717
}
47044718
}
@@ -5004,6 +5018,7 @@ exports[`components > viewers > stop viewer should render with OTP transit index
50045018
stopViewerConfig={
50055019
Object {
50065020
"numberOfDepartures": 3,
5021+
"showBlockIds": false,
50075022
"timeRange": 345600,
50085023
}
50095024
}
@@ -5684,6 +5699,7 @@ exports[`components > viewers > stop viewer should render with TriMet transit in
56845699
stopViewerConfig={
56855700
Object {
56865701
"numberOfDepartures": 3,
5702+
"showBlockIds": false,
56875703
"timeRange": 345600,
56885704
}
56895705
}
@@ -6416,6 +6432,7 @@ exports[`components > viewers > stop viewer should render with TriMet transit in
64166432
stopViewerConfig={
64176433
Object {
64186434
"numberOfDepartures": 3,
6435+
"showBlockIds": false,
64196436
"timeRange": 345600,
64206437
}
64216438
}
@@ -6566,6 +6583,7 @@ exports[`components > viewers > stop viewer should render with TriMet transit in
65666583
stopViewerConfig={
65676584
Object {
65686585
"numberOfDepartures": 3,
6586+
"showBlockIds": false,
65696587
"timeRange": 345600,
65706588
}
65716589
}
@@ -6828,6 +6846,7 @@ exports[`components > viewers > stop viewer should render with initial stop id a
68286846
stopViewerConfig={
68296847
Object {
68306848
"numberOfDepartures": 3,
6849+
"showBlockIds": false,
68316850
"timeRange": 345600,
68326851
}
68336852
}

__tests__/reducers/__snapshots__/create-otp-reducer.js.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Object {
1515
"routingTypes": Array [],
1616
"stopViewer": Object {
1717
"numberOfDepartures": 3,
18+
"showBlockIds": false,
1819
"timeRange": 345600,
1920
},
2021
"transitOperators": Array [],

example-config.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,18 @@ itinerary:
200200
# Format the date time format for display.
201201
dateTime:
202202
longDateFormat: DD-MM-YYYY
203+
204+
# stopViewer:
205+
# # The max. number of departures to show for each trip pattern
206+
# # in the stop viewer Next Arrivals mode
207+
# # (defaults to 3 if unspecified).
208+
# numberOfDepartures: 3
209+
# # Whether to display block IDs with each departure in the schedule mode.
210+
# # (defauls to false if unspecified).
211+
# showBlockIds: false
212+
# # Specifies the time window, in seconds, in which to search for next arrivals,
213+
# # so that, for example, if it is Friday and a route does
214+
# # not begin service again until Monday, we are showing its next
215+
# # departure and it is not entirely excluded from display
216+
# # (defaults to 4 days/345600s if unspecified).
217+
# timeRange: 345600

lib/components/viewers/stop-schedule-table.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class StopScheduleTable extends Component {
8181
}
8282

8383
render () {
84-
const { date, stopData, timeFormat } = this.props
84+
const { date, showBlockIds, stopData, timeFormat } = this.props
8585
// Show loading spinner if times are still being fetched.
8686
if (stopData.fetchStatus === FETCH_STATUS.FETCHING) {
8787
return <Loading small />
@@ -100,7 +100,7 @@ class StopScheduleTable extends Component {
100100
<StyledTable>
101101
<thead>
102102
<tr>
103-
<th>Block</th>
103+
{showBlockIds && <th>Block</th>}
104104
<th>Route</th>
105105
<th>To</th>
106106
<th>Departure</th>
@@ -128,7 +128,7 @@ class StopScheduleTable extends Component {
128128
const refProp = scrollToRow ? this.targetDepartureRef : null
129129
return (
130130
<tr key={index} className={className} ref={refProp}>
131-
<BlockCell title={blockId}>{blockId}</BlockCell>
131+
{showBlockIds && <BlockCell title={blockId}>{blockId}</BlockCell>}
132132
<RouteCell>{routeName}</RouteCell>
133133
<td>{headsign}</td>
134134
<TimeCell>{formattedTime}</TimeCell>

lib/components/viewers/stop-viewer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ class StopViewer extends Component {
235235
viewedStop
236236
} = this.props
237237
const { date, scheduleView } = this.state
238+
const { showBlockIds } = stopViewerConfig
238239
const hasStopTimesAndRoutes = !!(stopData && stopData.stopTimes && stopData.stopTimes.length > 0 && stopData.routes)
239240

240241
let contents
@@ -245,6 +246,7 @@ class StopViewer extends Component {
245246
<StopScheduleTable
246247
date={date}
247248
homeTimezone={homeTimezone}
249+
showBlockIds={showBlockIds}
248250
stopData={stopData}
249251
timeFormat={timeFormat}
250252
/>

lib/reducers/create-otp-reducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export function getInitialState (userDefinedConfig, initialQuery) {
7474
routingTypes: [],
7575
stopViewer: {
7676
numberOfDepartures: 3, // per pattern
77+
// Hide block ids unless explicitly enabld in config.
78+
showBlockIds: false,
7779
// This is set to 345600 (four days) so that, for example, if it is Friday and
7880
// a route does not begin service again until Monday, we are showing its next
7981
// departure and it is not entirely excluded from display.

0 commit comments

Comments
 (0)