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-6040 + DT-6042 #4855

Merged
merged 5 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions app/component/EmbeddedSearch/EmbeddedSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
Expand Down
2 changes: 1 addition & 1 deletion app/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})',
Expand Down
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -165,7 +165,7 @@ function getBackSuggestion() {
]);
}

function getFavouriteStops(stopsAndStations, input) {
function filterFavouriteStops(stopsAndStations, input) {
return stopsAndStations.then(stops => {
return filterMatchingToInput(stops, input, [
'properties.name',
Expand All @@ -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',
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -240,9 +242,9 @@ export function getSearchResults(
) {
const {
getPositions,
getFavouriteLocations: locations,
getOldSearches: prevSearches,
getFavouriteStops: stops,
getFavouriteLocations,
getOldSearches,
getFavouriteStops,
parkingAreaSources,
getLanguage,
getStopAndStationsQuery,
Expand Down Expand Up @@ -295,16 +297,18 @@ export function getSearchResults(
}
if (
targets.includes('SelectFromOwnLocations') &&
hasFavourites(context, locations, stops)
hasFavourites(searchContext)
) {
searchComponents.push(selectFromOwnLocations(input));
}
if (allTargets || targets.includes('Locations')) {
// 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());
}
Expand All @@ -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',
Expand All @@ -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')) {
Expand Down Expand Up @@ -371,7 +377,7 @@ export function getSearchResults(
);
}
if (allSources || sources.includes('History')) {
const history = prevSearches(context);
const history = getOldSearches(context);
const dropLayers = [
'currentPosition',
'selectFromMap',
Expand All @@ -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(
Expand All @@ -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'];
Expand Down Expand Up @@ -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:');
}
Expand All @@ -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),
);
}
}
}
Expand All @@ -503,7 +513,7 @@ export function getSearchResults(
),
);
if (allSources || sources.includes('History')) {
const routeHistory = prevSearches(context);
const routeHistory = getOldSearches(context);
const dropLayers = [
'currentPosition',
'selectFromMap',
Expand All @@ -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,
),
);
Expand Down
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Loading