Skip to content

Commit

Permalink
Merge pull request #4686 from HSLdevcom/DT-5609-v2
Browse files Browse the repository at this point in the history
DT-5609 do not search train stops from HSL data in matka
  • Loading branch information
optionsome authored Nov 18, 2022
2 parents e894996 + 2dd0f30 commit a5c07d8
Show file tree
Hide file tree
Showing 32 changed files with 284 additions and 194 deletions.
13 changes: 11 additions & 2 deletions app/component/IndexPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,11 @@ class IndexPage extends React.Component {
'Stops',
];

if (useCitybikes(this.context.config.cityBike?.networks)) {
if (useCitybikes(config.cityBike?.networks)) {
stopAndRouteSearchTargets.push('BikeRentalStations');
locationSearchTargets.push('BikeRentalStations');
}
if (this.context.config.includeParkAndRideSuggestions) {
if (config.includeParkAndRideSuggestions) {
stopAndRouteSearchTargets.push('ParkingAreas');
locationSearchTargets.push('ParkingAreas');
}
Expand Down Expand Up @@ -290,6 +290,15 @@ class IndexPage extends React.Component {
modeIconColors: config.colors.iconColors,
modeSet: config.iconModeSet,
};

if (config.stopSearchFilter) {
stopRouteSearchProps.filterResults = results =>
results.filter(config.stopSearchFilter);
stopRouteSearchProps.geocodingSize = 40; // increase size to compensate filtering
locationSearchProps.filterResults = results =>
results.filter(config.stopSearchFilter);
}

const transportModes = getTransportModes(config);
const nearYouModes = getNearYouModes(config);

Expand Down
5 changes: 5 additions & 0 deletions app/component/OriginDestinationBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class OriginDestinationBar extends React.Component {
};

render() {
const { config } = this.context;
const refPoint = getRefPoint(
this.props.origin,
this.props.destination,
Expand All @@ -129,6 +130,9 @@ class OriginDestinationBar extends React.Component {
desktopTargets.push('BikeRentalStations');
}
const mobileTargets = [...desktopTargets, 'MapPosition'];
const filter = config.stopSearchFilter
? results => results.filter(config.stopSearchFilter)
: undefined;
return (
<div
className={cx(
Expand Down Expand Up @@ -167,6 +171,7 @@ class OriginDestinationBar extends React.Component {
}
modeSet={this.props.modeSet}
onFocusChange={() => {}}
filterResults={filter}
/>{' '}
</div>
);
Expand Down
8 changes: 7 additions & 1 deletion app/component/StopsNearYouSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ function StopsNearYouSearch({ mode, breakpoint, lang }, { router, config }) {
const isMobile = breakpoint !== 'large';
const transportMode = `route-${mode}`;

const filter = config.stopSearchFilter
? (results, transportmode, type) =>
filterSearchResultsByMode(results, transportmode, type).filter(
config.stopSearchFilter,
)
: filterSearchResultsByMode;
const selectHandler = item => {
router.push(getStopRoutePath(item));
};
Expand All @@ -30,7 +36,7 @@ function StopsNearYouSearch({ mode, breakpoint, lang }, { router, config }) {
transportMode={transportMode}
geocodingSize={40}
value=""
filterResults={filterSearchResultsByMode}
filterResults={filter}
sources={searchSources}
targets={
mode === 'CITYBIKE' ? ['BikeRentalStations'] : ['Stops', 'Routes']
Expand Down
11 changes: 11 additions & 0 deletions app/configurations/config.matka.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,17 @@ export default {
'digitraffic',
],

stopSearchFilter: stop => {
const props = stop.properties;
if (
props?.id?.includes('GTFS:HSL') &&
props?.addendum?.GTFS?.modes?.includes('RAIL')
) {
return false;
}
return true;
},

meta: {
description: APP_DESCRIPTION,
keywords: `reitti,reitit,opas,reittiopas,joukkoliikenne`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-autosuggest-panel",
"version": "1.4.11",
"version": "1.5.3",
"description": "digitransit-component autosuggest-panel module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -28,8 +28,8 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-autosuggest": "^1.8.12",
"@digitransit-component/digitransit-component-icon": "^0.1.18",
"@digitransit-component/digitransit-component-autosuggest": "^1.9.2",
"@digitransit-component/digitransit-component-icon": "^0.2.0",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,4 +231,8 @@ $zindex: base, map-container, map-gradient, map-fullscreen-toggle,
margin-left: 25px;
margin-top: -5px;
}
}

.search-panel-whitespace {
min-width: 40px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -656,24 +656,27 @@ class DTAutosuggestPanel extends React.Component {
showScroll={this.props.showScroll}
isEmbedded={this.props.isEmbedded}
/>
<ItinerarySearchControl
className={cx(styles['add-via-point'], styles.more, {
collapsed: viaPoints.length > 4,
})}
enabled={showMultiPointControls}
onClick={() => this.handleAddViaPointClick()}
onKeyPress={e =>
this.isKeyboardSelectionEvent(e) && this.handleAddViaPointClick()
}
aria-label={i18next.t('add-via-button-label')}
>
<Icon
img="viapoint"
width={1.25}
height={1.375}
color={this.props.color}
/>
</ItinerarySearchControl>
{showMultiPointControls && (
<ItinerarySearchControl
className={cx(styles['add-via-point'], styles.more, {
collapsed: viaPoints.length > 4,
})}
enabled={showMultiPointControls}
onClick={() => this.handleAddViaPointClick()}
onKeyPress={e =>
this.isKeyboardSelectionEvent(e) &&
this.handleAddViaPointClick()
}
aria-label={i18next.t('add-via-button-label')}
>
<Icon
img="viapoint"
width={1.25}
height={1.375}
color={this.props.color}
/>
</ItinerarySearchControl>
)}
</div>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-autosuggest",
"version": "1.8.12",
"version": "1.9.2",
"description": "digitransit-component autosuggest module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -29,15 +29,15 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"dependencies": {
"@digitransit-search-util/digitransit-search-util-execute-search-immidiate": "^1.2.3",
"@digitransit-search-util/digitransit-search-util-get-label": "^0.1.2",
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^1.0.0",
"@digitransit-search-util/digitransit-search-util-execute-search-immidiate": "^1.3.1",
"@digitransit-search-util/digitransit-search-util-get-label": "^0.2.0",
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^1.1.0",
"@hsl-fi/hooks": "^1.2.0"
},
"peerDependencies": {
"@digitransit-component/digitransit-component-dialog-modal": "^0.3.4",
"@digitransit-component/digitransit-component-icon": "^0.1.18",
"@digitransit-component/digitransit-component-suggestion-item": "^1.0.4",
"@digitransit-component/digitransit-component-icon": "^0.2.0",
"@digitransit-component/digitransit-component-suggestion-item": "^1.1.0",
"@hsl-fi/sass": "^0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ input[type='text'] {
justify-content: center;
height: 100%;
width: 52px;
border: 0;
background: none;
svg {
fill: $primary-color;
width: 14px;
Expand Down Expand Up @@ -172,6 +174,7 @@ button.clear-input {

.clear-search-history {
display: flex;
font-family: 'Gotham Rounded A', 'Gotham Rounded B', 'Roboto', Arial, Georgia, Serif;
margin-top: auto;
align-items: center;
justify-content: center;
Expand All @@ -182,6 +185,7 @@ button.clear-input {
font-size: 15px;
font-weight: var(--font-weight-medium);
letter-spacing: -0.42px;
border: none;
border-top: 1px solid #ddd;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class DTAutosuggest extends React.Component {
'mode-metro': '#ed8c00',
'mode-ferry': '#007A97',
'mode-citybike': '#f2b62d',
'mode-funicular': '#ff00ff',
},
required: false,
modeSet: undefined,
Expand Down Expand Up @@ -682,6 +683,7 @@ class DTAutosuggest extends React.Component {
value: '',
sources: this.props.sources,
ownPlaces: false,
renderMobileSearch: this.props.isMobile,
};
// must update suggestions
this.setState(newState, () =>
Expand All @@ -695,6 +697,7 @@ class DTAutosuggest extends React.Component {

inputClicked = inputValue => {
this.input.focus();
this.clearLocationText();
if (this.props.isMobile) {
this.props.lock();
}
Expand Down Expand Up @@ -728,6 +731,8 @@ class DTAutosuggest extends React.Component {
this.fetchFunction({ value: this.state.value });
this.setState(newState);
}
} else if (this.props.isMobile && !this.state.renderMobileSearch) {
this.setState({ renderMobileSearch: true });
}
};

Expand Down Expand Up @@ -874,7 +879,7 @@ class DTAutosuggest extends React.Component {
this.props.id === 'via-point' ||
this.props.id === 'origin-stop-near-you';

onFocus = () => {
clearLocationText = () => {
const positions = [
'Valittu sijainti',
'Nykyinen sijaintisi',
Expand All @@ -890,10 +895,13 @@ class DTAutosuggest extends React.Component {
if (positions.includes(this.state.value)) {
this.clearInput();
}
};

onFocus = () => {
this.clearLocationText();

const scrollY = window.pageYOffset;
return this.setState({
scrollY,
});
return this.setState({ scrollY });
};

render() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@digitransit-component/digitransit-component-control-panel",
"version": "1.0.4",
"version": "1.1.1",
"description": "digitransit-component control-panel module",
"main": "index.js",
"files": [
Expand Down Expand Up @@ -29,7 +29,7 @@
"author": "Digitransit Authors",
"license": "(AGPL-3.0 OR EUPL-1.2)",
"peerDependencies": {
"@digitransit-component/digitransit-component-icon": "^0.1.18",
"@digitransit-component/digitransit-component-icon": "^0.2.0",
"@hsl-fi/sass": "~0.2.0",
"classnames": "2.2.6",
"i18next": "^19.3.3",
Expand Down
Loading

0 comments on commit a5c07d8

Please sign in to comment.