@@ -2,7 +2,7 @@ import Icon from '@conveyal/woonerf/components/icon'
2
2
import React , { Component , PropTypes } from 'react'
3
3
import { Badge , Button , ButtonGroup , Tooltip , OverlayTrigger , Nav , NavItem } from 'react-bootstrap'
4
4
5
- import { getEntityBounds , getEntityName , getTableById } from '../util/gtfs'
5
+ import { getEntityBounds , getEntityName } from '../util/gtfs'
6
6
import { entityIsNew } from '../util/objects'
7
7
import { GTFS_ICONS } from '../util/ui'
8
8
@@ -20,7 +20,6 @@ export default class EntityDetailsHeader extends Component {
20
20
setActiveEntity : PropTypes . func ,
21
21
subEntity : PropTypes . number ,
22
22
subComponent : PropTypes . string ,
23
- tableData : PropTypes . object ,
24
23
toggleEditFareRules : PropTypes . func ,
25
24
updateMapSetting : PropTypes . func ,
26
25
validationErrors : PropTypes . array
@@ -61,14 +60,26 @@ export default class EntityDetailsHeader extends Component {
61
60
_showFareRules = ( ) => this . props . toggleEditFareRules ( true )
62
61
63
62
_showRoute = ( ) => {
64
- const { activeComponent, activeEntity, feedSource, setActiveEntity, subComponent} = this . props
63
+ const {
64
+ activeComponent,
65
+ activeEntity,
66
+ feedSource,
67
+ setActiveEntity,
68
+ subComponent
69
+ } = this . props
65
70
if ( subComponent === 'trippattern' ) {
66
71
setActiveEntity ( feedSource . id , activeComponent , activeEntity )
67
72
}
68
73
}
69
74
70
75
_showTripPatterns = ( ) => {
71
- const { activeComponent, activeEntity, feedSource, setActiveEntity, subComponent} = this . props
76
+ const {
77
+ activeComponent,
78
+ activeEntity,
79
+ feedSource,
80
+ setActiveEntity,
81
+ subComponent
82
+ } = this . props
72
83
if ( subComponent !== 'trippattern' ) {
73
84
setActiveEntity ( feedSource . id , activeComponent , activeEntity , 'trippattern' )
74
85
}
@@ -83,7 +94,6 @@ export default class EntityDetailsHeader extends Component {
83
94
mapState,
84
95
subComponent,
85
96
subEntityId,
86
- tableData,
87
97
validationErrors
88
98
} = this . props
89
99
const validationTooltip = (
@@ -93,28 +103,28 @@ export default class EntityDetailsHeader extends Component {
93
103
) ) }
94
104
</ Tooltip >
95
105
)
96
- const entityName = activeComponent === 'feedinfo' ? 'Feed Info' : getEntityName ( activeEntity )
106
+ const hasErrors = validationErrors . length > 0
107
+ const entityName = activeComponent === 'feedinfo'
108
+ ? 'Feed Info'
109
+ : getEntityName ( activeEntity )
97
110
const icon = GTFS_ICONS . find ( i => i . id === activeComponent )
98
- const zoomDisabled = activeEntity && ! subComponent ? mapState . target === activeEntity . id : mapState . target === subEntityId
111
+ const zoomDisabled = activeEntity && ! subComponent
112
+ ? mapState . target === activeEntity . id
113
+ : mapState . target === subEntityId
99
114
const iconName = icon ? icon . icon : null
100
115
const nameWidth = activeComponent === 'stop' || activeComponent === 'route'
101
- ? '130px'
102
- : '170px'
103
- const entityNameStyle = {
104
- width : nameWidth ,
105
- paddingTop : '8px' ,
106
- display : 'inline-block' ,
107
- textOverflow : 'ellipsis' ,
108
- whiteSpace : 'nowrap' ,
109
- overflow : 'hidden'
110
- }
116
+ ? '176px'
117
+ : '210px'
111
118
return (
112
- < div style = { { height : '100px' } } >
113
- < h5 style = { { width : '100%' , marginBottom : '0px' } } >
119
+ < div className = 'entity-details-header' >
120
+ < h5 className = 'entity-details-heading' >
114
121
{ /* Zoom, undo, and save buttons */ }
115
122
< ButtonGroup className = 'pull-right' >
116
123
{ activeComponent === 'stop' || activeComponent === 'route'
117
- ? < OverlayTrigger rootClose placement = 'bottom' overlay = { < Tooltip id = 'tooltip' > Zoom to { activeComponent } </ Tooltip > } >
124
+ ? < OverlayTrigger
125
+ rootClose
126
+ placement = 'bottom'
127
+ overlay = { < Tooltip id = 'tooltip' > Zoom to { activeComponent } </ Tooltip > } >
118
128
< Button
119
129
bsSize = 'small'
120
130
disabled = { zoomDisabled }
@@ -124,62 +134,72 @@ export default class EntityDetailsHeader extends Component {
124
134
</ OverlayTrigger >
125
135
: null
126
136
}
127
- < OverlayTrigger rootClose placement = 'bottom' overlay = { < Tooltip id = 'tooltip' > Undo changes</ Tooltip > } >
137
+ < OverlayTrigger
138
+ rootClose
139
+ placement = 'bottom'
140
+ overlay = { < Tooltip id = 'tooltip' > Undo changes</ Tooltip > } >
128
141
< Button
129
142
bsSize = 'small'
130
143
disabled = { ! entityEdited }
131
144
onClick = { this . _onClickUndo } >
132
145
< Icon type = 'undo' />
133
146
</ Button >
134
147
</ OverlayTrigger >
135
- < OverlayTrigger rootClose placement = 'bottom' overlay = { < Tooltip id = 'tooltip' > Save changes</ Tooltip > } >
148
+ < OverlayTrigger
149
+ rootClose
150
+ placement = 'bottom'
151
+ overlay = { < Tooltip id = 'tooltip' > Save changes</ Tooltip > } >
136
152
< Button
137
153
bsSize = 'small'
138
- disabled = { ! entityEdited || validationErrors . length > 0 }
154
+ disabled = { ! entityEdited || hasErrors }
139
155
onClick = { this . _onClickSave } >
140
156
< Icon type = 'floppy-o' />
141
157
</ Button >
142
158
</ OverlayTrigger >
143
159
</ ButtonGroup >
144
- { /* Entity Icon */ }
145
- < span style = { { position : 'relative' , top : '-4px' } } >
146
- { activeComponent === 'route' && activeEntity
147
- ? < span className = 'fa-stack' >
148
- < Icon type = 'square' style = { { color : `#${ activeEntity . route_color ? activeEntity . route_color : 'fff' } ` } } className = 'fa-stack-2x' />
149
- < Icon type = 'bus' style = { { color : `#${ activeEntity . route_text_color ? activeEntity . route_text_color : '000' } ` } } className = 'fa-stack-1x' />
150
- </ span >
151
- : iconName
152
- ? < span className = 'fa-stack' >
153
- < Icon type = 'square' className = 'fa-stack-2x' />
154
- < Icon type = { iconName } className = 'fa-inverse fa-stack-1x' />
155
- </ span >
156
- // schedule exception icon if no icon found
157
- : < span className = 'fa-stack' >
158
- < Icon type = 'calendar' className = 'fa-stack-1x' />
159
- < Icon type = 'ban' className = 'text-danger fa-stack-2x' />
160
- </ span >
161
- }
162
- </ span >
163
- { ' ' }
164
- { /* Entity name */ }
165
- < span
166
- title = { entityName }
167
- style = { entityNameStyle } >
168
- { entityName }
160
+ < span className = 'entity-details-title' style = { { width : nameWidth } } >
161
+ { /* Entity Icon */ }
162
+ < span style = { { position : 'relative' , top : '-4px' } } >
163
+ { activeComponent === 'route'
164
+ ? < span className = 'fa-stack' >
165
+ < Icon
166
+ type = 'square'
167
+ style = { { color : `#${ activeEntity . route_color || 'fff' } ` } }
168
+ className = 'fa-stack-2x' />
169
+ < Icon
170
+ type = 'bus'
171
+ style = { { color : `#${ activeEntity . route_text_color || '000' } ` } }
172
+ className = 'fa-stack-1x' />
173
+ </ span >
174
+ : iconName
175
+ ? < span className = 'fa-stack' >
176
+ < Icon type = 'square' className = 'fa-stack-2x' />
177
+ < Icon type = { iconName } className = 'fa-inverse fa-stack-1x' />
178
+ </ span >
179
+ // schedule exception icon if no icon found
180
+ : < span className = 'fa-stack' >
181
+ < Icon type = 'calendar' className = 'fa-stack-1x' />
182
+ < Icon type = 'ban' className = 'text-danger fa-stack-2x' />
183
+ </ span >
184
+ }
185
+ </ span >
186
+ { ' ' }
187
+ { /* Entity name */ }
188
+ < span
189
+ title = { entityName }
190
+ className = 'entity-details-name' >
191
+ { entityName }
192
+ </ span >
169
193
</ span >
170
194
</ h5 >
171
- { /* FIXME: check for null feed info needs to be fixed */ }
172
- { ! getTableById ( tableData , activeComponent , false ) && activeComponent === 'feedinfo'
173
- ? < small > Complete feed info to begin editing GTFS.</ small >
174
- : null
175
- }
176
195
{ /* Validation issues */ }
177
196
< p style = { { marginBottom : '2px' } } >
178
197
< small style = { { marginTop : '3px' } } className = 'pull-right' >
179
198
< em className = 'text-muted' > * denotes required field</ em >
180
199
</ small >
181
- < small className = { `${ validationErrors . length > 0 ? ' text-danger' : ' text-success' } ` } >
182
- { validationErrors . length > 0
200
+ < small
201
+ className = { `${ hasErrors ? ' text-danger' : ' text-success' } ` } >
202
+ { hasErrors
183
203
? < span >
184
204
< Icon type = 'times-circle' />
185
205
{ ' ' }
@@ -217,22 +237,22 @@ export default class EntityDetailsHeader extends Component {
217
237
</ OverlayTrigger >
218
238
</ Nav >
219
239
: activeComponent === 'fare'
220
- ? < Nav style = { { marginBottom : '5px' } } bsStyle = 'pills' justified >
221
- < NavItem
222
- eventKey = { 'fare' }
223
- active = { ! editFareRules }
224
- onClick = { this . _showFareAttributes } >
225
- Attributes
226
- </ NavItem >
227
- < NavItem
228
- eventKey = { 'rules' }
229
- disabled = { ! activeEntity || entityIsNew ( activeEntity ) }
230
- active = { editFareRules }
231
- onClick = { this . _showFareRules } >
232
- Rules
233
- </ NavItem >
234
- </ Nav >
235
- : null
240
+ ? < Nav style = { { marginBottom : '5px' } } bsStyle = 'pills' justified >
241
+ < NavItem
242
+ eventKey = { 'fare' }
243
+ active = { ! editFareRules }
244
+ onClick = { this . _showFareAttributes } >
245
+ Attributes
246
+ </ NavItem >
247
+ < NavItem
248
+ eventKey = { 'rules' }
249
+ disabled = { ! activeEntity || entityIsNew ( activeEntity ) }
250
+ active = { editFareRules }
251
+ onClick = { this . _showFareRules } >
252
+ Rules
253
+ </ NavItem >
254
+ </ Nav >
255
+ : null
236
256
}
237
257
</ div >
238
258
)
0 commit comments