-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gtfs: Allow to configure the walking time for stop aggregation
fixes #807 Also fix the node's color, that, if the user's preferences was changed, was not used by default.
- Loading branch information
Showing
5 changed files
with
85 additions
and
12 deletions.
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
59 changes: 59 additions & 0 deletions
59
packages/transition-frontend/src/components/forms/gtfs/GtfsImportNodesComponent.tsx
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2023, Polytechnique Montreal and contributors | ||
* | ||
* This file is licensed under the MIT License. | ||
* License text available at https://opensource.org/licenses/MIT | ||
*/ | ||
import React from 'react'; | ||
import { withTranslation, WithTranslation } from 'react-i18next'; | ||
|
||
import { GtfsImportData } from 'transition-common/lib/services/gtfs/GtfsImportTypes'; | ||
import InputColor from 'chaire-lib-frontend/lib/components/input/InputColor'; | ||
import Preferences from 'chaire-lib-common/lib/config/Preferences'; | ||
import InputWrapper from 'chaire-lib-frontend/lib/components/input/InputWrapper'; | ||
import InputString from 'chaire-lib-frontend/lib/components/input/InputString'; | ||
import { _isBlank } from 'chaire-lib-common/lib/utils/LodashExtensions'; | ||
|
||
export interface GtfsImportServiceComponentProps extends WithTranslation { | ||
id: string; | ||
updateSelectedValue: (path: keyof GtfsImportData, value: string | boolean | number | undefined) => void; | ||
gtfsImportData: GtfsImportData; | ||
} | ||
|
||
const GtfsImportServiceComponent: React.FunctionComponent<GtfsImportServiceComponentProps> = ( | ||
props: GtfsImportServiceComponentProps | ||
) => { | ||
const stopAggregationWalkingTime = props.gtfsImportData.stopAggregationWalkingRadiusSeconds; | ||
|
||
return ( | ||
<React.Fragment> | ||
<InputWrapper | ||
twoColumns={true} | ||
label={props.t('transit:gtfs:StopAggregationWalkingRadiusSeconds')} | ||
help={props.t('transit:gtfs:StopAggregationWalkingRadiusSecondsHelp')} | ||
> | ||
<InputString | ||
id={`formFieldTransitGtfsImporterFileDefaultNodeColor${props.id}`} | ||
value={stopAggregationWalkingTime === undefined ? '' : String(stopAggregationWalkingTime)} | ||
pattern="[0-9]+" | ||
onValueUpdated={({ value }) => | ||
props.updateSelectedValue( | ||
'stopAggregationWalkingRadiusSeconds', | ||
!_isBlank(value) ? parseInt(value) : undefined | ||
) | ||
} | ||
/> | ||
</InputWrapper> | ||
<InputWrapper twoColumns={true} label={props.t('transit:gtfs:DefaultNodeColor')}> | ||
<InputColor | ||
id={`formFieldTransitGtfsImporterFileDefaultNodeColor${props.id}`} | ||
value={props.gtfsImportData.nodes_color} | ||
defaultColor={Preferences.get('transit.nodes.defaultColor', '#0086FF')} | ||
onValueChange={(e) => props.updateSelectedValue('nodes_color', e.target.value)} | ||
/> | ||
</InputWrapper> | ||
</React.Fragment> | ||
); | ||
}; | ||
|
||
export default withTranslation(['transit', 'main'])(GtfsImportServiceComponent); |