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

DT-5921 Add car ferry functionality #5121

Open
wants to merge 16 commits into
base: v3
Choose a base branch
from
Open

Conversation

VillePihlava
Copy link
Contributor

@VillePihlava VillePihlava commented Oct 15, 2024

This should not be merged before the functionality from this pr can be used opentripplanner/OpenTripPlanner#5966,

Proposed Changes

  • Add car ferry functionality
    • matka config
    • waltti config
  • Direct car and cars on transit combination view
  • Add overflow icon
  • Remove leg text for itineraries for ferries in the matka config
  • Fix leg-before-line width for bikes from 6px to 8px
  • Fix color for the secondary icon in the alternative itinerary bar

@VillePihlava VillePihlava changed the title DT-5921 Add car ferry functionality [Do not merge] DT-5921 Add car ferry functionality Oct 15, 2024
Copy link
Member

@vesameskanen vesameskanen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work. I suggested a fair amount of mainly cosmetic changes, which make the code easier to read and understand.

In general, try to avoid adding unncecessary validation checks 'just in case'. The code should fail fast and crash if variable values are not valid.

app/component/RouteNumberContainer.js Outdated Show resolved Hide resolved
app/component/RouteNumberContainer.js Outdated Show resolved Hide resolved
app/component/itinerary/CarLeg.js Outdated Show resolved Hide resolved
Comment on lines 90 to 91
<div className={cx('itinerary-leg-action', 'car')}>
<div className="itinerary-leg-action-content">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge these into one div

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change these for now. For example, there are similar divs in BicycleLeg, BikeParkLeg, CarParkLeg. Do you want all of these changed or none?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I understand. I would love to see all code improving continuously. Please fix this unless it feels unreasonably big task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two divs have been merged everywhere I could find them.

Comment on lines 127 to 128
<div className={cx('itinerary-leg-action', 'car')}>
<div className="itinerary-leg-action-content">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge divs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not change these for now. For example, there are similar divs in BicycleLeg, BikeParkLeg, CarParkLeg. Do you want all of these changed or none?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two divs have been merged everywhere I could find them.

app/component/itinerary/ItineraryList.js Outdated Show resolved Hide resolved
severityLevel={AlertSeverityLevelType.Info}
/>
</div>
<div className="with-car-info-notification">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merge these 2 divs: with-car-info-notification and with-car-info-content

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed with-bike-info-header and with-car-info-header in itinerary-list-header.scss, they were not used anymore. I merged with-bike-info-content and with-bike-info-notification as well as with-car-info-content and with-car-info-notification.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a new css class .with-car-info-notification-icon which seems to be unused.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed with-car-info-notification-icon and with-bike-info-notification-icon. The car class was accidentally created based off of the old bike icon class. Both seem unused and I removed them

settings.includeCarSuggestions &&
config.carBoardingModes?.FERRY !== undefined &&
carPublicPlan.carPublicItineraryCount > 0;

const showAltBar =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

carPublicPlan.carPublicItineraryCount > 0 is enough

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FERRY checking is now removed. The idea behind checking for FERRY is that only in the configs that it is defined in, the UI will show ferries. Now there isn't a config field for removing carpublic itineraries in case they are found but not wanted. I did not remove settings.includeCarSuggestions.

Copy link
Member

@vesameskanen vesameskanen Oct 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can there be car + public itineraries if includeCarSuggestions === false ? That would be surprising.

The logic gets a bit complicated because car itinerary is fetched for co2 comparison although user does not wish to get car itineraries.

Make sure that car + public won't get populated just because of co2 car routing. It should contain something only when user has selected car routing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a double check here and forgot I checked this earlier. This is now only carPublicPlan.carPublicItineraryCount > 0

app/component/itinerary/ItineraryPage.js Outdated Show resolved Hide resolved
Comment on lines 1227 to 1230
(settings.includeCarSuggestions &&
(carPlan?.edges?.length ||
(config.carBoardingModes?.FERRY !== undefined &&
carPublicPlan?.edges?.length))));
Copy link
Member

@vesameskanen vesameskanen Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(settings.includeCarSuggestions && carPlan?.edges?.length) ||
carPublicPlan?.edges?.length > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This assumes that the carpublicplan would be shown even without the setting. I think this is wrong. Do you agree? FERRY is now removed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Combination (settings.includeCarSuggestions && carPlan?.edges?.length) is used because carplan may be comouted for co2 comparison only.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has now been changed to (settings.includeCarSuggestions && carPlan?.edges?.length) ||
carPublicPlan?.edges?.length > 0. I had a double check here and forgot I checked this earlier

@vesameskanen
Copy link
Member

There is a conflict.

Copy link
Member

@vesameskanen vesameskanen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some new logic errors related to car+public itinerary list creation. Please read my review comments.

return (
transitModes.length > 0 &&
settings.includeCarSuggestions &&
config.carBoardingModes?.FERRY !== undefined
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong. I suggest:

settings.includeCarSuggestions && filterTransitModes(...).length > 0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed this to transitModes.length > 0 && settings.includeCarSuggestions. I didn't realize previously that transitModes is filtered earlier with filterTransitModes.

altStates[PLANTYPE.CAR][0].loading === LOADSTATE.DONE &&
altStates[PLANTYPE.CARTRANSIT][0].loading === LOADSTATE.DONE
) {
const plan = mergeCarDirectAndTransitPlans(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is not OK. car + transit should be set only when there are carBoardingModes configured and settings.includeCarSuggestions is true.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very similar to how the mergeBikeTransitPlans works. Because the check for making the cartransit query is made in planParamUtil, this should be fine as is. Do you want me to change this and the way it works for bikes or should I leave both as is?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now changed it to
altStates[PLANTYPE.CAR][0].loading === LOADSTATE.DONE &&
altStates[PLANTYPE.CARTRANSIT][0].loading === LOADSTATE.DONE &&
settings.includeCarSuggestions &&
config.carBoardingModes !== undefined

@VillePihlava VillePihlava changed the title [Do not merge] DT-5921 Add car ferry functionality DT-5921 Add car ferry functionality Oct 31, 2024
@VillePihlava VillePihlava marked this pull request as ready for review October 31, 2024 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants