Skip to content

Commit

Permalink
fix(pattern-editor): add missing shape ID to pattern on save
Browse files Browse the repository at this point in the history
fixes #208
  • Loading branch information
landonreed committed Jul 10, 2018
1 parent 45c14d8 commit 1f5ccfa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/editor/actions/tripPattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {createAction} from 'redux-actions'
import {snakeCaseKeys} from '../../common/util/map-keys'

import {secureFetch} from '../../common/actions'
import {generateUID} from '../../common/util/util'
import {fetchGTFSEntities} from '../../manager/actions/versions'
import {resetActiveGtfsEntity, savedGtfsEntity, updateActiveGtfsEntity, updateEditSetting} from './active'
import {fetchTripCounts} from './trip'
Expand Down Expand Up @@ -74,6 +75,13 @@ export function saveTripPattern (feedId, tripPattern) {
// NOTE: This must be applied before snake case-ing (because
// resequenceShapePoints updates the camelCase field shapePtSequence).
tripPattern.patternStops = tripPattern.patternStops.map(resequenceStops)
if (!tripPattern.shapeId) {
// If trip pattern has no shape ID (e.g., if the pattern was imported
// without shapes), generate one and assign shape points to the new ID.
const shapeId = generateUID()
tripPattern.shapeId = shapeId
tripPattern.shapePoints = tripPattern.shapePoints.map(sp => ({...sp, shapeId}))
}
tripPattern.shapePoints = tripPattern.shapePoints.map(resequenceShapePoints)
const data = snakeCaseKeys(tripPattern)
// Shape points must be assigned to shapes field in order to match back end
Expand Down

0 comments on commit 1f5ccfa

Please sign in to comment.