Skip to content

Commit

Permalink
Merge branch 'v3' into lahti-ticketlink
Browse files Browse the repository at this point in the history
  • Loading branch information
sharhio committed Oct 1, 2024
2 parents 8e44f2a + aade6c4 commit 5a33c25
Show file tree
Hide file tree
Showing 40 changed files with 388 additions and 243 deletions.
28 changes: 19 additions & 9 deletions app/component/IndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,30 @@ class IndexPage extends React.Component {
const destination = this.pendingDestination || this.props.destination;
const sources = ['Favourite', 'History', 'Datasource'];
const stopAndRouteSearchTargets = ['Stops', 'Routes'];
const locationSearchTargets = [
let locationSearchTargets = [
'Locations',
'CurrentPosition',
'FutureRoutes',
'Stops',
];

if (useCitybikes(config.vehicleRental?.networks, config)) {
stopAndRouteSearchTargets.push('VehicleRentalStations');
locationSearchTargets.push('VehicleRentalStations');
}
if (config.includeParkAndRideSuggestions) {
stopAndRouteSearchTargets.push('ParkingAreas');
locationSearchTargets.push('ParkingAreas');
if (config.locationSearchTargetsFromOTP) {
// configurable setup
locationSearchTargets = [
...locationSearchTargets,
...config.locationSearchTargetsFromOTP,
];
} else {
// default setup
locationSearchTargets.push('Stops');

if (useCitybikes(config.vehicleRental?.networks, config)) {
stopAndRouteSearchTargets.push('VehicleRentalStations');
locationSearchTargets.push('VehicleRentalStations');
}
if (config.includeParkAndRideSuggestions) {
stopAndRouteSearchTargets.push('ParkingAreas');
locationSearchTargets.push('ParkingAreas');
}
}
const locationSearchTargetsMobile = [
...locationSearchTargets,
Expand Down
5 changes: 4 additions & 1 deletion app/component/RouteNumberContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const RouteNumberContainer = (
isCallAgency,
withBicycle,
occupancyStatus,
mode,
...props
},
{ config },
Expand All @@ -23,7 +24,7 @@ const RouteNumberContainer = (
className={className}
isCallAgency={isCallAgency || route.type === 715}
color={route.color ? `#${route.color}` : null}
mode={route.mode}
mode={mode !== undefined ? mode : route.mode}
text={getLegText(route, config, interliningWithRoute)}
withBicycle={withBicycle}
occupancyStatus={occupancyStatus}
Expand All @@ -41,6 +42,7 @@ RouteNumberContainer.propTypes = {
fadeLong: PropTypes.bool,
withBicycle: PropTypes.bool,
occupancyStatus: PropTypes.string,
mode: PropTypes.string,
};

RouteNumberContainer.defaultProps = {
Expand All @@ -52,6 +54,7 @@ RouteNumberContainer.defaultProps = {
className: '',
withBicycle: false,
occupancyStatus: undefined,
mode: undefined,
};

RouteNumberContainer.contextTypes = {
Expand Down
9 changes: 3 additions & 6 deletions app/component/StopTimetablePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ class StopTimetablePage extends React.Component {
}

onDateChange = value => {
this.setState({ date: value });
this.props.relay.refetch(
{
date: value,
},
null,
() => this.setState({ date: value }),
);
};

Expand All @@ -48,11 +48,8 @@ class StopTimetablePage extends React.Component {
<TimetableContainer
stop={this.props.stop}
date={this.state.date}
propsForDateSelect={{
startDate: unixToYYYYMMDD(unixTime(), this.context.config),
selectedDate: this.state.date,
onDateChange: this.onDateChange,
}}
startDate={unixToYYYYMMDD(unixTime(), this.context.config)}
onDateChange={this.onDateChange}
/>
);
}
Expand Down
30 changes: 8 additions & 22 deletions app/component/SwipeableTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,8 @@ const handleKeyPress = (e, reactSwipeEl) => {
};

export default class SwipeableTabs extends React.Component {
constructor(props) {
super();
this.state = { tabIndex: props.tabIndex };
}

static propTypes = {
tabIndex: PropTypes.number,
tabIndex: PropTypes.number.isRequired,
tabs: PropTypes.arrayOf(PropTypes.node).isRequired,
onSwipe: PropTypes.func.isRequired,
hideArrows: PropTypes.bool,
Expand All @@ -82,7 +77,6 @@ export default class SwipeableTabs extends React.Component {
static defaultProps = {
hideArrows: false,
navigationOnBottom: false,
tabIndex: 0,
classname: undefined,
};

Expand All @@ -100,7 +94,7 @@ export default class SwipeableTabs extends React.Component {
}

tabBalls = tabsLength => {
const tabIndex = parseInt(this.state.tabIndex, 10);
const tabIndex = parseInt(this.props.tabIndex, 10);
const onLeft = tabIndex;
const onRight = tabsLength - tabIndex - 1;
let tabBalls = [];
Expand Down Expand Up @@ -161,17 +155,15 @@ export default class SwipeableTabs extends React.Component {
)}
tabIndex={0}
className={`swipe-tab-ball ${
index === this.state.tabIndex ? 'selected' : ''
index === this.props.tabIndex ? 'selected' : ''
} ${ball.smaller ? 'decreasing-small' : ''} ${
ball.small ? 'decreasing' : ''
} ${ball.hidden ? 'hidden' : ''}`}
onClick={() => {
this.setState({ tabIndex: index });
this.props.onSwipe(index);
}}
onKeyDown={e => {
if (isKeyboardSelectionEvent(e)) {
this.setState({ tabIndex: index });
this.props.onSwipe(index);
}
}}
Expand Down Expand Up @@ -247,7 +239,6 @@ export default class SwipeableTabs extends React.Component {
callback: i => {
// force transition after animation should be over because animation can randomly fail sometimes
setTimeout(() => {
this.setState({ tabIndex: i });
this.props.onSwipe(i);
}, 300);
},
Expand All @@ -262,11 +253,7 @@ export default class SwipeableTabs extends React.Component {
</div>
</ScrollableWrapper>
)}
<div
className={`swipe-header-container ${this.props.classname} ${
this.state.scrolled && !navigationOnBottom ? 'scrolled' : ''
}`}
>
<div className={`swipe-header-container ${this.props.classname}`}>
{this.props.classname === 'swipe-desktop-view' && (
<div className="desktop-view-divider" />
)}
Expand All @@ -282,7 +269,7 @@ export default class SwipeableTabs extends React.Component {
{!hideArrows && (
<div
className={cx('swipe-button-container', {
active: !(disabled || this.state.tabIndex <= 0),
active: !(disabled || this.props.tabIndex <= 0),
})}
>
<div
Expand All @@ -301,7 +288,7 @@ export default class SwipeableTabs extends React.Component {
<Icon
img="icon-icon_arrow-collapse--left"
className={`itinerary-arrow-icon ${
disabled || this.state.tabIndex <= 0 ? 'disabled' : ''
disabled || this.props.tabIndex <= 0 ? 'disabled' : ''
}`}
/>
</div>
Expand All @@ -322,7 +309,7 @@ export default class SwipeableTabs extends React.Component {
{!hideArrows && (
<div
className={cx('swipe-button-container', {
active: !(disabled || this.state.tabIndex >= tabs.length - 1),
active: !(disabled || this.props.tabIndex >= tabs.length - 1),
})}
>
<div
Expand All @@ -341,7 +328,7 @@ export default class SwipeableTabs extends React.Component {
<Icon
img="icon-icon_arrow-collapse--right"
className={`itinerary-arrow-icon ${
disabled || this.state.tabIndex >= tabs.length - 1
disabled || this.props.tabIndex >= tabs.length - 1
? 'disabled'
: ''
}`}
Expand All @@ -361,7 +348,6 @@ export default class SwipeableTabs extends React.Component {
callback: i => {
// force transition after animation should be over because animation can randomly fail sometimes
setTimeout(() => {
this.setState({ tabIndex: i });
this.props.onSwipe(i);
}, 300);
},
Expand Down
9 changes: 3 additions & 6 deletions app/component/TerminalTimetablePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ class TerminalTimetablePage extends React.Component {
}

onDateChange = value => {
this.setState({ date: value });
this.props.relay.refetch(
{
date: value,
},
null,
() => this.setState({ date: value }),
);
};

Expand All @@ -48,11 +48,8 @@ class TerminalTimetablePage extends React.Component {
<TimetableContainer
stop={this.props.station}
date={this.state.date}
propsForDateSelect={{
startDate: unixToYYYYMMDD(unixTime(), this.context.config),
selectedDate: this.state.date,
onDateChange: this.onDateChange,
}}
startDate={unixToYYYYMMDD(unixTime(), this.context.config)}
onDateChange={this.onDateChange}
/>
);
}
Expand Down
25 changes: 8 additions & 17 deletions app/component/Timetable.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,19 +82,12 @@ class Timetable extends React.Component {
}),
).isRequired,
}).isRequired,
propsForDateSelect: PropTypes.shape({
startDate: PropTypes.string,
selectedDate: PropTypes.string,
onDateChange: PropTypes.func,
}).isRequired,
date: PropTypes.string,
startDate: PropTypes.string.isRequired,
onDateChange: PropTypes.func.isRequired,
date: PropTypes.string.isRequired,
language: PropTypes.string.isRequired,
};

static defaultProps = {
date: undefined,
};

static contextTypes = {
router: routerShape.isRequired,
match: matchShape.isRequired,
Expand Down Expand Up @@ -183,7 +176,7 @@ class Timetable extends React.Component {
};

dateForPrinting = () => {
const selectedDate = moment(this.props.propsForDateSelect.selectedDate);
const selectedDate = moment(this.props.date);
return (
<div className="printable-date-container">
<div className="printable-date-icon">
Expand Down Expand Up @@ -331,9 +324,7 @@ class Timetable extends React.Component {
}${locationType.toLowerCase()}/${this.props.stop.gtfsId}`;
const timeTableRows = this.createTimeTableRows(timetableMap);
const timeDifferenceDays = moment
.duration(
moment(this.props.propsForDateSelect.selectedDate).diff(moment()),
)
.duration(moment(this.props.date).diff(moment()))
.asDays();
return (
<>
Expand All @@ -349,10 +340,10 @@ class Timetable extends React.Component {
) : null}
<div className="timetable-topbar">
<DateSelect
startDate={this.props.propsForDateSelect.startDate}
selectedDate={this.props.propsForDateSelect.selectedDate}
startDate={this.props.startDate}
selectedDate={this.props.date}
onDateChange={e => {
this.props.propsForDateSelect.onDateChange(e);
this.props.onDateChange(e);
const showRoutes = this.state.showRoutes.length
? this.state.showRoutes.join(',')
: undefined;
Expand Down
4 changes: 2 additions & 2 deletions app/component/itinerary/BicycleLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,9 +375,9 @@ export default function BicycleLeg(
<div
role="button"
tabIndex="0"
onClick={() => openSettings(true)}
onClick={() => openSettings(true, true)}
onKeyPress={e =>
isKeyboardSelectionEvent(e) && openSettings(true)
isKeyboardSelectionEvent(e) && openSettings(true, true)
}
className="itinerary-transit-leg-route-bike"
>
Expand Down
4 changes: 2 additions & 2 deletions app/component/itinerary/Itinerary.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export function RouteLeg(
) {
const isCallAgency = isCallAgencyPickupType(leg);
let routeNumber;
const mode = getRouteMode(leg.route);
const mode = getRouteMode(leg.route, config);

const getOccupancyStatus = () => {
if (hasOneTransitLeg) {
Expand Down Expand Up @@ -118,7 +118,7 @@ export function RouteLeg(
<RouteNumberContainer
alertSeverityLevel={getActiveLegAlertSeverityLevel(leg)}
route={leg.route}
className={cx('line', leg.mode.toLowerCase())}
className={cx('line', mode)}
interliningWithRoute={interliningWithRoute}
mode={mode}
vertical
Expand Down
2 changes: 0 additions & 2 deletions app/component/itinerary/ItineraryListContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,12 @@ function ItineraryListContainer(
};

const onSelectActive = index => {
const subpath = getSubPath('');
if (activeIndex === index) {
onSelectImmediately(index);
} else {
router.replace({
...match.location,
state: { selectedItineraryIndex: index },
pathname: `${getItineraryPagePath(params.from, params.to)}${subpath}`,
});

addAnalyticsEvent({
Expand Down
Loading

0 comments on commit 5a33c25

Please sign in to comment.