Skip to content

Commit

Permalink
Merge pull request #893 from stadtnavi/fix/itinerary-page-earlier-dep…
Browse files Browse the repository at this point in the history
…artures

fix(itinerary-page): multi-modal request for earlier/later connections
  • Loading branch information
andreashelms authored Jan 22, 2025
2 parents 2dd3c19 + 700c03a commit c068139
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
9 changes: 5 additions & 4 deletions app/component/ItineraryList/ItineraryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function ItineraryList(
separatorPosition,
loadingMoreItineraries,
driving,
onlyHasWalkingItineraries,
hasNoTransitItineraries,
routingErrors,
},
context,
Expand Down Expand Up @@ -85,7 +85,7 @@ function ItineraryList(
intermediatePlaces={intermediatePlaces}
isCancelled={itineraryHasCancelation(itinerary)}
showCancelled={showCancelled}
hideBorder={onlyHasWalkingItineraries}
hideBorder={hasNoTransitItineraries}
zones={
config.zones.stops && itinerary.legs ? getZones(itinerary.legs) : []
}
Expand Down Expand Up @@ -199,7 +199,7 @@ function ItineraryList(
/>
)}
</div>
{onlyHasWalkingItineraries && !showAlternativePlan && (
{hasNoTransitItineraries && !showAlternativePlan && (
<div className="summary-no-route-found" style={{ marginTop: 0 }}>
<div
className={cx('flex-horizontal', 'summary-notification', 'info')}
Expand Down Expand Up @@ -316,7 +316,7 @@ ItineraryList.propTypes = {
showAlternativePlan: PropTypes.bool,
separatorPosition: PropTypes.number,
loadingMoreItineraries: PropTypes.string,
onlyHasWalkingItineraries: PropTypes.bool,
hasNoTransitItineraries: PropTypes.bool,
};

ItineraryList.defaultProps = {
Expand All @@ -330,6 +330,7 @@ ItineraryList.defaultProps = {
separatorPosition: undefined,
loadingMoreItineraries: undefined,
routingErrors: [],
hasNoTransitItineraries: false,
};

ItineraryList.contextTypes = {
Expand Down
13 changes: 7 additions & 6 deletions app/component/ItineraryListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class ItineraryListContainer extends React.Component {
settingsNotification: PropTypes.func,
loadingMoreItineraries: PropTypes.string,
driving: PropTypes.bool,
onlyHasWalkingItineraries: PropTypes.bool,
hasNoTransitItineraries: PropTypes.bool,
};

static defaultProps = {
Expand All @@ -78,7 +78,7 @@ class ItineraryListContainer extends React.Component {
routingErrors: [],
separatorPosition: undefined,
settingsNotification: false,
onlyHasWalkingItineraries: false,
hasNoTransitItineraries: false,
};

static contextTypes = {
Expand Down Expand Up @@ -252,9 +252,10 @@ class ItineraryListContainer extends React.Component {
separatorPosition,
loadingMoreItineraries,
driving,
onlyHasWalkingItineraries,
hasNoTransitItineraries,
settingsNotification,
} = this.props;

const searchTime =
this.props.plan?.date ||
(location.query &&
Expand All @@ -274,7 +275,7 @@ class ItineraryListContainer extends React.Component {
{(this.context.match.params.hash &&
this.context.match.params.hash === 'bikeAndVehicle') ||
disableButtons ||
onlyHasWalkingItineraries
hasNoTransitItineraries
? null
: arriveBy
? this.laterButton(true)
Expand Down Expand Up @@ -302,15 +303,15 @@ class ItineraryListContainer extends React.Component {
separatorPosition={separatorPosition}
loadingMoreItineraries={loadingMoreItineraries}
driving={driving}
onlyHasWalkingItineraries={onlyHasWalkingItineraries}
hasNoTransitItineraries={hasNoTransitItineraries}
>
{this.props.children}
</ItineraryList>
{settingsNotification && <SettingsNotification />}
{(this.context.match.params.hash &&
this.context.match.params.hash === 'bikeAndVehicle') ||
disableButtons ||
onlyHasWalkingItineraries
hasNoTransitItineraries
? null
: arriveBy
? this.earlierButton(true)
Expand Down
30 changes: 24 additions & 6 deletions app/component/ItineraryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,18 @@ class ItineraryPage extends React.Component {
});
}

setModeToMultiModalIfSelected(tunedParams) {
switch (this.props.match.params.hash) {
case streetHash.parkAndRide:
return {
...tunedParams,
modes: [{ mode: 'CAR', qualifier: 'PARK' }, { mode: 'TRANSIT' }],
};
default:
return tunedParams;
}
}

onLater = (itineraries, reversed) => {
addAnalyticsEvent({
event: 'sendMatomoEvent',
Expand Down Expand Up @@ -418,7 +430,7 @@ class ItineraryPage extends React.Component {
useRelaxedRoutingPreferences,
)(this.props.match.params, this.props.match);

const tunedParams = {
let tunedParams = {
wheelchair: null,
...params,
numItineraries: 5,
Expand All @@ -432,6 +444,8 @@ class ItineraryPage extends React.Component {
});
this.showScreenreaderLoadingAlert();

tunedParams = this.setModeToMultiModalIfSelected(tunedParams);

fetchQuery(
this.props.relayEnvironment,
moreItinerariesQuery,
Expand Down Expand Up @@ -510,7 +524,7 @@ class ItineraryPage extends React.Component {
useRelaxedRoutingPreferences,
)(this.props.match.params, this.props.match);

const tunedParams = {
let tunedParams = {
wheelchair: null,
...params,
numItineraries: 5,
Expand All @@ -523,6 +537,8 @@ class ItineraryPage extends React.Component {
});
this.showScreenreaderLoadingAlert();

tunedParams = this.setModeToMultiModalIfSelected(tunedParams);

fetchQuery(
this.props.relayEnvironment,
moreItinerariesQuery,
Expand Down Expand Up @@ -667,6 +683,8 @@ class ItineraryPage extends React.Component {
this.setState({
center: undefined,
bounds: undefined,
earlierItineraries: [],
laterItineraries: [],
});
}

Expand Down Expand Up @@ -1171,11 +1189,9 @@ class ItineraryPage extends React.Component {
// Remove old itineraries if new query cannot find a route
if (error) {
combinedItineraries = [];
} else if (streetHashes.includes(hash)) {
combinedItineraries = this.selectedPlan?.itineraries || [];
} else {
combinedItineraries = this.getCombinedItineraries();
if (!hasNoTransitItineraries) {
if (!streetHashes.includes(hash) && !hasNoTransitItineraries) {
// don't show plain walking in transit itinerary list
combinedItineraries = transitItineraries(combinedItineraries);
}
Expand Down Expand Up @@ -1316,9 +1332,11 @@ class ItineraryPage extends React.Component {
onEarlier: this.onEarlier,
onDetailsTabFocused: this.onDetailsTabFocused,
loading,
loadingMore: state.loadingMore, // spinner pos while loading earlier/later
loadingMoreItineraries: state.loadingMore, // spinner pos while loading earlier/later
settingsNotification,
routingFeedbackPosition: state.routingFeedbackPosition,
hasNoTransitItineraries:
transitItineraries(combinedItineraries).length === 0,
};

const streetModeSelectorProps = {
Expand Down

0 comments on commit c068139

Please sign in to comment.