@digitransit-search-util/digitransit-search-util-execute-search-immidiate 1.3.2 → 1.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +39 -25
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -54,7 +54,7 @@ function getStopsFromGeocoding(stops, URL_PELIAS_PLACE) {
|
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function filterFavouriteLocations(favourites, input) {
|
|
58
58
|
return Promise.resolve(
|
|
59
59
|
filterMatchingToInput(favourites, input, ['address', 'name']).map(item => ({
|
|
60
60
|
type: 'FavouritePlace',
|
|
@@ -165,7 +165,7 @@ function getBackSuggestion() {
|
|
|
165
165
|
]);
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
function
|
|
168
|
+
function filterFavouriteStops(stopsAndStations, input) {
|
|
169
169
|
return stopsAndStations.then(stops => {
|
|
170
170
|
return filterMatchingToInput(stops, input, [
|
|
171
171
|
'properties.name',
|
|
@@ -175,7 +175,7 @@ function getFavouriteStops(stopsAndStations, input) {
|
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
function
|
|
178
|
+
function filterOldSearches(oldSearches, input, dropLayers) {
|
|
179
179
|
let matchingOldSearches = filterMatchingToInput(oldSearches, input, [
|
|
180
180
|
'properties.name',
|
|
181
181
|
'properties.label',
|
|
@@ -203,13 +203,15 @@ function getOldSearches(oldSearches, input, dropLayers) {
|
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
function hasFavourites(
|
|
207
|
-
const favouriteLocations =
|
|
208
|
-
|
|
206
|
+
function hasFavourites(searchContext) {
|
|
207
|
+
const favouriteLocations = searchContext.getFavouriteLocations(
|
|
208
|
+
searchContext.context,
|
|
209
|
+
);
|
|
210
|
+
if (favouriteLocations?.length > 0) {
|
|
209
211
|
return true;
|
|
210
212
|
}
|
|
211
|
-
const favouriteStops =
|
|
212
|
-
return favouriteStops
|
|
213
|
+
const favouriteStops = searchContext.getFavouriteStops(searchContext.context);
|
|
214
|
+
return favouriteStops?.length > 0;
|
|
213
215
|
}
|
|
214
216
|
|
|
215
217
|
const routeLayers = [
|
|
@@ -240,9 +242,9 @@ export function getSearchResults(
|
|
|
240
242
|
) {
|
|
241
243
|
const {
|
|
242
244
|
getPositions,
|
|
243
|
-
getFavouriteLocations
|
|
244
|
-
getOldSearches
|
|
245
|
-
getFavouriteStops
|
|
245
|
+
getFavouriteLocations,
|
|
246
|
+
getOldSearches,
|
|
247
|
+
getFavouriteStops,
|
|
246
248
|
parkingAreaSources,
|
|
247
249
|
getLanguage,
|
|
248
250
|
getStopAndStationsQuery,
|
|
@@ -295,7 +297,7 @@ export function getSearchResults(
|
|
|
295
297
|
}
|
|
296
298
|
if (
|
|
297
299
|
targets.includes('SelectFromOwnLocations') &&
|
|
298
|
-
hasFavourites(
|
|
300
|
+
hasFavourites(searchContext)
|
|
299
301
|
) {
|
|
300
302
|
searchComponents.push(selectFromOwnLocations(input));
|
|
301
303
|
}
|
|
@@ -303,8 +305,10 @@ export function getSearchResults(
|
|
|
303
305
|
// eslint-disable-next-line prefer-destructuring
|
|
304
306
|
const searchParams = geocodingSearchParams;
|
|
305
307
|
if (sources.includes('Favourite')) {
|
|
306
|
-
const favouriteLocations =
|
|
307
|
-
searchComponents.push(
|
|
308
|
+
const favouriteLocations = getFavouriteLocations(context);
|
|
309
|
+
searchComponents.push(
|
|
310
|
+
filterFavouriteLocations(favouriteLocations, input),
|
|
311
|
+
);
|
|
308
312
|
if (sources.includes('Back')) {
|
|
309
313
|
searchComponents.push(getBackSuggestion());
|
|
310
314
|
}
|
|
@@ -328,7 +332,7 @@ export function getSearchResults(
|
|
|
328
332
|
);
|
|
329
333
|
}
|
|
330
334
|
if (allSources || sources.includes('History')) {
|
|
331
|
-
const locationHistory =
|
|
335
|
+
const locationHistory = getOldSearches(context, 'endpoint');
|
|
332
336
|
const dropLayers = [
|
|
333
337
|
'currentPosition',
|
|
334
338
|
'selectFromMap',
|
|
@@ -341,7 +345,9 @@ export function getSearchResults(
|
|
|
341
345
|
'back',
|
|
342
346
|
];
|
|
343
347
|
dropLayers.push(...routeLayers);
|
|
344
|
-
searchComponents.push(
|
|
348
|
+
searchComponents.push(
|
|
349
|
+
filterOldSearches(locationHistory, input, dropLayers),
|
|
350
|
+
);
|
|
345
351
|
}
|
|
346
352
|
}
|
|
347
353
|
if (allTargets || targets.includes('ParkingAreas')) {
|
|
@@ -371,7 +377,7 @@ export function getSearchResults(
|
|
|
371
377
|
);
|
|
372
378
|
}
|
|
373
379
|
if (allSources || sources.includes('History')) {
|
|
374
|
-
const history =
|
|
380
|
+
const history = getOldSearches(context);
|
|
375
381
|
const dropLayers = [
|
|
376
382
|
'currentPosition',
|
|
377
383
|
'selectFromMap',
|
|
@@ -381,16 +387,18 @@ export function getSearchResults(
|
|
|
381
387
|
'bikestation',
|
|
382
388
|
'bikeRentalStation',
|
|
383
389
|
'back',
|
|
390
|
+
'stop',
|
|
391
|
+
'station',
|
|
384
392
|
];
|
|
385
393
|
dropLayers.push(...routeLayers);
|
|
386
394
|
dropLayers.push(...locationLayers);
|
|
387
|
-
searchComponents.push(
|
|
395
|
+
searchComponents.push(filterOldSearches(history, input, dropLayers));
|
|
388
396
|
}
|
|
389
397
|
}
|
|
390
398
|
|
|
391
399
|
if (allTargets || targets.includes('Stops')) {
|
|
392
400
|
if (sources.includes('Favourite')) {
|
|
393
|
-
const favouriteStops =
|
|
401
|
+
const favouriteStops = getFavouriteStops(context);
|
|
394
402
|
let stopsAndStations;
|
|
395
403
|
if (favouriteStops.every(stop => stop.type === 'station')) {
|
|
396
404
|
stopsAndStations = getStopsFromGeocoding(
|
|
@@ -414,12 +422,16 @@ export function getSearchResults(
|
|
|
414
422
|
return results;
|
|
415
423
|
});
|
|
416
424
|
}
|
|
417
|
-
searchComponents.push(
|
|
425
|
+
searchComponents.push(filterFavouriteStops(stopsAndStations, input));
|
|
418
426
|
}
|
|
419
427
|
if (allSources || sources.includes('Datasource')) {
|
|
420
428
|
const geocodingLayers = ['stop', 'station'];
|
|
421
429
|
const searchParams =
|
|
422
430
|
geocodingSize && geocodingSize !== 10 ? { size: geocodingSize } : {};
|
|
431
|
+
if (geocodingSearchParams && geocodingSearchParams['boundary.country']) {
|
|
432
|
+
searchParams['boundary.country'] =
|
|
433
|
+
geocodingSearchParams['boundary.country'];
|
|
434
|
+
}
|
|
423
435
|
// a little hack: when searching location data, automatically dedupe stops
|
|
424
436
|
// this could be a new explicit prop
|
|
425
437
|
if (allTargets || targets.includes('Locations')) {
|
|
@@ -445,7 +457,7 @@ export function getSearchResults(
|
|
|
445
457
|
);
|
|
446
458
|
}
|
|
447
459
|
if (allSources || sources.includes('History')) {
|
|
448
|
-
const stopHistory =
|
|
460
|
+
const stopHistory = getOldSearches(context).filter(item => {
|
|
449
461
|
if (item.properties.gid) {
|
|
450
462
|
return item.properties.gid.includes('GTFS:');
|
|
451
463
|
}
|
|
@@ -469,12 +481,14 @@ export function getSearchResults(
|
|
|
469
481
|
dropLayers.push('bikestation');
|
|
470
482
|
}
|
|
471
483
|
searchComponents.push(
|
|
472
|
-
|
|
484
|
+
filterOldSearches(stopHistory, input, dropLayers).then(result =>
|
|
473
485
|
filterResults ? filterResults(result, mode) : result,
|
|
474
486
|
),
|
|
475
487
|
);
|
|
476
488
|
} else {
|
|
477
|
-
searchComponents.push(
|
|
489
|
+
searchComponents.push(
|
|
490
|
+
filterOldSearches(stopHistory, input, dropLayers),
|
|
491
|
+
);
|
|
478
492
|
}
|
|
479
493
|
}
|
|
480
494
|
}
|
|
@@ -499,7 +513,7 @@ export function getSearchResults(
|
|
|
499
513
|
),
|
|
500
514
|
);
|
|
501
515
|
if (allSources || sources.includes('History')) {
|
|
502
|
-
const routeHistory =
|
|
516
|
+
const routeHistory = getOldSearches(context);
|
|
503
517
|
const dropLayers = [
|
|
504
518
|
'currentPosition',
|
|
505
519
|
'selectFromMap',
|
|
@@ -521,7 +535,7 @@ export function getSearchResults(
|
|
|
521
535
|
}
|
|
522
536
|
dropLayers.push(...locationLayers);
|
|
523
537
|
searchComponents.push(
|
|
524
|
-
|
|
538
|
+
filterOldSearches(routeHistory, input, dropLayers).then(results =>
|
|
525
539
|
filterResults ? filterResults(results, mode, 'Routes') : results,
|
|
526
540
|
),
|
|
527
541
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitransit-search-util/digitransit-search-util-execute-search-immidiate",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
4
4
|
"description": "digitransit-search-util execute-search-immidiate module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -28,5 +28,5 @@
|
|
|
28
28
|
"@digitransit-search-util/digitransit-search-util-uniq-by-label": "^1.1.0",
|
|
29
29
|
"lodash": "4.17.21"
|
|
30
30
|
},
|
|
31
|
-
"gitHead": "
|
|
31
|
+
"gitHead": "60e0495cfef7163c4c77f0b6a7f1c8c2f31224e2"
|
|
32
32
|
}
|