11import React , { Component , PropTypes } from 'react'
2- import { Grid , Row , Col , Button , Glyphicon , PageHeader } from 'react-bootstrap'
2+ import { Grid , Row , Col , Button , Glyphicon , PageHeader } from 'react-bootstrap'
33import JSZip from 'jszip'
44import { Link } from 'react-router'
55
@@ -20,15 +20,14 @@ export default class GtfsPlusEditor extends Component {
2020 newRowClicked : PropTypes . func ,
2121 onComponentMount : PropTypes . func ,
2222 project : PropTypes . object ,
23+ setActiveTable : PropTypes . func ,
24+ setCurrentPage : PropTypes . func ,
25+ setVisibilityFilter : PropTypes . func ,
2326 tableData : PropTypes . object ,
2427 user : PropTypes . object ,
2528 validation : PropTypes . object
2629 }
2730
28- state = {
29- activeTableId : 'realtime_routes'
30- }
31-
3231 componentWillMount ( ) {
3332 this . props . onComponentMount ( this . props )
3433 }
@@ -66,11 +65,11 @@ export default class GtfsPlusEditor extends Component {
6665 _gtfsEntitySelected = ( type , entity ) => this . props . gtfsEntitySelected ( type , entity )
6766
6867 _newRowsDisplayed = ( rows ) => {
69- const { feedSource, feedVersionId, loadGtfsEntities} = this . props
70- loadGtfsEntities ( this . state . activeTableId , rows , feedSource , feedVersionId )
68+ const { activeTableId , feedSource, feedVersionId, loadGtfsEntities} = this . props
69+ loadGtfsEntities ( activeTableId , rows , feedSource , feedVersionId )
7170 }
7271
73- _selectTable = ( activeTableId ) => this . setState ( { activeTableId} )
72+ _selectTable = ( activeTableId ) => this . props . setActiveTable ( { activeTableId} )
7473
7574 _showHelpClicked = ( tableId , fieldName ) => {
7675 const helpContent = fieldName
@@ -87,23 +86,25 @@ export default class GtfsPlusEditor extends Component {
8786
8887 render ( ) {
8988 const {
89+ activeTableId,
9090 feedSource,
91- deleteRowClicked,
92- fieldEdited,
93- newRowClicked,
9491 project,
9592 tableData,
9693 user,
97- validation
94+ validation,
95+ visibleRows
9896 } = this . props
9997 if ( ! feedSource ) return null
10098 const editingIsDisabled = ! user . permissions . hasFeedPermission ( feedSource . organizationId , feedSource . projectId , feedSource . id , 'edit-gtfs' )
10199 const buttonStyle = {
102100 display : 'block' ,
103- width : '100%'
101+ width : '100%' ,
102+ overflow : 'hidden' ,
103+ textOverflow : 'ellipsis' ,
104+ whiteSpace : 'nowrap'
104105 }
105106
106- const activeTable = getConfigProperty ( 'modules.gtfsplus.spec' ) . find ( t => t . id === this . state . activeTableId )
107+ const activeTable = getConfigProperty ( 'modules.gtfsplus.spec' ) . find ( t => t . id === activeTableId )
107108
108109 return (
109110 < ManagerPage ref = 'page' >
@@ -137,11 +138,16 @@ export default class GtfsPlusEditor extends Component {
137138 < Row >
138139 < Col xs = { 2 } >
139140 { getConfigProperty ( 'modules.gtfsplus.spec' ) . map ( ( table , index ) => {
141+ const tableLength = tableData [ table . id ] && tableData [ table . id ] . length
140142 return ( < p key = { index } >
141143 < OptionButton
142- bsStyle = { table . id === this . state . activeTableId ? 'info' : 'default' }
144+ active = { table . id === activeTableId }
143145 key = { table . id }
144- style = { buttonStyle }
146+ style = { {
147+ color : tableLength ? 'black' : 'grey' ,
148+ ...buttonStyle
149+ } }
150+ title = { table . id }
145151 value = { table . id }
146152 onClick = { this . _selectTable } >
147153 { validation && ( table . id in validation )
@@ -155,14 +161,11 @@ export default class GtfsPlusEditor extends Component {
155161 </ Col >
156162 < Col xs = { 10 } >
157163 < GtfsPlusTable
164+ { ...this . props }
158165 ref = 'activeTable'
159- feedSource = { feedSource }
160166 table = { activeTable }
161- tableData = { tableData [ activeTable . id ] }
162- validation = { validation [ activeTable . id ] }
163- newRowClicked = { newRowClicked }
164- deleteRowClicked = { deleteRowClicked }
165- fieldEdited = { fieldEdited }
167+ rows = { visibleRows }
168+ validation = { validation [ activeTable . id ] || [ ] }
166169 gtfsEntitySelected = { this . _gtfsEntitySelected }
167170 getGtfsEntity = { this . _getGtfsEntity }
168171 showHelpClicked = { this . _showHelpClicked }
0 commit comments