@internetarchive/collection-browser 1.14.17-alpha.22 → 1.14.17-alpha.24
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/dist/src/collection-browser.d.ts +1 -0
- package/dist/src/collection-browser.js +9 -3
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +9 -0
- package/dist/src/data-source/collection-browser-data-source.js +7 -3
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/models.d.ts +1 -1
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +1 -1
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/test/collection-browser.test.js +2 -6
- package/dist/test/collection-browser.test.js.map +1 -1
- package/package.json +2 -2
- package/src/collection-browser.ts +8 -4
- package/src/data-source/collection-browser-data-source.ts +22 -8
- package/src/data-source/models.ts +1 -1
- package/src/tiles/grid/item-tile.ts +1 -1
- package/test/collection-browser.test.ts +2 -8
|
@@ -134,6 +134,8 @@ export class CollectionBrowser
|
|
|
134
134
|
|
|
135
135
|
@property({ type: Boolean }) suppressFacets = false;
|
|
136
136
|
|
|
137
|
+
@property({ type: Boolean }) suppressSortBar = false;
|
|
138
|
+
|
|
137
139
|
@property({ type: Boolean }) clearResultsOnEmptyQuery = false;
|
|
138
140
|
|
|
139
141
|
@property({ type: String }) collectionPagePath: string = '/details/';
|
|
@@ -260,7 +262,7 @@ export class CollectionBrowser
|
|
|
260
262
|
* We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
|
|
261
263
|
* user may never see.
|
|
262
264
|
*/
|
|
263
|
-
if (!model && !this.isScrollingToCell) {
|
|
265
|
+
if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
|
|
264
266
|
const pageNumber = Math.floor(offsetIndex / this.pageSize) + 1;
|
|
265
267
|
this.dataSource.fetchPage(pageNumber);
|
|
266
268
|
}
|
|
@@ -606,7 +608,9 @@ export class CollectionBrowser
|
|
|
606
608
|
});
|
|
607
609
|
}
|
|
608
610
|
|
|
609
|
-
private get sortFilterBarTemplate() {
|
|
611
|
+
private get sortFilterBarTemplate(): TemplateResult | typeof nothing {
|
|
612
|
+
if (this.suppressSortBar) return nothing;
|
|
613
|
+
|
|
610
614
|
return html`
|
|
611
615
|
<sort-filter-bar
|
|
612
616
|
.defaultSortField=${this.defaultSortField}
|
|
@@ -1415,7 +1419,7 @@ export class CollectionBrowser
|
|
|
1415
1419
|
this.historyPopOccurred = false;
|
|
1416
1420
|
|
|
1417
1421
|
// Fire the initial page and facets requests
|
|
1418
|
-
//await this.dataSource.handleQueryChange();
|
|
1422
|
+
// await this.dataSource.handleQueryChange();
|
|
1419
1423
|
}
|
|
1420
1424
|
|
|
1421
1425
|
private setupStateRestorationObserver() {
|
|
@@ -1703,7 +1707,7 @@ export class CollectionBrowser
|
|
|
1703
1707
|
* increase the number of pages to render and start fetching data for the new page
|
|
1704
1708
|
*/
|
|
1705
1709
|
private scrollThresholdReached() {
|
|
1706
|
-
if (!this.dataSource.endOfDataReached) {
|
|
1710
|
+
if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
|
|
1707
1711
|
this.pagesToRender += 1;
|
|
1708
1712
|
this.dataSource.fetchPage(this.pagesToRender);
|
|
1709
1713
|
}
|
|
@@ -48,6 +48,12 @@ export interface CollectionBrowserDataSourceInterface
|
|
|
48
48
|
*/
|
|
49
49
|
readonly endOfDataReached: boolean;
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* True if the initial work for a new query state has been completed (i.e., firing initial
|
|
53
|
+
* page/facet requests). False otherwise.
|
|
54
|
+
*/
|
|
55
|
+
readonly queryInitialized: boolean;
|
|
56
|
+
|
|
51
57
|
/**
|
|
52
58
|
* A string key compactly representing the current full search state, which can
|
|
53
59
|
* be used to determine, e.g., when a new search is required or whether an arriving
|
|
@@ -273,6 +279,11 @@ export class CollectionBrowserDataSource
|
|
|
273
279
|
*/
|
|
274
280
|
endOfDataReached = false;
|
|
275
281
|
|
|
282
|
+
/**
|
|
283
|
+
* @inheritdoc
|
|
284
|
+
*/
|
|
285
|
+
queryInitialized = false;
|
|
286
|
+
|
|
276
287
|
/**
|
|
277
288
|
* @inheritdoc
|
|
278
289
|
*/
|
|
@@ -364,7 +375,8 @@ export class CollectionBrowserDataSource
|
|
|
364
375
|
// We should only reset if either:
|
|
365
376
|
// (a) our state permits a valid search, or
|
|
366
377
|
// (b) we have a blank query that we want to show empty results for
|
|
367
|
-
const shouldShowEmptyQueryResults =
|
|
378
|
+
const shouldShowEmptyQueryResults =
|
|
379
|
+
this.host.clearResultsOnEmptyQuery && this.host.baseQuery === '';
|
|
368
380
|
if (!(this.canPerformSearch || shouldShowEmptyQueryResults)) return;
|
|
369
381
|
|
|
370
382
|
this.handleQueryChange();
|
|
@@ -393,6 +405,7 @@ export class CollectionBrowserDataSource
|
|
|
393
405
|
this.numTileModels = 0;
|
|
394
406
|
this.totalResults = 0;
|
|
395
407
|
this.endOfDataReached = false;
|
|
408
|
+
this.queryInitialized = false;
|
|
396
409
|
|
|
397
410
|
this.host.requestUpdate();
|
|
398
411
|
}
|
|
@@ -463,6 +476,7 @@ export class CollectionBrowserDataSource
|
|
|
463
476
|
});
|
|
464
477
|
|
|
465
478
|
// Fire the initial page & facet requests
|
|
479
|
+
this.queryInitialized = true;
|
|
466
480
|
await Promise.all([
|
|
467
481
|
this.doInitialPageFetch(),
|
|
468
482
|
this.host.suppressFacets ? null : this.fetchFacets(),
|
|
@@ -942,7 +956,11 @@ export class CollectionBrowserDataSource
|
|
|
942
956
|
const queryChangedSinceFetch =
|
|
943
957
|
facetFetchQueryKey !== this.facetFetchQueryKey;
|
|
944
958
|
if (queryChangedSinceFetch) {
|
|
945
|
-
console.log(
|
|
959
|
+
console.log(
|
|
960
|
+
'facet query has changed since fetch, returning. new/old:',
|
|
961
|
+
this.facetFetchQueryKey,
|
|
962
|
+
facetFetchQueryKey
|
|
963
|
+
);
|
|
946
964
|
return;
|
|
947
965
|
}
|
|
948
966
|
|
|
@@ -1014,12 +1032,8 @@ export class CollectionBrowserDataSource
|
|
|
1014
1032
|
const { pageFetchQueryKey } = this;
|
|
1015
1033
|
const pageFetches =
|
|
1016
1034
|
this.pageFetchesInProgress[pageFetchQueryKey] ?? new Set();
|
|
1017
|
-
if (pageFetches.has(pageNumber))
|
|
1018
|
-
|
|
1019
|
-
`Skipping fetch for page ${pageNumber} because one is already in progress`
|
|
1020
|
-
);
|
|
1021
|
-
return;
|
|
1022
|
-
}
|
|
1035
|
+
if (pageFetches.has(pageNumber)) return;
|
|
1036
|
+
|
|
1023
1037
|
for (let i = 0; i < numPages; i += 1) {
|
|
1024
1038
|
pageFetches.add(pageNumber + i);
|
|
1025
1039
|
}
|
|
@@ -66,7 +66,7 @@ export interface CollectionBrowserSearchInterface
|
|
|
66
66
|
readonly initialPageNumber: number;
|
|
67
67
|
readonly currentVisiblePageNumbers: number[];
|
|
68
68
|
readonly clearResultsOnEmptyQuery?: boolean;
|
|
69
|
-
readonly dataSource
|
|
69
|
+
readonly dataSource?: CollectionBrowserDataSourceInterface;
|
|
70
70
|
|
|
71
71
|
getSessionId(): Promise<string>;
|
|
72
72
|
setSearchResultsLoading(loading: boolean): void;
|
|
@@ -4,7 +4,7 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { msg } from '@lit/localize';
|
|
6
6
|
|
|
7
|
-
import { map } from 'lit/directives/map';
|
|
7
|
+
import { map } from 'lit/directives/map.js';
|
|
8
8
|
import { DateFormat, formatDate } from '../../utils/format-date';
|
|
9
9
|
import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
|
|
10
10
|
import { BaseTileComponent } from '../base-tile-component';
|
|
@@ -917,7 +917,7 @@ describe('Collection Browser', () => {
|
|
|
917
917
|
el.sortDirection = 'asc';
|
|
918
918
|
el.selectedCreatorFilter = 'X';
|
|
919
919
|
await el.updateComplete;
|
|
920
|
-
await
|
|
920
|
+
await nextTick();
|
|
921
921
|
|
|
922
922
|
expect(searchService.searchParams?.query).to.equal('first-creator');
|
|
923
923
|
expect(searchService.searchParams?.filters?.firstCreator?.X).to.equal(
|
|
@@ -926,7 +926,7 @@ describe('Collection Browser', () => {
|
|
|
926
926
|
|
|
927
927
|
el.baseQuery = 'collection:foo';
|
|
928
928
|
await el.updateComplete;
|
|
929
|
-
await
|
|
929
|
+
await nextTick();
|
|
930
930
|
|
|
931
931
|
expect(searchService.searchParams?.query).to.equal('collection:foo');
|
|
932
932
|
expect(searchService.searchParams?.filters?.firstCreator).not.to.exist;
|
|
@@ -1446,9 +1446,6 @@ describe('Collection Browser', () => {
|
|
|
1446
1446
|
</collection-browser>`
|
|
1447
1447
|
);
|
|
1448
1448
|
|
|
1449
|
-
await el.initialSearchComplete;
|
|
1450
|
-
await el.updateComplete;
|
|
1451
|
-
|
|
1452
1449
|
el.baseQuery = 'bar';
|
|
1453
1450
|
await el.updateComplete;
|
|
1454
1451
|
|
|
@@ -1484,9 +1481,6 @@ describe('Collection Browser', () => {
|
|
|
1484
1481
|
</collection-browser>`
|
|
1485
1482
|
);
|
|
1486
1483
|
|
|
1487
|
-
await el.initialSearchComplete;
|
|
1488
|
-
await el.updateComplete;
|
|
1489
|
-
|
|
1490
1484
|
el.withinCollection = 'bar';
|
|
1491
1485
|
await el.updateComplete;
|
|
1492
1486
|
|