@@ -2,7 +2,7 @@ import Icon from '@conveyal/woonerf/components/icon'
22import React , { Component , PropTypes } from 'react'
33import { Badge , Button , ButtonGroup , Tooltip , OverlayTrigger , Nav , NavItem } from 'react-bootstrap'
44
5- import { getEntityBounds , getEntityName , getTableById } from '../util/gtfs'
5+ import { getEntityBounds , getEntityName } from '../util/gtfs'
66import { entityIsNew } from '../util/objects'
77import { GTFS_ICONS } from '../util/ui'
88
@@ -20,7 +20,6 @@ export default class EntityDetailsHeader extends Component {
2020 setActiveEntity : PropTypes . func ,
2121 subEntity : PropTypes . number ,
2222 subComponent : PropTypes . string ,
23- tableData : PropTypes . object ,
2423 toggleEditFareRules : PropTypes . func ,
2524 updateMapSetting : PropTypes . func ,
2625 validationErrors : PropTypes . array
@@ -61,14 +60,26 @@ export default class EntityDetailsHeader extends Component {
6160 _showFareRules = ( ) => this . props . toggleEditFareRules ( true )
6261
6362 _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
6570 if ( subComponent === 'trippattern' ) {
6671 setActiveEntity ( feedSource . id , activeComponent , activeEntity )
6772 }
6873 }
6974
7075 _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
7283 if ( subComponent !== 'trippattern' ) {
7384 setActiveEntity ( feedSource . id , activeComponent , activeEntity , 'trippattern' )
7485 }
@@ -83,7 +94,6 @@ export default class EntityDetailsHeader extends Component {
8394 mapState,
8495 subComponent,
8596 subEntityId,
86- tableData,
8797 validationErrors
8898 } = this . props
8999 const validationTooltip = (
@@ -93,28 +103,28 @@ export default class EntityDetailsHeader extends Component {
93103 ) ) }
94104 </ Tooltip >
95105 )
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 )
97110 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
99114 const iconName = icon ? icon . icon : null
100115 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'
111118 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' >
114121 { /* Zoom, undo, and save buttons */ }
115122 < ButtonGroup className = 'pull-right' >
116123 { 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 > } >
118128 < Button
119129 bsSize = 'small'
120130 disabled = { zoomDisabled }
@@ -124,62 +134,72 @@ export default class EntityDetailsHeader extends Component {
124134 </ OverlayTrigger >
125135 : null
126136 }
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 > } >
128141 < Button
129142 bsSize = 'small'
130143 disabled = { ! entityEdited }
131144 onClick = { this . _onClickUndo } >
132145 < Icon type = 'undo' />
133146 </ Button >
134147 </ 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 > } >
136152 < Button
137153 bsSize = 'small'
138- disabled = { ! entityEdited || validationErrors . length > 0 }
154+ disabled = { ! entityEdited || hasErrors }
139155 onClick = { this . _onClickSave } >
140156 < Icon type = 'floppy-o' />
141157 </ Button >
142158 </ OverlayTrigger >
143159 </ 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 >
169193 </ span >
170194 </ 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- }
176195 { /* Validation issues */ }
177196 < p style = { { marginBottom : '2px' } } >
178197 < small style = { { marginTop : '3px' } } className = 'pull-right' >
179198 < em className = 'text-muted' > * denotes required field</ em >
180199 </ 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
183203 ? < span >
184204 < Icon type = 'times-circle' />
185205 { ' ' }
@@ -217,22 +237,22 @@ export default class EntityDetailsHeader extends Component {
217237 </ OverlayTrigger >
218238 </ Nav >
219239 : 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
236256 }
237257 </ div >
238258 )
0 commit comments