Skip to content

Commit b6f2a91

Browse files
address pr feedback
1 parent 04ffe0b commit b6f2a91

10 files changed

+27
-23
lines changed

lib/editor/actions/location.js

+9-8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import type {GtfsLocation} from '../../types'
88

99
import { receivedNewEntity, savedGtfsEntity } from './active'
1010

11+
// FLEX TODO: The two big dispatch blocks are almost the same... Would it be possible to extract them (such as saveEntity('locationgroup', locationGroupUrl) and same for locationgroupstop)?
1112
export function saveLocationGroup (
1213
feedId: ?string,
1314
locationGroup: GtfsLocation,
@@ -38,11 +39,11 @@ export function saveLocationGroup (
3839
// Refetch entity and replace in store
3940
if (refetch) {
4041
dispatch(fetchGTFSEntities({
41-
namespace,
42-
id: savedEntity.id,
43-
type: 'locationgroupstop',
4442
editor: true,
45-
replaceNew: !notNew
43+
id: savedEntity.id,
44+
namespace,
45+
replaceNew: !notNew,
46+
type: 'locationgroupstop'
4647
}))
4748
} else {
4849
// Push new entity into store.
@@ -57,11 +58,11 @@ export function saveLocationGroup (
5758
// Refetch entity and replace in store
5859
if (refetch) {
5960
dispatch(fetchGTFSEntities({
60-
namespace,
61-
id: savedEntity.id,
62-
type: 'locationgroup',
6361
editor: true,
64-
replaceNew: !notNew
62+
id: savedEntity.id,
63+
namespace,
64+
replaceNew: !notNew,
65+
type: 'locationgroup'
6566
}))
6667
} else {
6768
// Push new entity into store.

lib/editor/actions/map/stopStrategies.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,10 @@ export function addStopToPattern (pattern: Pattern, origStop: GtfsStop | GtfsLoc
253253

254254
// find center to simulate stop
255255
const center = centerOfMass(turfPolygon([polygon]))
256-
if (center.geometry.coordinates) {
257-
stop.stop_lon = center.geometry.coordinates[1]
258-
stop.stop_lat = center.geometry.coordinates[0]
256+
const {coordinates} = center.geometry ? center.geometry : {coordinates: false}
257+
if (coordinates) {
258+
stop.stop_lon = coordinates[1]
259+
stop.stop_lat = coordinates[0]
259260
}
260261
}
261262

@@ -300,6 +301,7 @@ export function addStopToPattern (pattern: Pattern, origStop: GtfsStop | GtfsLoc
300301
dispatch(updatePatternStops(pattern, patternStops))
301302
// Only a stop should be checked, not a location
302303
// Otherwise, check if a shape ought to be created. Then, save.
304+
// FLEX TODO: Is this working? Why 2?
303305
if (patternStops.length === 2 && followStreets) {
304306
// Create shape between stops the added stop is the second one and
305307
// followStreets is enabled. Otherwise, there is no need to create a

lib/editor/components/map/PatternStopsLayer.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ export default class PatternStopsLayer extends Component<Props> {
116116
}
117117
removeStopFromPattern={removeStopFromPattern}
118118
stop={stop}
119-
patternStop={patternStop} />
119+
patternStop={patternStop}
120+
/>
120121
)
121122
}
122123
if (location) {
@@ -131,6 +132,7 @@ export default class PatternStopsLayer extends Component<Props> {
131132
key={patternStop.id}
132133
location={location}
133134
setActiveStop={setActiveStop}
135+
// FLEX TODO: do we need these fallbacks? We might not.
134136
// fallback to index if/when id changes
135137
// $FlowFixMe
136138
ref={`${patternStop.id || patternStop.locationId || patternStop.locationGroupId}`}
@@ -139,7 +141,7 @@ export default class PatternStopsLayer extends Component<Props> {
139141
patternStop={patternStop} />
140142
}
141143
if (locationGroup) {
142-
// 2024 TODO: support rendering location groups. will be tricky. need to
144+
// FLEX TODO: support rendering location groups. will be tricky. need to
143145
// grab location group stop data
144146
return <></>
145147
}

lib/editor/components/pattern/EditShapePanel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ export default class EditShapePanel extends Component<Props> {
124124
saveActiveGtfsEntity,
125125
showConfirmModal,
126126
stops,
127-
locations, locationGroups,
127+
locations,
128+
locationGroups,
128129
updateActiveGtfsEntity,
129130
updatePatternGeometry
130131
} = this.props

lib/editor/components/pattern/PatternStopCard.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ class PatternStopCard extends Component<Props> {
242242
if (patternStop.locationId !== null || patternStop.locationGroupId !== null) {
243243
cardBackground = 'hsla(187, 84%, 87%, 0.5)'
244244
}
245-
// $FlowFixMe flexDefaultTravelTime doens't exist on a PatternStop, which is the point of this check
245+
// $FlowFixMe flexDefaultTravelTime doesn't exist on a PatternStop, which is the point of this check
246246
if ((!patternStop.defaultTravelTime && !patternStop.flexDefaultTravelTime) && index !== 0) {
247247
cardBackground = 'hsla(35, 84%, 87%, 1)'
248248
}

lib/editor/components/pattern/PatternStopContainer.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,18 @@ class PatternStopContainer extends Component<Props, State> {
137137
let stop = false
138138
if (card.stopId !== null) {
139139
stop = stops.find(st => st.stop_id === card.stopId)
140-
cumulativeTravelTime += card.defaultDwellTime + card.defaultTravelTime
141140
}
142141
// Since stops and locations are unified, the stop could also refer to a location
143142
// IDs exist in one namespace as per the spac
144143
if (card.locationId !== null) {
145144
stop = locations.find(l => l.location_id === card.locationId)
146-
cumulativeTravelTime += card.defaultDwellTime + card.defaultTravelTime
147145
}
148146
if (card.locationGroupId !== null) {
149147
stop = locationGroups.find(lg => lg.location_group_id === card.locationGroupId)
150-
cumulativeTravelTime += card.defaultDwellTime + card.defaultTravelTime
151148
}
152149

150+
cumulativeTravelTime += card.defaultDwellTime + card.defaultTravelTime
151+
153152
return (
154153
// $FlowFixMe
155154
<PatternStopCard

lib/editor/components/pattern/TripPatternViewer.js

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export default class TripPatternViewer extends Component<Props> {
3939
activePattern.patternStops = activePattern.patternStops.map((ps) => {
4040
return {
4141
...ps,
42+
// FLEX TODO: can we use || here?
4243
id: `${
4344
ps.stopId
4445
? ps.stopId

lib/editor/components/timetable/TimetableEditor.js

-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ export default class TimetableEditor extends Component<Props, State> {
199199
objectPath.set(newRow, `stopTimes.${i}`, blankStopTime)
200200
}
201201

202-
// objectPath.set(newRow, `stopTimes.${i}.stopId`, halt.stopId !== null ? halt.stopId : halt.locationId !== null ? halt.locationId : halt.locationGroupId)
203-
204202
// only set time if timepoint set to true or null
205203
// if (stop.timepoint === null || stop.timepoint) {
206204
if (halt.stopId !== null) {

lib/editor/selectors/timetable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const getTimetableColumns = createSelector(
6868
if (stops && !isLocation) stop = stops.find(st => st.stop_id === ps.stopId)
6969
if (locations && isLocation) stop = locations.find(l => l.location_id === ps.locationId)
7070

71-
// 2024 todo: fix location group names here?
71+
// FLEX todo: fix location group names here?
7272
const stopName = stop ? stop.stop_name : ps.stopId ? ps.stopId : (ps.locationId ? ps.locationId : ps.locationGroupId)
7373
const stopId = stop && stop.stop_code
7474
? stop.stop_code

lib/editor/util/map.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,8 @@ export function stopToPatternStop (
819819
throw new Error('Stop Id not set')
820820
}
821821
return {
822-
continuousDropOff: 1, // 1?
823-
continuousPickup: 1, // 1?
822+
continuousDropOff: 1, // FLEX TODO: Is 1 correct?
823+
continuousPickup: 1, // FLEX TODO: 1 Is 1 correct?
824824
defaultDwellTime: 0,
825825
defaultTravelTime: 0,
826826
dropOffBookingRuleId: null,

0 commit comments

Comments
 (0)