11import React , { Component , PropTypes } from 'react'
2- import { Button , Nav , NavItem } from 'react-bootstrap'
2+ import { Button } from 'react-bootstrap'
33import { Icon } from '@conveyal/woonerf'
44import { Table , Column } from 'react-virtualized'
55import { shallowEqual } from 'react-pure-render'
66
7- import VirtualizedEntitySelect from './VirtualizedEntitySelect'
87import EntityListButtons from './EntityListButtons'
8+ import EntityListSecondaryActions from './EntityListSecondaryActions'
99import { getEntityName } from '../util/gtfs'
1010
1111export default class EntityList extends Component {
@@ -126,8 +126,19 @@ export default class EntityList extends Component {
126126 //
127127 // }
128128 render ( ) {
129+ const {
130+ tableView,
131+ width,
132+ activeEntity,
133+ activeComponent,
134+ hasRoutes,
135+ feedSource,
136+ entities,
137+ newGtfsEntity,
138+ enterTimetableEditor
139+ } = this . props
129140 const sidePadding = '5px'
130- const panelWidth = ! this . props . tableView ? `${ this . props . width } px` : '100%'
141+ const panelWidth = ! tableView ? `${ width } px` : '100%'
131142 const panelStyle = {
132143 width : panelWidth ,
133144 height : '100%' ,
@@ -138,17 +149,15 @@ export default class EntityList extends Component {
138149 paddingRight : '0px' ,
139150 paddingLeft : sidePadding
140151 }
141- const entArray = this . props . entities
142- const activeEntity = this . props . activeEntity
143152 let activeIndex
144- const list = entArray && entArray . length
145- ? entArray . map ( ( entity , index ) => {
153+ const list = entities && entities . length
154+ ? entities . map ( ( entity , index ) => {
146155 if ( activeEntity && entity . id === activeEntity . id ) {
147156 activeIndex = index
148157 }
149158 const isActive = activeEntity && entity . id === activeEntity . id
150159 const isSelected = typeof this . state . fromIndex !== 'undefined' && typeof this . state . toIndex !== 'undefined' && index >= this . state . fromIndex && index <= this . state . toIndex
151- const name = getEntityName ( this . props . activeComponent , entity ) || '[Unnamed]'
160+ const name = getEntityName ( activeComponent , entity ) || '[Unnamed]'
152161 return { name, id : entity . id , isActive, isSelected}
153162 }
154163 )
@@ -163,9 +172,9 @@ export default class EntityList extends Component {
163172 style = { { outline : 'none' } }
164173 >
165174 < Table
166- width = { this . props . width - 5 }
175+ width = { width - 5 }
167176 height = { 560 }
168- key = { `${ this . props . feedSource . id } -${ this . props . activeComponent } -table` }
177+ key = { `${ feedSource . id } -${ activeComponent } -table` }
169178 disableHeader
170179 headerHeight = { 20 }
171180 rowHeight = { 25 }
@@ -186,19 +195,19 @@ export default class EntityList extends Component {
186195 dataKey = 'name'
187196 className = 'small entity-list-row'
188197 style = { { outline : 'none' } }
189- width = { this . props . width - 5 }
198+ width = { width - 5 }
190199 />
191200 </ Table >
192201 </ div >
193202 : < div style = { { marginTop : '20px' } } className = 'text-center' >
194203 < Button
195204 bsSize = 'small'
196- disabled = { this . props . entities && this . props . entities . findIndex ( e => e . id === 'new' ) !== - 1 }
205+ disabled = { entities && entities . findIndex ( e => e . id === 'new' ) !== - 1 }
197206 onClick = { ( ) => {
198- this . props . newGtfsEntity ( this . props . feedSource . id , this . props . activeComponent )
207+ newGtfsEntity ( feedSource . id , activeComponent )
199208 } }
200209 >
201- < Icon type = 'plus' /> Create first { this . props . activeComponent === 'scheduleexception' ? 'exception' : this . props . activeComponent }
210+ < Icon type = 'plus' /> Create first { activeComponent === 'scheduleexception' ? 'exception' : activeComponent }
202211 </ Button >
203212 </ div >
204213 return (
@@ -213,50 +222,21 @@ export default class EntityList extends Component {
213222 updateIndexes = { this . updateIndexes }
214223 { ...this . props }
215224 />
225+ { activeComponent === 'calendar' || activeComponent === 'scheduleexception'
226+ ? < Button
227+ style = { { marginTop : '10px' } }
228+ block
229+ disabled = { ! hasRoutes }
230+ onClick = { ( ) => enterTimetableEditor ( ) }
231+ >
232+ < Icon type = 'pencil' /> Edit schedules
233+ </ Button >
234+ : null
235+ }
216236 { /* Table view button */ }
217237 </ div >
218- { this . props . activeComponent === 'calendar' || this . props . activeComponent === 'scheduleexception'
219- ? < Nav style = { { marginBottom : '5px' } } bsStyle = 'pills' justified activeKey = { this . props . activeComponent } onSelect = { this . handleSelect } >
220- < NavItem
221- eventKey = { 'calendar' }
222- onClick = { ( ) => {
223- if ( this . props . activeComponent !== 'calendar' ) {
224- // browserHistory.push(`/feed/${this.props.feedSource.id}/edit/calendar`)
225- this . props . setActiveEntity ( this . props . feedSource . id , 'calendar' )
226- }
227- } }
228- >
229- Calendars
230- </ NavItem >
231- < NavItem
232- eventKey = { 'scheduleexception' }
233- onClick = { ( ) => {
234- if ( this . props . activeComponent !== 'scheduleexception' ) {
235- // browserHistory.push(`/feed/${this.props.feedSource.id}/edit/scheduleexception`)
236- this . props . setActiveEntity ( this . props . feedSource . id , 'scheduleexception' )
237- }
238- } }
239- >
240- Exceptions
241- </ NavItem >
242- </ Nav >
243- : this . props . activeComponent === 'stop' || this . props . activeComponent === 'route'
244- ? < VirtualizedEntitySelect
245- value = { this . props . activeEntity && this . props . activeEntity . id }
246- optionRenderer = { this . _optionRenderer }
247- component = { this . props . activeComponent }
248- entities = { entArray }
249- onChange = { ( value ) => {
250- if ( ! value ) {
251- this . props . setActiveEntity ( this . props . feedSource . id , this . props . activeComponent )
252- } else {
253- this . props . setActiveEntity ( this . props . feedSource . id , this . props . activeComponent , value . entity )
254- }
255- } }
256- />
257- : null
258- }
259- { ! this . props . tableView
238+ < EntityListSecondaryActions { ...this . props } />
239+ { ! tableView
260240 ? entityList
261241 : null // GtfsTable fully removed from repo, last available at fe29528569f5f64c23a49d2af0bd224f3d63d010
262242 }
0 commit comments