Skip to content
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

Improve mode setting value casting, remove "default" mode settings #647

Merged
merged 36 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
ab88ac4
fix(core-utils): add walk speed to query
daniel-heppner-ibigroup Aug 9, 2023
a492b1e
chore: update yarn lock
daniel-heppner-ibigroup Aug 9, 2023
abf72a5
Merge branch 'master' into walk-speed
daniel-heppner-ibigroup Aug 9, 2023
c425164
fix(types): add typeOverride property to modesettingbase
daniel-heppner-ibigroup Aug 9, 2023
7a016d6
fix(trip-form): improve mode setting value coercion function
daniel-heppner-ibigroup Aug 9, 2023
2f75000
fix(core-utils): repair crash on unknown mode setting dropdown value
daniel-heppner-ibigroup Aug 9, 2023
0e4b683
fix(core-utils): remove old walkSpeed query-param to reduce interfere…
daniel-heppner-ibigroup Aug 9, 2023
9913546
Revert "fix(types): add typeOverride property to modesettingbase"
daniel-heppner-ibigroup Aug 9, 2023
2333783
remove walkSpeed default qp
daniel-heppner-ibigroup Aug 9, 2023
37173d8
chore: complete removal of old walkSpeed parameter
daniel-heppner-ibigroup Aug 9, 2023
f4064e6
refactor: remove unwanted default walk tolerance sliders
miles-grant-ibigroup Aug 10, 2023
40b839a
test: update snapshots
miles-grant-ibigroup Aug 10, 2023
ca734eb
Initial work on walk reluctance checkbox
amy-corson-ibigroup Jul 28, 2023
aca3889
refactor: set query to null and fix crash
amy-corson-ibigroup Aug 3, 2023
d301b4f
feat(trip-form): support config mode subsetting
amy-corson-ibigroup Aug 3, 2023
1804660
Revert "feat(trip-form): support config mode subsetting"
amy-corson-ibigroup Aug 4, 2023
b1f5282
feat(trip-form): support config mode subsetting
amy-corson-ibigroup Aug 4, 2023
6119a54
chore(trip-form): update types
amy-corson-ibigroup Aug 4, 2023
9102ce7
refactor: remove subsetting override
amy-corson-ibigroup Aug 8, 2023
f478a45
chore(core-utils): Update comment for truthValue
amy-corson-ibigroup Aug 8, 2023
6009008
refactor: remove subsettingOverride
amy-corson-ibigroup Aug 9, 2023
92d534a
remove question mark
amy-corson-ibigroup Aug 9, 2023
0ca143c
remove unneccesary comment
amy-corson-ibigroup Aug 10, 2023
8723eb6
fix(trip-form): fix dropdown/hover bug in firefox
daniel-heppner-ibigroup Aug 7, 2023
b594819
add link to firefox bug tracker
daniel-heppner-ibigroup Aug 8, 2023
7bec575
chore(release): 3.1.5 [skip ci]
semantic-release-bot Aug 9, 2023
16c7982
update fr translation string
amy-corson-ibigroup Aug 10, 2023
b52deff
add translation to generateMainSettingLabel
amy-corson-ibigroup Aug 10, 2023
bf50ce5
chore(release): 3.2.0 [skip ci]
semantic-release-bot Aug 10, 2023
3d2392c
fix(core-utils): Add field leg.headsign to graphql plan query, remove…
binh-dam-ibigroup Aug 15, 2023
acd3c4e
chore(core-utils): remove walk speed from snapshots
daniel-heppner-ibigroup Aug 16, 2023
a6306e0
test(storybook): Update snapshots
binh-dam-ibigroup Aug 16, 2023
7428e96
chore(release): 10.0.0 [skip ci]
semantic-release-bot Aug 17, 2023
abb9f4e
Merge branch 'master' into walk-speed
daniel-heppner-ibigroup Aug 18, 2023
cd0972a
deps(trip-form): new core-utils
daniel-heppner-ibigroup Aug 18, 2023
7c6b60e
chore: update snapshots
daniel-heppner-ibigroup Aug 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions packages/trip-form/modeSettings.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1 @@
- applicableMode: CAR
default: 3
graphQLQueryParam: true
high: 5
inverseKey: carReluctance
key: carTolerance
low: 0
step: 0.1
type: SLIDER
- applicableMode: BICYCLE
default: 2
graphQLQueryParam: true
high: 5
inverseKey: bikeReluctance
key: bikeTolerance
low: 0
step: 0.1
type: SLIDER
- applicableMode: TRANSIT
default: false
graphQLQueryParam: true
id: walkReluctance
key: walkReluctance
truthValue: 5
type: CHECKBOX
# Reserved for future use. Supply default mode settings here
2 changes: 1 addition & 1 deletion packages/trip-form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"types": "lib/index.d.ts",
"private": false,
"dependencies": {
"@opentripplanner/core-utils": "^9.0.2",
"@opentripplanner/core-utils": "^10.0.0",
"@floating-ui/react": "^0.19.2",
"@styled-icons/bootstrap": "^10.34.0",
"@styled-icons/boxicons-regular": "^10.38.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/trip-form/src/GeneralSettingsPanel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default function GeneralSettingsPanel({
.getCustomQueryParams(queryParamMessages)
.find(qp => qp.name === param);
// Check that the parameter applies to the specified routingType
if (!paramInfo.routingTypes.includes(query.routingType)) return null;
if (!paramInfo?.routingTypes.includes(query.routingType)) return null;

// Check that the applicability test (if provided) is satisfied
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import {
setModeButtonEnabled
} from "./utils";

import modeSettingDefinitions from "../../modeSettings.yml";

const getIcon = (iconName: string): JSX.Element | null => {
switch (iconName) {
case "bus":
Expand Down Expand Up @@ -67,8 +65,8 @@ const defaultModeButtonDefinitions = [
}
];

// TODO: add more test settings?
const modeSettingDefinitionsWithDropdown = [
...modeSettingDefinitions,
{
applicableMode: "TRANSIT",
default: "blue",
Expand Down
13 changes: 13 additions & 0 deletions packages/trip-form/src/MetroModeSelector/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ export function convertModeSettingValue(
setting: ModeSetting,
value: string | boolean | number
): string | boolean | number {
// Assume the type of the output value based on the type of the default value.
if (setting.default) {
switch (typeof setting.default) {
case "bigint":
case "number":
return Number(value);
case "boolean":
return value === "true" || value === true;
default:
return value;
}
}
// In case no default is provided.
switch (setting.type) {
case "CHECKBOX":
case "SUBMODE":
Expand Down
4 changes: 2 additions & 2 deletions packages/trip-form/src/SettingsSelectorPanel.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ const SettingsPanelTemplate = (args: StoryArgs, context: StoryContext) => {
queryParamMessages={
args.useCustomMessages
? {
walkSpeed: {
label: "Custom walk speed label",
maxWalkDistance: {
label: "Custom max walk distance label",
options: [
{
text: "3 kph custom speed value",
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3241,7 +3241,7 @@
resolved "https://registry.yarnpkg.com/@open-draft/until/-/until-1.0.3.tgz#db9cc719191a62e7d9200f6e7bab21c5b848adca"
integrity sha512-Aq58f5HiWdyDlFffbbSjAlv596h/cOnt2DO1w3DOC7OJ5EHs0hd/nycJfiu9RJbT6Yk6F1knnRRXNSpxoIVZ9Q==

"@opentripplanner/core-utils@^9.0.3":
"@opentripplanner/core-utils@^9.0.2", "@opentripplanner/core-utils@^9.0.3":
version "9.0.3"
resolved "https://registry.yarnpkg.com/@opentripplanner/core-utils/-/core-utils-9.0.3.tgz#c1ebdcc3ad5999fb28427102c9be7d7268f6bd37"
integrity sha512-8P3Bi41jF7z18P/soo6lEw+nrqarsyGMAxivsF1/kMJdRo4wnakp0zcrVZjDXTxoR6LPtj6Kkuxv3JQFO9jKiw==
Expand All @@ -3260,10 +3260,10 @@
lodash.isequal "^4.5.0"
qs "^6.9.1"

"@opentripplanner/types@6.0.0-alpha.4":
version "6.0.0-alpha.4"
resolved "https://registry.yarnpkg.com/@opentripplanner/types/-/types-6.0.0-alpha.4.tgz#dee3c06675e30c596159d182ed707e7710cd937c"
integrity sha512-FlYsHm/tk+x0ldrEG1X9Ph1R1k3way1oEdKX7XSnhu9lNTzL4lO0hfT1PLzNXMfBRar7TzK94PHNDibJsod8Kw==
"@opentripplanner/types@7.0.0-alpha.2":
version "7.0.0-alpha.2"
resolved "https://registry.yarnpkg.com/@opentripplanner/types/-/types-7.0.0-alpha.2.tgz#d10c69f99b2da6d1e80ab5989520bde8e558627b"
integrity sha512-IzQwBcxkoyM+r/W7u+nzICf/6QnreLKppkrZZNl0yVxFiT6RBOd0U2UxMxLPYuRd/3awQabI3/qQ3/6ZxMWPfA==

"@peculiar/asn1-schema@^2.1.6", "@peculiar/asn1-schema@^2.3.0":
version "2.3.3"
Expand Down
Loading