diff --git a/app/component/EmbeddedSearch/EmbeddedSearch.js b/app/component/EmbeddedSearch/EmbeddedSearch.js index aec9569562..1feded154a 100644 --- a/app/component/EmbeddedSearch/EmbeddedSearch.js +++ b/app/component/EmbeddedSearch/EmbeddedSearch.js @@ -40,9 +40,9 @@ const translations = { }, sv: { 'own-position': 'Min position', - 'find-bike-route': 'Sök en cyckelrutt', - 'find-walk-route': 'Sök en promenadsrutt', - 'find-route': 'Sök en rutt', + 'find-bike-route': 'Sök cykelrutt', + 'find-walk-route': 'Sök promenadrutt', + 'find-route': 'Sök rutt', 'search-fields-sr-instructions': '', 'search-route': 'Söka rutter', }, diff --git a/app/translations.js b/app/translations.js index 3fe04edf42..e1dfc6bbe1 100644 --- a/app/translations.js +++ b/app/translations.js @@ -3956,7 +3956,7 @@ const translations = { 'avoid-walking': 'Undvik gång', 'back-button-title': 'Tillbaka till föregående sida', 'back-to-front-page': 'Tillbaka till framsidan ›', - bicycle: 'cyckel', + bicycle: 'cykel', 'bicycle-distance-duration': 'Cykla {duration} ({distance})', 'bicycle-walk-from-transit': 'Ta cykeln från {transportMode} och led cykeln {distance} ({duration})', diff --git a/digitransit-component/packages/digitransit-component-autosuggest-panel/package.json b/digitransit-component/packages/digitransit-component-autosuggest-panel/package.json index 17240d291a..7e9bc8028d 100644 --- a/digitransit-component/packages/digitransit-component-autosuggest-panel/package.json +++ b/digitransit-component/packages/digitransit-component-autosuggest-panel/package.json @@ -1,6 +1,6 @@ { "name": "@digitransit-component/digitransit-component-autosuggest-panel", - "version": "2.0.6", + "version": "2.0.7", "description": "digitransit-component autosuggest-panel module", "main": "index.js", "files": [ @@ -28,7 +28,7 @@ "author": "Digitransit Authors", "license": "(AGPL-3.0 OR EUPL-1.2)", "peerDependencies": { - "@digitransit-component/digitransit-component-autosuggest": "^1.9.10", + "@digitransit-component/digitransit-component-autosuggest": "^1.9.11", "@digitransit-component/digitransit-component-icon": "^0.2.2", "@hsl-fi/sass": "^0.2.0", "classnames": "2.2.6", diff --git a/digitransit-component/packages/digitransit-component-autosuggest/package.json b/digitransit-component/packages/digitransit-component-autosuggest/package.json index c9f92b32e4..ec797e881f 100644 --- a/digitransit-component/packages/digitransit-component-autosuggest/package.json +++ b/digitransit-component/packages/digitransit-component-autosuggest/package.json @@ -1,6 +1,6 @@ { "name": "@digitransit-component/digitransit-component-autosuggest", - "version": "1.9.10", + "version": "1.9.11", "description": "digitransit-component autosuggest module", "main": "index.js", "files": [ @@ -29,7 +29,7 @@ "author": "Digitransit Authors", "license": "(AGPL-3.0 OR EUPL-1.2)", "dependencies": { - "@digitransit-search-util/digitransit-search-util-execute-search-immidiate": "^1.3.3", + "@digitransit-search-util/digitransit-search-util-execute-search-immidiate": "^1.3.4", "@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.3" diff --git a/digitransit-component/packages/digitransit-component/package.json b/digitransit-component/packages/digitransit-component/package.json index b6f508cb4f..f7e4bbc17e 100644 --- a/digitransit-component/packages/digitransit-component/package.json +++ b/digitransit-component/packages/digitransit-component/package.json @@ -14,8 +14,8 @@ "docs": "node -r esm ../../scripts/generate-readmes" }, "dependencies": { - "@digitransit-component/digitransit-component-autosuggest": "^1.9.9", - "@digitransit-component/digitransit-component-autosuggest-panel": "^2.0.5", + "@digitransit-component/digitransit-component-autosuggest": "^1.9.11", + "@digitransit-component/digitransit-component-autosuggest-panel": "^2.0.7", "@digitransit-component/digitransit-component-control-panel": "^1.1.3", "@digitransit-component/digitransit-component-favourite-bar": "1.1.3", "@digitransit-component/digitransit-component-favourite-editing-modal": "^1.1.4", diff --git a/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/index.js b/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/index.js index 3548a6573b..25926165c9 100644 --- a/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/index.js +++ b/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/index.js @@ -54,7 +54,7 @@ function getStopsFromGeocoding(stops, URL_PELIAS_PLACE) { }); }); } -function getFavouriteLocations(favourites, input) { +function filterFavouriteLocations(favourites, input) { return Promise.resolve( filterMatchingToInput(favourites, input, ['address', 'name']).map(item => ({ type: 'FavouritePlace', @@ -165,7 +165,7 @@ function getBackSuggestion() { ]); } -function getFavouriteStops(stopsAndStations, input) { +function filterFavouriteStops(stopsAndStations, input) { return stopsAndStations.then(stops => { return filterMatchingToInput(stops, input, [ 'properties.name', @@ -175,7 +175,7 @@ function getFavouriteStops(stopsAndStations, input) { }); } -function getOldSearches(oldSearches, input, dropLayers) { +function filterOldSearches(oldSearches, input, dropLayers) { let matchingOldSearches = filterMatchingToInput(oldSearches, input, [ 'properties.name', 'properties.label', @@ -203,13 +203,15 @@ function getOldSearches(oldSearches, input, dropLayers) { ); } -function hasFavourites(context, locations, stops) { - const favouriteLocations = locations(context); - if (favouriteLocations && favouriteLocations.length > 0) { +function hasFavourites(searchContext) { + const favouriteLocations = searchContext.getFavouriteLocations( + searchContext.context, + ); + if (favouriteLocations?.length > 0) { return true; } - const favouriteStops = stops(context); - return favouriteStops && favouriteStops.length > 0; + const favouriteStops = searchContext.getFavouriteStops(searchContext.context); + return favouriteStops?.length > 0; } const routeLayers = [ @@ -240,9 +242,9 @@ export function getSearchResults( ) { const { getPositions, - getFavouriteLocations: locations, - getOldSearches: prevSearches, - getFavouriteStops: stops, + getFavouriteLocations, + getOldSearches, + getFavouriteStops, parkingAreaSources, getLanguage, getStopAndStationsQuery, @@ -295,7 +297,7 @@ export function getSearchResults( } if ( targets.includes('SelectFromOwnLocations') && - hasFavourites(context, locations, stops) + hasFavourites(searchContext) ) { searchComponents.push(selectFromOwnLocations(input)); } @@ -303,8 +305,10 @@ export function getSearchResults( // eslint-disable-next-line prefer-destructuring const searchParams = geocodingSearchParams; if (sources.includes('Favourite')) { - const favouriteLocations = locations(context); - searchComponents.push(getFavouriteLocations(favouriteLocations, input)); + const favouriteLocations = getFavouriteLocations(context); + searchComponents.push( + filterFavouriteLocations(favouriteLocations, input), + ); if (sources.includes('Back')) { searchComponents.push(getBackSuggestion()); } @@ -328,7 +332,7 @@ export function getSearchResults( ); } if (allSources || sources.includes('History')) { - const locationHistory = prevSearches(context, 'endpoint'); + const locationHistory = getOldSearches(context, 'endpoint'); const dropLayers = [ 'currentPosition', 'selectFromMap', @@ -341,7 +345,9 @@ export function getSearchResults( 'back', ]; dropLayers.push(...routeLayers); - searchComponents.push(getOldSearches(locationHistory, input, dropLayers)); + searchComponents.push( + filterOldSearches(locationHistory, input, dropLayers), + ); } } if (allTargets || targets.includes('ParkingAreas')) { @@ -371,7 +377,7 @@ export function getSearchResults( ); } if (allSources || sources.includes('History')) { - const history = prevSearches(context); + const history = getOldSearches(context); const dropLayers = [ 'currentPosition', 'selectFromMap', @@ -381,16 +387,18 @@ export function getSearchResults( 'bikestation', 'bikeRentalStation', 'back', + 'stop', + 'station', ]; dropLayers.push(...routeLayers); dropLayers.push(...locationLayers); - searchComponents.push(getOldSearches(history, input, dropLayers)); + searchComponents.push(filterOldSearches(history, input, dropLayers)); } } if (allTargets || targets.includes('Stops')) { if (sources.includes('Favourite')) { - const favouriteStops = stops(context); + const favouriteStops = getFavouriteStops(context); let stopsAndStations; if (favouriteStops.every(stop => stop.type === 'station')) { stopsAndStations = getStopsFromGeocoding( @@ -414,7 +422,7 @@ export function getSearchResults( return results; }); } - searchComponents.push(getFavouriteStops(stopsAndStations, input)); + searchComponents.push(filterFavouriteStops(stopsAndStations, input)); } if (allSources || sources.includes('Datasource')) { const geocodingLayers = ['stop', 'station']; @@ -449,7 +457,7 @@ export function getSearchResults( ); } if (allSources || sources.includes('History')) { - const stopHistory = prevSearches(context).filter(item => { + const stopHistory = getOldSearches(context).filter(item => { if (item.properties.gid) { return item.properties.gid.includes('GTFS:'); } @@ -473,12 +481,14 @@ export function getSearchResults( dropLayers.push('bikestation'); } searchComponents.push( - getOldSearches(stopHistory, input, dropLayers).then(result => + filterOldSearches(stopHistory, input, dropLayers).then(result => filterResults ? filterResults(result, mode) : result, ), ); } else { - searchComponents.push(getOldSearches(stopHistory, input, dropLayers)); + searchComponents.push( + filterOldSearches(stopHistory, input, dropLayers), + ); } } } @@ -503,7 +513,7 @@ export function getSearchResults( ), ); if (allSources || sources.includes('History')) { - const routeHistory = prevSearches(context); + const routeHistory = getOldSearches(context); const dropLayers = [ 'currentPosition', 'selectFromMap', @@ -525,7 +535,7 @@ export function getSearchResults( } dropLayers.push(...locationLayers); searchComponents.push( - getOldSearches(routeHistory, input, dropLayers).then(results => + filterOldSearches(routeHistory, input, dropLayers).then(results => filterResults ? filterResults(results, mode, 'Routes') : results, ), ); diff --git a/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/package.json b/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/package.json index 02dc93544c..f260385e6e 100644 --- a/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/package.json +++ b/digitransit-search-util/packages/digitransit-search-util-execute-search-immidiate/package.json @@ -1,6 +1,6 @@ { "name": "@digitransit-search-util/digitransit-search-util-execute-search-immidiate", - "version": "1.3.3", + "version": "1.3.4", "description": "digitransit-search-util execute-search-immidiate module", "main": "index.js", "publishConfig": {