@internetarchive/collection-browser 1.14.17 → 2.0.0
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/index.d.ts +4 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +0 -2
- package/dist/src/app-root.js +0 -8
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +49 -200
- package/dist/src/collection-browser.js +191 -762
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.d.ts +2 -2
- package/dist/src/collection-facets/facet-row.js +5 -10
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/facets-template.d.ts +2 -2
- package/dist/src/collection-facets/facets-template.js +2 -2
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +2 -9
- package/dist/src/collection-facets/more-facets-content.js +13 -18
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets.d.ts +2 -3
- package/dist/src/collection-facets.js +12 -13
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +217 -0
- package/dist/src/data-source/collection-browser-data-source-interface.js +2 -0
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -0
- package/dist/src/data-source/collection-browser-data-source.d.ts +352 -0
- package/dist/src/data-source/collection-browser-data-source.js +912 -0
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -0
- package/dist/src/data-source/collection-browser-query-state.d.ts +43 -0
- package/dist/src/data-source/collection-browser-query-state.js +2 -0
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -0
- package/dist/src/data-source/models.d.ts +28 -0
- package/dist/src/data-source/models.js +9 -0
- package/dist/src/data-source/models.js.map +1 -0
- package/dist/src/manage/manage-bar.d.ts +1 -1
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/models.d.ts +21 -4
- package/dist/src/models.js +111 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +26 -23
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +1 -0
- package/dist/src/tiles/grid/item-tile.js +28 -1
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +13 -8
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +2 -2
- package/dist/src/tiles/hover/hover-pane-controller.js +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +2 -2
- package/dist/src/tiles/hover/tile-hover-pane.js +2 -2
- package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
- package/dist/src/tiles/item-image.d.ts +3 -0
- package/dist/src/tiles/item-image.js +30 -2
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +4 -3
- package/dist/src/tiles/list/tile-list.js +39 -14
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +2 -2
- package/dist/src/tiles/tile-dispatcher.js +5 -5
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +6 -2
- package/dist/src/tiles/tile-display-value-provider.js +15 -1
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
- package/dist/src/utils/collapse-repeated-quotes.js +14 -0
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
- package/dist/src/utils/log.d.ts +7 -0
- package/dist/src/utils/log.js +16 -0
- package/dist/src/utils/log.js.map +1 -0
- package/dist/src/utils/resolve-mediatype.d.ts +8 -0
- package/dist/src/utils/resolve-mediatype.js +24 -0
- package/dist/src/utils/resolve-mediatype.js.map +1 -0
- package/dist/test/collection-browser.test.js +142 -92
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/facet-row.test.js +6 -17
- package/dist/test/collection-facets/facet-row.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +2 -2
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +5 -5
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -0
- package/dist/test/data-source/collection-browser-data-source.test.js +80 -0
- package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -0
- package/dist/test/item-image.test.js +33 -34
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +3 -0
- package/dist/test/mocks/mock-search-responses.js +131 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +4 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +41 -4
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/tile-stats.test.js +62 -0
- package/dist/test/tile-stats.test.js.map +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +44 -0
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +18 -17
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/dist/test/tiles/list/tile-list.test.js +44 -5
- package/dist/test/tiles/list/tile-list.test.js.map +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +12 -0
- package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
- package/index.ts +4 -1
- package/package.json +3 -4
- package/src/app-root.ts +0 -10
- package/src/collection-browser.ts +219 -935
- package/src/collection-facets/facet-row.ts +4 -9
- package/src/collection-facets/facets-template.ts +3 -3
- package/src/collection-facets/more-facets-content.ts +15 -20
- package/src/collection-facets.ts +11 -14
- package/src/data-source/collection-browser-data-source-interface.ts +272 -0
- package/src/data-source/collection-browser-data-source.ts +1166 -0
- package/src/data-source/collection-browser-query-state.ts +54 -0
- package/src/data-source/models.ts +38 -0
- package/src/manage/manage-bar.ts +1 -1
- package/src/models.ts +164 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +26 -23
- package/src/tiles/grid/item-tile.ts +36 -1
- package/src/tiles/grid/tile-stats.ts +12 -7
- package/src/tiles/hover/hover-pane-controller.ts +3 -3
- package/src/tiles/hover/tile-hover-pane.ts +3 -3
- package/src/tiles/item-image.ts +28 -0
- package/src/tiles/list/tile-list.ts +56 -23
- package/src/tiles/tile-dispatcher.ts +5 -5
- package/src/tiles/tile-display-value-provider.ts +20 -2
- package/src/utils/collapse-repeated-quotes.ts +13 -0
- package/src/utils/log.ts +16 -0
- package/src/utils/resolve-mediatype.ts +26 -0
- package/test/collection-browser.test.ts +213 -106
- package/test/collection-facets/facet-row.test.ts +5 -18
- package/test/collection-facets/more-facets-content.test.ts +4 -2
- package/test/collection-facets.test.ts +5 -5
- package/test/data-source/collection-browser-data-source.test.ts +103 -0
- package/test/item-image.test.ts +34 -36
- package/test/mocks/mock-search-responses.ts +144 -0
- package/test/mocks/mock-search-service.ts +6 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +50 -4
- package/test/tile-stats.test.ts +104 -0
- package/test/tiles/grid/item-tile.test.ts +55 -0
- package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
- package/test/tiles/list/tile-list.test.ts +55 -5
- package/test/tiles/tile-dispatcher.test.ts +13 -0
- package/dist/test/mocks/mock-collection-name-cache.d.ts +0 -9
- package/dist/test/mocks/mock-collection-name-cache.js +0 -18
- package/dist/test/mocks/mock-collection-name-cache.js.map +0 -1
- package/test/mocks/mock-collection-name-cache.ts +0 -24
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
nothing,
|
|
8
8
|
} from 'lit';
|
|
9
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
-
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
11
10
|
import eyeIcon from '../assets/img/icons/eye';
|
|
12
11
|
import eyeClosedIcon from '../assets/img/icons/eye-closed';
|
|
13
12
|
import type {
|
|
@@ -16,6 +15,7 @@ import type {
|
|
|
16
15
|
FacetEventDetails,
|
|
17
16
|
FacetState,
|
|
18
17
|
} from '../models';
|
|
18
|
+
import type { CollectionTitles } from '../data-source/models';
|
|
19
19
|
|
|
20
20
|
@customElement('facet-row')
|
|
21
21
|
export class FacetRow extends LitElement {
|
|
@@ -31,7 +31,7 @@ export class FacetRow extends LitElement {
|
|
|
31
31
|
|
|
32
32
|
/** The collection name cache for converting collection identifiers to titles */
|
|
33
33
|
@property({ type: Object })
|
|
34
|
-
|
|
34
|
+
collectionTitles?: CollectionTitles;
|
|
35
35
|
|
|
36
36
|
//
|
|
37
37
|
// COMPONENT LIFECYCLE METHODS
|
|
@@ -56,18 +56,13 @@ export class FacetRow extends LitElement {
|
|
|
56
56
|
const showOnlyCheckboxId = `${facetType}:${bucket.key}-show-only`;
|
|
57
57
|
const negativeCheckboxId = `${facetType}:${bucket.key}-negative`;
|
|
58
58
|
|
|
59
|
-
// For collections, we
|
|
60
|
-
// so we use the `async-collection-name` widget.
|
|
59
|
+
// For collections, we render the collection title as a link.
|
|
61
60
|
// For other facet types, we just have a static value to use.
|
|
62
61
|
const bucketTextDisplay =
|
|
63
62
|
facetType !== 'collection'
|
|
64
63
|
? html`${bucket.displayText ?? bucket.key}`
|
|
65
64
|
: html`<a href="/details/${bucket.key}">
|
|
66
|
-
|
|
67
|
-
.collectionNameCache=${this.collectionNameCache}
|
|
68
|
-
.identifier=${bucket.key}
|
|
69
|
-
placeholder="-"
|
|
70
|
-
></async-collection-name>
|
|
65
|
+
${this.collectionTitles?.get(bucket.key) ?? bucket.key}
|
|
71
66
|
</a> `;
|
|
72
67
|
|
|
73
68
|
const facetHidden = bucket.state === 'hidden';
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from 'lit';
|
|
9
9
|
import { customElement, property } from 'lit/decorators.js';
|
|
10
10
|
import { repeat } from 'lit/directives/repeat.js';
|
|
11
|
-
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
12
11
|
import {
|
|
13
12
|
FacetGroup,
|
|
14
13
|
FacetBucket,
|
|
@@ -16,6 +15,7 @@ import {
|
|
|
16
15
|
getDefaultSelectedFacets,
|
|
17
16
|
FacetEventDetails,
|
|
18
17
|
} from '../models';
|
|
18
|
+
import type { CollectionTitles } from '../data-source/models';
|
|
19
19
|
import { FacetRow } from './facet-row';
|
|
20
20
|
|
|
21
21
|
@customElement('facets-template')
|
|
@@ -27,7 +27,7 @@ export class FacetsTemplate extends LitElement {
|
|
|
27
27
|
@property({ type: String }) renderOn?: string;
|
|
28
28
|
|
|
29
29
|
@property({ type: Object })
|
|
30
|
-
|
|
30
|
+
collectionTitles?: CollectionTitles;
|
|
31
31
|
|
|
32
32
|
private facetClicked(e: CustomEvent<FacetEventDetails>) {
|
|
33
33
|
const { bucket, negative } = e.detail;
|
|
@@ -126,7 +126,7 @@ export class FacetsTemplate extends LitElement {
|
|
|
126
126
|
bucket => html`<facet-row
|
|
127
127
|
.facetType=${facetGroup.key}
|
|
128
128
|
.bucket=${bucket}
|
|
129
|
-
.
|
|
129
|
+
.collectionTitles=${this.collectionTitles}
|
|
130
130
|
@facetClick=${this.facetClicked}
|
|
131
131
|
></facet-row>`
|
|
132
132
|
)}
|
|
@@ -13,13 +13,13 @@ import { customElement, property, state } from 'lit/decorators.js';
|
|
|
13
13
|
import {
|
|
14
14
|
Aggregation,
|
|
15
15
|
Bucket,
|
|
16
|
+
PageType,
|
|
16
17
|
SearchServiceInterface,
|
|
17
18
|
SearchParams,
|
|
18
19
|
SearchType,
|
|
19
20
|
AggregationSortType,
|
|
20
21
|
FilterMap,
|
|
21
22
|
} from '@internetarchive/search-service';
|
|
22
|
-
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
23
23
|
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
24
24
|
import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
|
|
25
25
|
import {
|
|
@@ -32,6 +32,7 @@ import {
|
|
|
32
32
|
valueFacetSort,
|
|
33
33
|
defaultFacetSort,
|
|
34
34
|
} from '../models';
|
|
35
|
+
import type { CollectionTitles } from '../data-source/models';
|
|
35
36
|
import '@internetarchive/ia-activity-indicator/ia-activity-indicator';
|
|
36
37
|
import './more-facets-pagination';
|
|
37
38
|
import './facets-template';
|
|
@@ -61,7 +62,7 @@ export class MoreFacetsContent extends LitElement {
|
|
|
61
62
|
@property({ type: String }) withinCollection?: string;
|
|
62
63
|
|
|
63
64
|
@property({ type: Object })
|
|
64
|
-
|
|
65
|
+
collectionTitles?: CollectionTitles;
|
|
65
66
|
|
|
66
67
|
@property({ type: Object }) selectedFacets?: SelectedFacets;
|
|
67
68
|
|
|
@@ -142,7 +143,10 @@ export class MoreFacetsContent extends LitElement {
|
|
|
142
143
|
const aggregationsSize = 65535; // todo - do we want to have all the records at once?
|
|
143
144
|
|
|
144
145
|
const collectionParams = this.withinCollection
|
|
145
|
-
? {
|
|
146
|
+
? {
|
|
147
|
+
pageType: 'collection_details' as PageType,
|
|
148
|
+
pageTarget: this.withinCollection,
|
|
149
|
+
}
|
|
146
150
|
: null;
|
|
147
151
|
|
|
148
152
|
const params: SearchParams = {
|
|
@@ -159,6 +163,13 @@ export class MoreFacetsContent extends LitElement {
|
|
|
159
163
|
|
|
160
164
|
this.facetGroup = this.aggregationFacetGroups;
|
|
161
165
|
this.facetsLoading = false;
|
|
166
|
+
|
|
167
|
+
const collectionTitles = results?.success?.response?.collectionTitles;
|
|
168
|
+
if (collectionTitles) {
|
|
169
|
+
for (const [id, title] of Object.entries(collectionTitles)) {
|
|
170
|
+
this.collectionTitles?.set(id, title);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
162
173
|
}
|
|
163
174
|
|
|
164
175
|
private pageNumberClicked(e: CustomEvent<{ page: number }>) {
|
|
@@ -285,9 +296,6 @@ export class MoreFacetsContent extends LitElement {
|
|
|
285
296
|
!suppressedCollections[bucketKey] && !bucketKey?.startsWith('fav-')
|
|
286
297
|
);
|
|
287
298
|
});
|
|
288
|
-
|
|
289
|
-
// asynchronously load the collection name
|
|
290
|
-
this.preloadCollectionNames(castedBuckets);
|
|
291
299
|
}
|
|
292
300
|
|
|
293
301
|
// find length and pagination size for modal pagination
|
|
@@ -320,26 +328,13 @@ export class MoreFacetsContent extends LitElement {
|
|
|
320
328
|
return facetGroups;
|
|
321
329
|
}
|
|
322
330
|
|
|
323
|
-
/**
|
|
324
|
-
* for collections, we need to asynchronously load the collection name
|
|
325
|
-
* so we use the `async-collection-name` widget and for the rest, we have a static value to use
|
|
326
|
-
*
|
|
327
|
-
* @param castedBuckets
|
|
328
|
-
*/
|
|
329
|
-
private preloadCollectionNames(castedBuckets: any[]) {
|
|
330
|
-
const collectionIds = castedBuckets?.map(option => option.key);
|
|
331
|
-
const collectionIdsArray = Array.from(new Set(collectionIds)) as string[];
|
|
332
|
-
|
|
333
|
-
this.collectionNameCache?.preloadIdentifiers(collectionIdsArray);
|
|
334
|
-
}
|
|
335
|
-
|
|
336
331
|
private get getMoreFacetsTemplate(): TemplateResult {
|
|
337
332
|
return html`
|
|
338
333
|
<facets-template
|
|
339
334
|
.facetGroup=${this.mergedFacets?.shift()}
|
|
340
335
|
.selectedFacets=${this.selectedFacets}
|
|
341
336
|
.renderOn=${'modal'}
|
|
342
|
-
.
|
|
337
|
+
.collectionTitles=${this.collectionTitles}
|
|
343
338
|
@selectedFacetsChanged=${(e: CustomEvent) => {
|
|
344
339
|
this.selectedFacets = e.detail;
|
|
345
340
|
}}
|
package/src/collection-facets.ts
CHANGED
|
@@ -22,8 +22,6 @@ import type {
|
|
|
22
22
|
} from '@internetarchive/search-service';
|
|
23
23
|
import '@internetarchive/histogram-date-range';
|
|
24
24
|
import '@internetarchive/feature-feedback';
|
|
25
|
-
import '@internetarchive/collection-name-cache';
|
|
26
|
-
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
27
25
|
import {
|
|
28
26
|
ModalConfig,
|
|
29
27
|
ModalManagerInterface,
|
|
@@ -47,6 +45,7 @@ import {
|
|
|
47
45
|
suppressedCollections,
|
|
48
46
|
defaultFacetSort,
|
|
49
47
|
} from './models';
|
|
48
|
+
import type { CollectionTitles } from './data-source/models';
|
|
50
49
|
import './collection-facets/more-facets-content';
|
|
51
50
|
import './collection-facets/facets-template';
|
|
52
51
|
import './collection-facets/facet-tombstone-row';
|
|
@@ -118,7 +117,7 @@ export class CollectionFacets extends LitElement {
|
|
|
118
117
|
analyticsHandler?: AnalyticsManagerInterface;
|
|
119
118
|
|
|
120
119
|
@property({ type: Object, attribute: false })
|
|
121
|
-
|
|
120
|
+
collectionTitles?: CollectionTitles;
|
|
122
121
|
|
|
123
122
|
@state() openFacets: Record<FacetOption, boolean> = {
|
|
124
123
|
subject: false,
|
|
@@ -188,11 +187,7 @@ export class CollectionFacets extends LitElement {
|
|
|
188
187
|
data-id=${collxn}
|
|
189
188
|
@click=${this.partOfCollectionClicked}
|
|
190
189
|
>
|
|
191
|
-
|
|
192
|
-
.collectionNameCache=${this.collectionNameCache}
|
|
193
|
-
.identifier=${collxn}
|
|
194
|
-
placeholder=${collxn}
|
|
195
|
-
></async-collection-name>
|
|
190
|
+
${this.collectionTitles?.get(collxn) ?? collxn}
|
|
196
191
|
</a>
|
|
197
192
|
</li>`;
|
|
198
193
|
})}
|
|
@@ -307,14 +302,16 @@ export class CollectionFacets extends LitElement {
|
|
|
307
302
|
|
|
308
303
|
private get histogramTemplate() {
|
|
309
304
|
const { fullYearsHistogramAggregation } = this;
|
|
305
|
+
const minDate = fullYearsHistogramAggregation?.first_bucket_key;
|
|
306
|
+
const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
|
|
310
307
|
return this.fullYearAggregationLoading
|
|
311
308
|
? html`<div class="histogram-loading-indicator">…</div>` // Ellipsis block
|
|
312
309
|
: html`
|
|
313
310
|
<histogram-date-range
|
|
314
|
-
.minDate=${
|
|
315
|
-
.maxDate=${
|
|
316
|
-
.minSelectedDate=${this.minSelectedDate}
|
|
317
|
-
.maxSelectedDate=${this.maxSelectedDate}
|
|
311
|
+
.minDate=${minDate}
|
|
312
|
+
.maxDate=${maxDate}
|
|
313
|
+
.minSelectedDate=${this.minSelectedDate ?? minDate}
|
|
314
|
+
.maxSelectedDate=${this.maxSelectedDate ?? maxDate}
|
|
318
315
|
.updateDelay=${100}
|
|
319
316
|
missingDataMessage="..."
|
|
320
317
|
.width=${this.collapsableFacets && this.contentWidth
|
|
@@ -652,7 +649,7 @@ export class CollectionFacets extends LitElement {
|
|
|
652
649
|
.modalManager=${this.modalManager}
|
|
653
650
|
.searchService=${this.searchService}
|
|
654
651
|
.searchType=${this.searchType}
|
|
655
|
-
.
|
|
652
|
+
.collectionTitles=${this.collectionTitles}
|
|
656
653
|
.selectedFacets=${this.selectedFacets}
|
|
657
654
|
.sortedBy=${sortedBy}
|
|
658
655
|
@facetsChanged=${(e: CustomEvent) => {
|
|
@@ -694,7 +691,7 @@ export class CollectionFacets extends LitElement {
|
|
|
694
691
|
.facetGroup=${facetGroup}
|
|
695
692
|
.selectedFacets=${this.selectedFacets}
|
|
696
693
|
.renderOn=${'page'}
|
|
697
|
-
.
|
|
694
|
+
.collectionTitles=${this.collectionTitles}
|
|
698
695
|
@selectedFacetsChanged=${(e: CustomEvent) => {
|
|
699
696
|
const event = new CustomEvent<SelectedFacets>('facetsChanged', {
|
|
700
697
|
detail: e.detail,
|
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FilterMap,
|
|
3
|
+
Aggregation,
|
|
4
|
+
CollectionExtraInfo,
|
|
5
|
+
AccountExtraInfo,
|
|
6
|
+
PageElementMap,
|
|
7
|
+
} from '@internetarchive/search-service';
|
|
8
|
+
import type { ReactiveController } from 'lit';
|
|
9
|
+
import type {
|
|
10
|
+
PrefixFilterType,
|
|
11
|
+
PrefixFilterCounts,
|
|
12
|
+
TileModel,
|
|
13
|
+
} from '../models';
|
|
14
|
+
import type { PageSpecifierParams, CollectionTitles } from './models';
|
|
15
|
+
|
|
16
|
+
export interface CollectionBrowserDataSourceInterface
|
|
17
|
+
extends ReactiveController {
|
|
18
|
+
/**
|
|
19
|
+
* How many tile models are present in this data source
|
|
20
|
+
*/
|
|
21
|
+
readonly size: number;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* How many results there are in the full result set for the current query
|
|
25
|
+
* (not necessarily all loaded yet).
|
|
26
|
+
*/
|
|
27
|
+
readonly totalResults: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Whether the host has a valid set of properties for performing a search.
|
|
31
|
+
* For instance, on the search page this requires a valid search service and a
|
|
32
|
+
* non-empty query, while collection pages allow searching with an empty query
|
|
33
|
+
* for MDS but not FTS.
|
|
34
|
+
*/
|
|
35
|
+
readonly canPerformSearch: boolean;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Whether the end of the set of results for the current query state has been
|
|
39
|
+
* encountered (i.e., the last page of results).
|
|
40
|
+
*/
|
|
41
|
+
readonly endOfDataReached: boolean;
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* True if the initial work for a new query state has been completed (i.e., firing initial
|
|
45
|
+
* page/facet requests). False otherwise.
|
|
46
|
+
*/
|
|
47
|
+
readonly queryInitialized: boolean;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A string key compactly representing the current full search state, which can
|
|
51
|
+
* be used to determine, e.g., when a new search is required or whether an arriving
|
|
52
|
+
* response is outdated.
|
|
53
|
+
*/
|
|
54
|
+
readonly pageFetchQueryKey: string;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Similar to `pageFetchQueryKey`, but excluding properties that do not affect
|
|
58
|
+
* the validity of a set of facets (e.g., sort).
|
|
59
|
+
*/
|
|
60
|
+
readonly facetFetchQueryKey: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* An object representing any collection- or profile-specific properties to be passed along
|
|
64
|
+
* to the search service, specifying the exact page/tab to fetch results for.
|
|
65
|
+
*/
|
|
66
|
+
readonly pageSpecifierParams: PageSpecifierParams | null;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* A FilterMap object representing all filters applied to the current search,
|
|
70
|
+
* including any facets, letter filters, and date ranges.
|
|
71
|
+
*/
|
|
72
|
+
readonly filterMap: FilterMap;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* The full set of aggregations retrieved for the current search.
|
|
76
|
+
*/
|
|
77
|
+
readonly aggregations?: Record<string, Aggregation>;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The `year_histogram` aggregation retrieved for the current search.
|
|
81
|
+
*/
|
|
82
|
+
readonly yearHistogramAggregation?: Aggregation;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A map from collection identifiers that appear on hits or aggregations for the
|
|
86
|
+
* current search, to their human-readable collection titles.
|
|
87
|
+
*/
|
|
88
|
+
readonly collectionTitles: CollectionTitles;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* The "extra info" package provided by the PPS for collection pages, including details
|
|
92
|
+
* used to populate the target collection header & About tab content.
|
|
93
|
+
*/
|
|
94
|
+
readonly collectionExtraInfo?: CollectionExtraInfo;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The "extra info" package provided by the PPS for profile pages, including details
|
|
98
|
+
* used to populate the profile header.
|
|
99
|
+
*/
|
|
100
|
+
readonly accountExtraInfo?: AccountExtraInfo;
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The set of requested page elements for profile pages, if applicable. These represent
|
|
104
|
+
* any content specific to the current profile tab.
|
|
105
|
+
*/
|
|
106
|
+
readonly pageElements?: PageElementMap;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* An array of the current target collection's parent collections. Should include *all*
|
|
110
|
+
* ancestors in the collection hierarchy, not just the immediate parent.
|
|
111
|
+
*/
|
|
112
|
+
readonly parentCollections?: string[];
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* An object storing result counts for the current search bucketed by letter prefix.
|
|
116
|
+
* Keys are the result field on which the prefixes are considered (e.g., title/creator)
|
|
117
|
+
* and values are a Record mapping letters to their counts.
|
|
118
|
+
*/
|
|
119
|
+
readonly prefixFilterCountMap: Partial<
|
|
120
|
+
Record<PrefixFilterType, PrefixFilterCounts>
|
|
121
|
+
>;
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Any error message from the most recent search results response.
|
|
125
|
+
*/
|
|
126
|
+
readonly queryErrorMessage?: string;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* An array of all the tile models whose management checkboxes are checked
|
|
130
|
+
*/
|
|
131
|
+
readonly checkedTileModels: TileModel[];
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* An array of all the tile models whose management checkboxes are unchecked
|
|
135
|
+
*/
|
|
136
|
+
readonly uncheckedTileModels: TileModel[];
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* A Promise which, after each query change, resolves once the fetches for the initial
|
|
140
|
+
* search have completed. Waits for *both* the hits and aggregations fetches to finish.
|
|
141
|
+
*
|
|
142
|
+
* Ensure you await this component's `updateComplete` promise before awaiting this
|
|
143
|
+
* one, to ensure you do not await an obsolete promise from the previous update.
|
|
144
|
+
*/
|
|
145
|
+
readonly initialSearchComplete: Promise<boolean>;
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* Resets the data source to its empty state, with no result pages, aggregations, etc.
|
|
149
|
+
*/
|
|
150
|
+
reset(): void;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Adds the given page of tile models to the data source.
|
|
154
|
+
* If the given page number already exists, that page will be overwritten.
|
|
155
|
+
* @param pageNum Which page number to add (indexed starting from 1)
|
|
156
|
+
* @param pageTiles The array of tile models for the new page
|
|
157
|
+
*/
|
|
158
|
+
addPage(pageNum: number, pageTiles: TileModel[]): void;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Returns the given page of tile models from the data source.
|
|
162
|
+
* @param pageNum Which page number to get (indexed starting from 1)
|
|
163
|
+
*/
|
|
164
|
+
getPage(pageNum: number): TileModel[];
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Returns the full set of paged tile models stored in this data source.
|
|
168
|
+
*/
|
|
169
|
+
getAllPages(): Record<string, TileModel[]>;
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Whether the data source contains any tiles for the given page number.
|
|
173
|
+
* @param pageNum Which page number to query (indexed starting from 1)
|
|
174
|
+
*/
|
|
175
|
+
hasPage(pageNum: number): boolean;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Returns the single tile model appearing at the given index in the
|
|
179
|
+
* data source, with respect to the current page size. Returns `undefined` if
|
|
180
|
+
* the corresponding page is not present on the data source or if it does not
|
|
181
|
+
* contain a tile model at the corresponding index.
|
|
182
|
+
* @param index The 0-based index (within the full data source) of the tile to get
|
|
183
|
+
*/
|
|
184
|
+
getTileModelAt(index: number): TileModel | undefined;
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Returns the first numeric tile index corresponding to the given tile model object,
|
|
188
|
+
* or -1 if the given tile model is not present.
|
|
189
|
+
* @param tile The tile model to search for in the data source
|
|
190
|
+
*/
|
|
191
|
+
indexOf(tile: TileModel): number;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Requests that the data source fire a backend request for the given page of results.
|
|
195
|
+
* @param pageNum Which page number to fetch results for
|
|
196
|
+
* @param numInitialPages How many pages should be batched together on an initial fetch
|
|
197
|
+
*/
|
|
198
|
+
fetchPage(pageNum: number, numInitialPages?: number): Promise<void>;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Requests that the data source update its prefix bucket result counts for the given
|
|
202
|
+
* type of prefix filter.
|
|
203
|
+
* @param filterType Which prefixable field to update the buckets for (e.g., title/creator)
|
|
204
|
+
*/
|
|
205
|
+
updatePrefixFilterCounts(filterType: PrefixFilterType): Promise<void>;
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Fetches and caches the prefix filter counts for the current sort type,
|
|
209
|
+
* provided it is one that permits prefix filtering. (If not, this does nothing).
|
|
210
|
+
*/
|
|
211
|
+
updatePrefixFiltersForCurrentSort(): Promise<void>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Clears the cached letter counts for both title and creator, and
|
|
215
|
+
* fetches a new set of counts for whichever of them is the currently
|
|
216
|
+
* selected sort option (which may be neither).
|
|
217
|
+
*
|
|
218
|
+
* Call this whenever the counts are invalidated (e.g., by a query change).
|
|
219
|
+
*/
|
|
220
|
+
refreshLetterCounts(): void;
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Returns the current page size of the data source.
|
|
224
|
+
*/
|
|
225
|
+
getPageSize(): number;
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Changes the page size used by the data source, discarding any previously-fetched pages.
|
|
229
|
+
*
|
|
230
|
+
* **Note: this operation will reset any data stored in the data source!**
|
|
231
|
+
* @param pageSize
|
|
232
|
+
*/
|
|
233
|
+
setPageSize(pageSize: number): void;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Sets whether this data source should suppress further data fetches, i.e. ignore any
|
|
237
|
+
* future query changes on its host that would trigger a page/facet fetch.
|
|
238
|
+
* @param suppressed Whether further fetches for this data source should be suppressed
|
|
239
|
+
*/
|
|
240
|
+
setFetchesSuppressed(suppressed: boolean): void;
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Notifies the data source that a query change has occurred, which may trigger a data
|
|
244
|
+
* reset & new fetches.
|
|
245
|
+
*/
|
|
246
|
+
handleQueryChange(): void;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Applies the given map function to all of the tile models in every page of the data
|
|
250
|
+
* source.
|
|
251
|
+
* @param callback A callback function to apply on each tile model, as with Array.map
|
|
252
|
+
*/
|
|
253
|
+
map(
|
|
254
|
+
callback: (model: TileModel, index: number, array: TileModel[]) => TileModel
|
|
255
|
+
): void;
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* Checks every tile's management checkbox
|
|
259
|
+
*/
|
|
260
|
+
checkAllTiles(): void;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* Unchecks every tile's management checkbox
|
|
264
|
+
*/
|
|
265
|
+
uncheckAllTiles(): void;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Removes all tile models that are currently checked & adjusts the paging
|
|
269
|
+
* of the data source to account for any new gaps in the data.
|
|
270
|
+
*/
|
|
271
|
+
removeCheckedTiles(): void;
|
|
272
|
+
}
|