@@ -5,7 +5,7 @@ import Select from 'react-select'
55
66import toSentenceCase from '../../common/util/to-sentence-case'
77import ExceptionDate from './ExceptionDate'
8- import { EXEMPLARS } from '../util'
8+ import { EXCEPTION_EXEMPLARS } from '../util'
99import { getTableById } from '../util/gtfs'
1010
1111export default class ScheduleExceptionForm extends Component {
@@ -27,18 +27,18 @@ export default class ScheduleExceptionForm extends Component {
2727 _onAddedServiceChange = ( input ) => {
2828 const { activeComponent, activeEntity, updateActiveEntity} = this . props
2929 const val = input ? input . map ( i => i . value ) : null
30- updateActiveEntity ( activeEntity , activeComponent , { addedService : val } )
30+ updateActiveEntity ( activeEntity , activeComponent , { added_service : val } )
3131 }
3232
3333 _onCustomScheduleChange = ( input ) => {
3434 const { activeComponent, activeEntity, updateActiveEntity} = this . props
3535 const val = input ? input . map ( i => i . value ) : null
36- updateActiveEntity ( activeEntity , activeComponent , { customSchedule : val } )
36+ updateActiveEntity ( activeEntity , activeComponent , { custom_schedule : val } )
3737 }
3838
3939 _onExemplarChange = ( evt ) => {
4040 const { activeComponent, activeEntity, updateActiveEntity} = this . props
41- updateActiveEntity ( activeEntity , activeComponent , { exemplar : evt . target . value , customSchedule : null } )
41+ updateActiveEntity ( activeEntity , activeComponent , { exemplar : + evt . target . value , custom_schedule : null } )
4242 }
4343
4444 _onNameChange = ( evt ) => {
@@ -49,12 +49,12 @@ export default class ScheduleExceptionForm extends Component {
4949 _onRemovedServiceChange = ( input ) => {
5050 const { activeComponent, activeEntity, updateActiveEntity} = this . props
5151 const val = input ? input . map ( i => i . value ) : null
52- updateActiveEntity ( activeEntity , activeComponent , { removedService : val } )
52+ updateActiveEntity ( activeEntity , activeComponent , { removed_service : val } )
5353 }
5454
5555 calendarToOption = calendar => ( {
56- value : calendar . id ,
57- label : calendar . description ,
56+ value : calendar . service_id ,
57+ label : calendar . description || calendar . id ,
5858 calendar
5959 } )
6060
@@ -87,10 +87,10 @@ export default class ScheduleExceptionForm extends Component {
8787 value = { ( activeEntity && activeEntity . exemplar ) || '' }
8888 onChange = { this . _onExemplarChange } >
8989 < option value = '' disabled > -- Select exception type --</ option >
90- { EXEMPLARS . map ( exemplar => {
90+ { Object . keys ( EXCEPTION_EXEMPLARS ) . map ( exemplar => {
9191 return (
92- < option value = { exemplar } key = { exemplar } >
93- { exemplar === ' SWAP'
92+ < option value = { EXCEPTION_EXEMPLARS [ exemplar ] } key = { EXCEPTION_EXEMPLARS [ exemplar ] } >
93+ { exemplar === EXCEPTION_EXEMPLARS . SWAP
9494 ? 'Swap, add, or remove'
9595 : toSentenceCase ( exemplar )
9696 }
@@ -99,7 +99,8 @@ export default class ScheduleExceptionForm extends Component {
9999 } ) }
100100 </ FormControl >
101101 </ FormGroup >
102- { activeEntity && activeEntity . exemplar === 'CUSTOM'
102+ { /* FIXME: This should likely use service_id rather than id */ }
103+ { activeEntity && activeEntity . exemplar === EXCEPTION_EXEMPLARS . CUSTOM
103104 ? < FormGroup
104105 controlId = { `custom` }
105106 className = { `col-xs-12` } >
@@ -108,13 +109,13 @@ export default class ScheduleExceptionForm extends Component {
108109 placeholder = 'Select calendar...'
109110 clearable
110111 multi
111- value = { activeEntity && activeEntity . customSchedule }
112+ value = { activeEntity && activeEntity . custom_schedule }
112113 onChange = { this . _onCustomScheduleChange }
113114 options = { calendars . map ( this . calendarToOption ) } />
114115 </ FormGroup >
115116 : null
116117 }
117- { activeEntity && activeEntity . exemplar === ' SWAP'
118+ { activeEntity && activeEntity . exemplar === EXCEPTION_EXEMPLARS . SWAP
118119 ? < FormGroup
119120 controlId = { `custom` }
120121 className = { `col-xs-12` } >
@@ -123,21 +124,21 @@ export default class ScheduleExceptionForm extends Component {
123124 placeholder = 'Select calendar...'
124125 clearable
125126 multi
126- value = { activeEntity && activeEntity . addedService }
127+ value = { activeEntity && activeEntity . added_service }
127128 onChange = { this . _onAddedServiceChange }
128129 options = { calendars
129- . filter ( cal => ! activeEntity . removedService || activeEntity . removedService . indexOf ( cal . id ) === - 1 )
130+ . filter ( cal => ! activeEntity . removed_service || activeEntity . removed_service . indexOf ( cal . id ) === - 1 )
130131 . map ( this . calendarToOption )
131132 } />
132133 < ControlLabel > < small > Select calendars to remove (optional):</ small > </ ControlLabel >
133134 < Select
134135 placeholder = 'Select calendar...'
135136 clearable
136137 multi
137- value = { activeEntity && activeEntity . removedService }
138+ value = { activeEntity && activeEntity . removed_service }
138139 onChange = { this . _onRemovedServiceChange }
139140 options = { calendars
140- . filter ( cal => ! activeEntity . addedService || activeEntity . addedService . indexOf ( cal . id ) === - 1 )
141+ . filter ( cal => ! activeEntity . added_service || activeEntity . added_service . indexOf ( cal . id ) === - 1 )
141142 . map ( this . calendarToOption )
142143 } />
143144 </ FormGroup >
@@ -148,7 +149,7 @@ export default class ScheduleExceptionForm extends Component {
148149 validationState = { validationErrors . find ( e => e . field === 'dates' ) ? 'error' : undefined }
149150 className = { `col-xs-12` } >
150151 < ControlLabel > < small > On these dates*</ small > </ ControlLabel >
151- { activeEntity && activeEntity . dates . length
152+ { activeEntity && activeEntity . dates && activeEntity . dates . length
152153 ? activeEntity . dates . map ( ( date , index ) => (
153154 < ExceptionDate
154155 index = { index }
0 commit comments