1
1
import React , { Component , PropTypes } from 'react'
2
- import { Button , Nav , NavItem } from 'react-bootstrap'
2
+ import { Button } from 'react-bootstrap'
3
3
import { Icon } from '@conveyal/woonerf'
4
4
import { Table , Column } from 'react-virtualized'
5
5
import { shallowEqual } from 'react-pure-render'
6
6
7
- import VirtualizedEntitySelect from './VirtualizedEntitySelect'
8
7
import EntityListButtons from './EntityListButtons'
8
+ import EntityListSecondaryActions from './EntityListSecondaryActions'
9
9
import { getEntityName } from '../util/gtfs'
10
10
11
11
export default class EntityList extends Component {
@@ -126,8 +126,19 @@ export default class EntityList extends Component {
126
126
//
127
127
// }
128
128
render ( ) {
129
+ const {
130
+ tableView,
131
+ width,
132
+ activeEntity,
133
+ activeComponent,
134
+ hasRoutes,
135
+ feedSource,
136
+ entities,
137
+ newGtfsEntity,
138
+ enterTimetableEditor
139
+ } = this . props
129
140
const sidePadding = '5px'
130
- const panelWidth = ! this . props . tableView ? `${ this . props . width } px` : '100%'
141
+ const panelWidth = ! tableView ? `${ width } px` : '100%'
131
142
const panelStyle = {
132
143
width : panelWidth ,
133
144
height : '100%' ,
@@ -138,17 +149,15 @@ export default class EntityList extends Component {
138
149
paddingRight : '0px' ,
139
150
paddingLeft : sidePadding
140
151
}
141
- const entArray = this . props . entities
142
- const activeEntity = this . props . activeEntity
143
152
let activeIndex
144
- const list = entArray && entArray . length
145
- ? entArray . map ( ( entity , index ) => {
153
+ const list = entities && entities . length
154
+ ? entities . map ( ( entity , index ) => {
146
155
if ( activeEntity && entity . id === activeEntity . id ) {
147
156
activeIndex = index
148
157
}
149
158
const isActive = activeEntity && entity . id === activeEntity . id
150
159
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]'
152
161
return { name, id : entity . id , isActive, isSelected}
153
162
}
154
163
)
@@ -163,9 +172,9 @@ export default class EntityList extends Component {
163
172
style = { { outline : 'none' } }
164
173
>
165
174
< Table
166
- width = { this . props . width - 5 }
175
+ width = { width - 5 }
167
176
height = { 560 }
168
- key = { `${ this . props . feedSource . id } -${ this . props . activeComponent } -table` }
177
+ key = { `${ feedSource . id } -${ activeComponent } -table` }
169
178
disableHeader
170
179
headerHeight = { 20 }
171
180
rowHeight = { 25 }
@@ -186,19 +195,19 @@ export default class EntityList extends Component {
186
195
dataKey = 'name'
187
196
className = 'small entity-list-row'
188
197
style = { { outline : 'none' } }
189
- width = { this . props . width - 5 }
198
+ width = { width - 5 }
190
199
/>
191
200
</ Table >
192
201
</ div >
193
202
: < div style = { { marginTop : '20px' } } className = 'text-center' >
194
203
< Button
195
204
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 }
197
206
onClick = { ( ) => {
198
- this . props . newGtfsEntity ( this . props . feedSource . id , this . props . activeComponent )
207
+ newGtfsEntity ( feedSource . id , activeComponent )
199
208
} }
200
209
>
201
- < Icon type = 'plus' /> Create first { this . props . activeComponent === 'scheduleexception' ? 'exception' : this . props . activeComponent }
210
+ < Icon type = 'plus' /> Create first { activeComponent === 'scheduleexception' ? 'exception' : activeComponent }
202
211
</ Button >
203
212
</ div >
204
213
return (
@@ -213,50 +222,21 @@ export default class EntityList extends Component {
213
222
updateIndexes = { this . updateIndexes }
214
223
{ ...this . props }
215
224
/>
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
+ }
216
236
{ /* Table view button */ }
217
237
</ 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
260
240
? entityList
261
241
: null // GtfsTable fully removed from repo, last available at fe29528569f5f64c23a49d2af0bd224f3d63d010
262
242
}
0 commit comments