-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Location Groups July 2024 #1017
Open
miles-grant-ibigroup
wants to merge
23
commits into
dev-flex-2024
Choose a base branch
from
pattern-location-groups-july-2024
base: dev-flex-2024
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
aabc35b
resolve schema update crashes
miles-grant-ibigroup fc342df
match server data structure
miles-grant-ibigroup de5f50d
clean up pattern card
miles-grant-ibigroup c54b3a2
first attempt at implementing new location groups
miles-grant-ibigroup 95b1fb9
Merge branch 'dev-flex-2024' into location-group-may-2024
miles-grant-ibigroup a930f56
fix: define and document MAP_BASE_URL to prevent gray maps
Aletor93 10d4ff4
remove unitary `stop_id`, re-unite patternStops
miles-grant-ibigroup a0800cd
lint
miles-grant-ibigroup a0e16c2
fix pattern stop adding
miles-grant-ibigroup d8d8ef5
fix pattern stop location map rendering
miles-grant-ibigroup d731c34
fix: comment default MAP_BASE_URL
Aletor93 f256f0f
Merge pull request #1016 from Aletor93/fix-mapbox-gray-maps
miles-grant-ibigroup bf947a6
correctly label stops/locations
miles-grant-ibigroup 6fa434f
fix pattern stop reordering
miles-grant-ibigroup 71b16ea
correctly handle adding non-stops to pattern
miles-grant-ibigroup 9ff7ee9
correct stopStrategies patternStop pushing
miles-grant-ibigroup 2c78875
send `pattern_id` along with every pattern stop
miles-grant-ibigroup 0c34d0d
Merge branch 'dev' into pattern-location-groups-july-2024
miles-grant-ibigroup e5ec45b
inital flow type fixes
daniel-heppner-ibigroup b705a1a
correct flow issues (non location group)
miles-grant-ibigroup ee6429c
fix tests
miles-grant-ibigroup 4dae31a
use new `GtfsLocation` where previously `GtfsLocationGroup` was used
miles-grant-ibigroup 04ffe0b
add missing polish
miles-grant-ibigroup File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,70 @@ import type {GtfsLocation} from '../../types' | |
|
||
import { receivedNewEntity, savedGtfsEntity } from './active' | ||
|
||
export function saveLocationGroup ( | ||
feedId: ?string, | ||
locationGroup: GtfsLocation, | ||
refetch: ?boolean = true | ||
) { | ||
return function (dispatch: dispatchFn, getState: getStateFn) { | ||
if (!feedId || !locationGroup) { | ||
return | ||
} | ||
// dispatch(savingActiveLocation()) //Update this? | ||
|
||
const notNew = !entityIsNew(locationGroup) // Checks if id is -2 or undefined | ||
const method = notNew ? 'put' : 'post' | ||
const idParam = notNew ? `/${locationGroup.id || ''}` : '' | ||
const {sessionId} = getState().editor.data.lock | ||
|
||
const mappingStrategy = getMapFromGtfsStrategy('locationGroup') | ||
const data = mappingStrategy(locationGroup) | ||
|
||
const locationGroupUrl = `/api/editor/secure/locationgroup${idParam}?feedId=${feedId}&sessionId=${sessionId || ''}` | ||
const locationGroupStopsUrl = `/api/editor/secure/locationgroupstop${idParam}?feedId=${feedId}&sessionId=${sessionId || ''}` | ||
|
||
dispatch(secureFetch(locationGroupStopsUrl, method, data)) | ||
.then(res => res.json()) | ||
.then(savedEntity => { | ||
dispatch(savedGtfsEntity()) | ||
const namespace = getEditorNamespace(feedId, getState()) | ||
// Refetch entity and replace in store | ||
if (refetch) { | ||
dispatch(fetchGTFSEntities({ | ||
namespace, | ||
id: savedEntity.id, | ||
type: 'locationgroupstop', | ||
editor: true, | ||
replaceNew: !notNew | ||
})) | ||
} else { | ||
// Push new entity into store. | ||
dispatch(receivedNewEntity({component: 'locationgroupstop', entity: savedEntity})) | ||
} | ||
}) | ||
return dispatch(secureFetch(locationGroupUrl, method, data)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The two big dispatch blocks are almost the same... Would it be possible to extract them (such as |
||
.then(res => res.json()) | ||
.then(savedEntity => { | ||
dispatch(savedGtfsEntity()) | ||
const namespace = getEditorNamespace(feedId, getState()) | ||
// Refetch entity and replace in store | ||
if (refetch) { | ||
dispatch(fetchGTFSEntities({ | ||
namespace, | ||
id: savedEntity.id, | ||
type: 'locationgroup', | ||
editor: true, | ||
replaceNew: !notNew | ||
})) | ||
} else { | ||
// Push new entity into store. | ||
dispatch(receivedNewEntity({component: 'locationgroup', entity: savedEntity})) | ||
Promise.resolve(savedEntity) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
export function saveLocation ( | ||
feedId: ?string, | ||
location: GtfsLocation, | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sort attributes (2 instances)