@@ -6,10 +6,8 @@ import {createAction, type ActionType} from 'redux-actions'
66
77import { createVoidPayloadAction , secureFetch } from '../../common/actions'
88import { ENTITY } from '../constants'
9- import { newGtfsEntity , fetchBaseGtfs } from './editor'
109import { fetchFeedSourceAndProject } from '../../manager/actions/feeds'
1110import { fetchGTFSEntities } from '../../manager/actions/versions'
12- import { saveTripPattern } from './tripPattern'
1311import {
1412 getEditorNamespace ,
1513 getTableById ,
@@ -18,10 +16,12 @@ import {
1816 subSubComponentList
1917} from '../util/gtfs'
2018import { getMapFromGtfsStrategy , entityIsNew } from '../util/objects'
21-
2219import type { Entity , Feed } from '../../types'
2320import type { dispatchFn , getStateFn , AppState } from '../../types/reducers'
2421
22+ import { saveTripPattern } from './tripPattern'
23+ import { newGtfsEntity , fetchBaseGtfs } from './editor'
24+
2525export const clearGtfsContent = createVoidPayloadAction ( 'CLEAR_GTFSEDITOR_CONTENT' )
2626const receivedNewEntity = createAction (
2727 'RECEIVE_NEW_ENTITY' ,
@@ -331,14 +331,25 @@ export function saveEntity (
331331 return
332332 }
333333 dispatch ( savingActiveGtfsEntity ( ) )
334- const notNew = ! entityIsNew ( entity )
334+ // Add default vals for component
335+ const defaults = { }
336+ if ( component === 'route' ) {
337+ defaults . continuous_pickup = 1 // Default value for no continuous pickup
338+ defaults . continuous_drop_off = 1 // Default value for no continuous drop off
339+ } else if ( component === 'feedinfo' ) {
340+ defaults . default_lang = ''
341+ defaults . feed_contact_url = ''
342+ defaults . feed_contact_email = ''
343+ }
344+ const entityWithDefaults = { ...defaults , ...( entity : any ) } // add defaults, if any.
345+ const notNew = ! entityIsNew ( entityWithDefaults )
335346 const method = notNew ? 'put' : 'post'
336- const idParam = notNew ? `/${ entity . id || '' } ` : ''
347+ const idParam = notNew ? `/${ entityWithDefaults . id || '' } ` : ''
337348 const { sessionId } = getState ( ) . editor . data . lock
338349 const route = component === 'fare' ? 'fareattribute' : component
339350 const url = `/api/editor/secure/${ route } ${ idParam } ?feedId=${ feedId } &sessionId=${ sessionId || '' } `
340351 const mappingStrategy = getMapFromGtfsStrategy ( component )
341- const data = mappingStrategy ( entity )
352+ const data = mappingStrategy ( entityWithDefaults )
342353 return dispatch ( secureFetch ( url , method , data ) )
343354 . then ( res => res . json ( ) )
344355 . then ( savedEntity => {
0 commit comments