@@ -3,6 +3,7 @@ import React, { Component } from 'react'
3
3
import { connect } from 'react-redux'
4
4
import styled from 'styled-components'
5
5
6
+ import { isBlank } from '../../util/ui'
6
7
import { getFormattedStopTime , getStopTimesByPattern } from '../../util/viewer'
7
8
8
9
const { getTimeFormat } = coreUtils . time
@@ -25,13 +26,16 @@ const StyledTable = styled.table`
25
26
}
26
27
`
27
28
28
- const RouteTd = styled . td `
29
+ const DestHeader = styled . th `
30
+ width: 100%;
31
+ `
32
+ const RouteCell = styled . td `
29
33
font-weight: bold;
30
34
`
31
- const DestTd = styled . td `
35
+ const DestCell = styled . td `
32
36
width: 100%;
33
37
`
34
- const TimeTd = styled . td `
38
+ const TimeCell = styled . td `
35
39
font-weight: bold;
36
40
text-align: right;
37
41
white-space: nowrap;
@@ -50,17 +54,19 @@ class StopScheduleTable extends Component {
50
54
51
55
// Merge stop times, so that we can sort them across all route patterns.
52
56
let mergedStopTimes = [ ]
53
- Object . values ( stopTimesByPattern ) . forEach ( pattern => {
57
+ Object . values ( stopTimesByPattern ) . forEach ( pattern => { //TODO:breakup pattern vars
54
58
const filteredTimes = pattern . times
55
59
//TODO refactor - Copied from util/viewers
56
60
. filter ( stopTime => {
57
61
return stopTime . stopIndex < stopTime . stopCount - 1 // ensure that this isn't the last stop
58
62
} )
59
63
. map ( stopTime => {
60
- // Add a route attribute to each stop time for rendering route info.
64
+ // Add the route attribute and headsign to each stop time for rendering route info.
65
+ const headsign = isBlank ( stopTime . headsign ) ? pattern . pattern . headsign : stopTime . headsign
61
66
return {
62
67
...stopTime ,
63
- route : pattern . route
68
+ route : pattern . route ,
69
+ headsign
64
70
}
65
71
} )
66
72
mergedStopTimes = mergedStopTimes . concat ( filteredTimes ) // reduce?
@@ -79,21 +85,21 @@ class StopScheduleTable extends Component {
79
85
< tr >
80
86
< th > Block</ th >
81
87
< th > Route</ th >
82
- < th > To</ th >
88
+ < DestHeader > To</ DestHeader >
83
89
< th > Departure</ th >
84
90
</ tr >
85
91
</ thead >
86
92
< tbody >
87
- { mergedStopTimes . map ( stopTime => {
93
+ { mergedStopTimes . map ( ( stopTime , index ) => {
88
94
const { blockId, headsign, route } = stopTime
89
95
const routeName = route . shortName ? route . shortName : route . longName
90
- const time = getFormattedStopTime ( stopTime , homeTimezone , stopViewerArriving , timeFormat , true )
96
+ const time = getFormattedStopTime ( stopTime , homeTimezone , stopViewerArriving , timeFormat , true , false , false )
91
97
return (
92
- < tr >
98
+ < tr key = { index } >
93
99
< td > { blockId } </ td >
94
- < RouteTd > { routeName } </ RouteTd >
95
- < DestTd > { headsign } </ DestTd >
96
- < TimeTd > { time } </ TimeTd >
100
+ < RouteCell > { routeName } </ RouteCell >
101
+ < DestCell > { headsign } </ DestCell >
102
+ < TimeCell > { time } </ TimeCell >
97
103
</ tr >
98
104
)
99
105
} ) }
0 commit comments