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-3417 #3148

Merged
merged 21 commits into from
Apr 1, 2020
Merged

DT-3417 #3148

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ba62a79
feat: add U prefix to U bus lines
AleksiSiitari Mar 17, 2020
69490cf
feat: add U prefix to U bus lines
AleksiSiitari Mar 17, 2020
5791589
Merge branch 'master' of https://github.com/HSLdevcom/digitransit-ui …
AleksiSiitari Mar 24, 2020
787855d
feat: u-prefix to U-line busses
AleksiSiitari Mar 25, 2020
7e2eb51
fix: add check before calling variable
AleksiSiitari Mar 25, 2020
0db82f9
fix: check config before calling function
AleksiSiitari Mar 25, 2020
e26a3fc
fix: added check before calling mapRouting function
AleksiSiitari Mar 25, 2020
9af21c5
fix: check if mapRouting function exists before calling it
AleksiSiitari Mar 25, 2020
603230f
fix: added check that config exists in RouteNumbers
AleksiSiitari Mar 25, 2020
c6c0098
fix: added check for config in PrintableItinerary
AleksiSiitari Mar 25, 2020
bb2c1a5
Merge branch 'master' of https://github.com/HSLdevcom/digitransit-ui …
AleksiSiitari Mar 25, 2020
155dc36
Merge branch 'dt-3417' of https://github.com/HSLdevcom/digitransit-ui…
AleksiSiitari Mar 25, 2020
cc73d79
fix: remove unnecessary checks and variable
AleksiSiitari Mar 26, 2020
6b009aa
chore: refactor u-prefix into a more sensible solution
AleksiSiitari Mar 26, 2020
366e325
chore: fix visual tests
AleksiSiitari Mar 26, 2020
7083372
Merge branch 'master' of https://github.com/HSLdevcom/digitransit-ui …
AleksiSiitari Mar 31, 2020
d27aa26
fix: clean code and fix layout problems
AleksiSiitari Mar 31, 2020
b493bc6
fix: reduce padding to fix layout problem on route page
AleksiSiitari Mar 31, 2020
58a20db
chore: update visual tests
AleksiSiitari Mar 31, 2020
69ebacc
fix: small fixes to make getRoutePrefix more reliable
AleksiSiitari Mar 31, 2020
c71db8e
fix: small fixes to make getRoutePrefix more reliable
AleksiSiitari Mar 31, 2020
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
1 change: 1 addition & 0 deletions app/component/CallAgencyLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CallAgencyLeg extends React.Component {
mode="call"
className="leg-call"
realtime={false}
gtfsId={this.props.leg.route.gtfsId}
vertical
fadeLong
/>
Expand Down
5 changes: 5 additions & 0 deletions app/component/FavouriteLocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ const FavouriteLocation = ({
mode={firstTransitLeg.mode}
realtime={firstTransitLeg.realTime}
text={firstTransitLeg.route.shortName}
gtfsId={firstTransitLeg.route.gtfsId}
/>
 
{departureTimeComponent}
Expand Down Expand Up @@ -116,6 +117,10 @@ FavouriteLocation.propTypes = {
firstTransitLeg: PropTypes.object,
};

FavouriteLocation.contextTypes = {
config: PropTypes.object.isRequired,
};

FavouriteLocation.displayName = 'FavouriteLocation';

export default FavouriteLocation;
1 change: 1 addition & 0 deletions app/component/NextDeparturesList.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ function NextDeparturesList(props, context) {
alertSeverityLevel={departure.alertSeverityLevel}
mode={stoptime.pattern.route.mode}
text={stoptime.pattern.route.shortName}
gtfsId={stoptime.pattern.route.gtfsId}
/>
</td>
<td className="td-destination">
Expand Down
2 changes: 1 addition & 1 deletion app/component/RouteHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function RouteHeader(props) {
return (
<div className={cx('route-header', props.className)}>
<h1 className={mode}>
<RouteNumber mode={mode} text={routeLine} />
<RouteNumber mode={mode} text={routeLine} gtfsId={props.route.gtfsId} />
{trip}
</h1>
</div>
Expand Down
23 changes: 15 additions & 8 deletions app/component/RouteNumber.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@ import ComponentUsageExample from './ComponentUsageExample';
import { realtimeDeparture as exampleRealtimeDeparture } from './ExampleData';
import { isMobile } from '../util/browser';

const LONG_ROUTE_NUMBER_LENGTH = 6;
const LONG_ROUTE_NUMBER_LENGTH = 5;

function RouteNumber(props, context) {
let mode = props.mode.toLowerCase();
const routeName =
mode === 'bus' && props.gtfsId && context.config.getRoutePrefix
? context.config.getRoutePrefix(props.gtfsId).concat(props.text)
: props.text;
const { alertSeverityLevel, color } = props;

if (mode === 'bicycle' || mode === 'car') {
mode += '-withoutBox';
}

const longText = props.text && props.text.length >= LONG_ROUTE_NUMBER_LENGTH;
const longText = routeName && routeName.length >= LONG_ROUTE_NUMBER_LENGTH;
// Checks if route only has letters without identifying numbers and
// length doesn't fit in the tab view
const hasNoShortName =
props.text &&
new RegExp(/^([^0-9]*)$/).test(props.text) &&
props.text.length > 3;
routeName &&
new RegExp(/^([^0-9]*)$/).test(routeName) &&
routeName.length > 3;

const getIcon = (icon, isCallAgency, hasDisruption, badgeFill, badgeText) => {
if (isCallAgency) {
Expand Down Expand Up @@ -106,7 +110,7 @@ function RouteNumber(props, context) {
</div>
)}
</span>
{props.text &&
{routeName &&
(props.vertical === false ? (
<span
style={{
Expand All @@ -119,7 +123,7 @@ function RouteNumber(props, context) {
hasNoShortName: hasNoShortName && longText && props.isRouteView,
})}
>
{props.text}
{routeName}
</span>
) : (
<div className="vehicle-number-container-v">
Expand All @@ -130,7 +134,7 @@ function RouteNumber(props, context) {
long: longText,
})}
>
{props.text}
{routeName}
</span>
</div>
))}
Expand Down Expand Up @@ -210,6 +214,7 @@ RouteNumber.propTypes = {
badgeText: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
icon: PropTypes.string,
isRouteView: PropTypes.bool,
gtfsId: PropTypes.string,
};

RouteNumber.defaultProps = {
Expand All @@ -225,10 +230,12 @@ RouteNumber.defaultProps = {
isCallAgency: false,
isRouteView: false,
icon: undefined,
gtfsId: undefined,
};

RouteNumber.contextTypes = {
intl: intlShape.isRequired,
config: PropTypes.object,
};

RouteNumber.displayName = 'RouteNumber';
Expand Down
11 changes: 10 additions & 1 deletion app/component/RouteNumberContainer.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-nested-ternary */
import PropTypes from 'prop-types';
import React from 'react';
import get from 'lodash/get';
Expand All @@ -16,7 +17,7 @@ const getText = (route, config) => {
};

const RouteNumberContainer = (
{ alertSeverityLevel, className, route, isCallAgency, ...props },
{ alertSeverityLevel, className, route, isCallAgency, trip, ...props },
{ config },
) =>
route && (
Expand All @@ -27,6 +28,13 @@ const RouteNumberContainer = (
color={route.color ? `#${route.color}` : null}
mode={route.mode}
text={getText(route, config)}
gtfsId={
route.gtfsId
? route.gtfsId
: trip && trip.pattern
? trip.pattern.code
: ''
}
{...props}
/>
);
Expand All @@ -37,6 +45,7 @@ RouteNumberContainer.propTypes = {
vertical: PropTypes.bool,
className: PropTypes.string,
fadeLong: PropTypes.bool,
trip: PropTypes.object,
};

RouteNumberContainer.defaultProps = {
Expand Down
1 change: 1 addition & 0 deletions app/component/RoutePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ class RoutePage extends React.Component {
color={route.color ? `#${route.color}` : null}
mode={route.mode}
text={route.shortName}
gtfsId={route.gtfsId}
isRouteView
/>
)}
Expand Down
1 change: 1 addition & 0 deletions app/component/SummaryRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ export const RouteLeg = ({ leg, large, intl }) => {
<RouteNumberContainer
alertSeverityLevel={getActiveLegAlertSeverityLevel(leg)}
route={leg.route}
trip={leg.trip}
className={cx('line', leg.mode.toLowerCase())}
vertical
withBar
Expand Down
1 change: 1 addition & 0 deletions app/component/TransitLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class TransitLeg extends React.Component {
mode={mode.toLowerCase()}
color={leg.route ? `#${leg.route.color}` : 'currentColor'}
text={leg.route && leg.route.shortName}
gtfsId={leg.route.gtfsId}
realtime={leg.realTime}
vertical
fadeLong
Expand Down
7 changes: 6 additions & 1 deletion app/component/ViaLeg.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ function ViaLeg(props, context) {
<div className="itinerary-time-column-time via-departure-time">
{moment(props.leg.startTime).format('HH:mm')}
</div>
<RouteNumber mode={props.leg.mode.toLowerCase()} vertical />
<RouteNumber
mode={props.leg.mode.toLowerCase()}
vertical
gtfsId={props.leg.gtfsId}
/>
</div>
<ItineraryCircleLine
isVia
Expand Down Expand Up @@ -175,6 +179,7 @@ ViaLeg.propTypes = {
startTime: PropTypes.number.isRequired,
distance: PropTypes.number.isRequired,
mode: PropTypes.string.isRequired,
gtfsId: PropTypes.string,
from: PropTypes.shape({
name: PropTypes.string.isRequired,
stop: PropTypes.shape({
Expand Down
2 changes: 1 addition & 1 deletion app/component/departure.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
white-space: nowrap;

.vehicle-number {
width: 2.5em;
width: 3em;
}

& .route-number {
Expand Down
2 changes: 1 addition & 1 deletion app/component/front-page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ div.route-tabs .tabs-navigation.bp-large {

.vehicle-number {
vertical-align: text-bottom;
padding-left: 0.4em;
padding-left: 0.2em;
}
}

Expand Down
7 changes: 7 additions & 0 deletions app/configurations/config.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,4 +775,11 @@ export default {

timetables: {},
showLogin: false,

/* Function that can be used to configure route names before displaying them
Takes routes gtfsId as input */
// eslint-disable-next-line no-unused-vars
getRoutePrefix: function routePrefix(routeId) {
return '';
},
};
9 changes: 9 additions & 0 deletions app/configurations/config.hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -535,4 +535,13 @@ export default {
},
},
showLogin: true,

/* Function that can be used to configure route names before displaying them
Takes routes gtfsId as input */
getRoutePrefix: function routePrefix(routeId) {
if (!routeId || !routeId.includes(':')) {
return '';
}
return routeId.split(':')[1].substring(0, 1) === '7' ? 'U' : '';
},
};
Binary file modified test/visual-images/AirplaneLeg_normal/normal/chrome.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/AirplaneLeg_normal/normal/safari.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/Departure_added-padding/added-padding/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/Departure_isArrival/isArrival/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/Departure_normal/normal/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/Departure_with-stop/with-stop/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/visual-images/StopMarkerPopup_basic/basic/edge.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.