@internetarchive/collection-browser 0.4.10 → 0.4.11
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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +26 -26
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +9 -9
- package/dist/index.js +9 -9
- package/dist/src/app-root.d.ts +50 -50
- package/dist/src/app-root.js +278 -278
- package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-left.js +2 -2
- package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
- package/dist/src/assets/img/icons/arrow-right.js +2 -2
- package/dist/src/assets/img/icons/chevron.d.ts +2 -2
- package/dist/src/assets/img/icons/chevron.js +2 -2
- package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
- package/dist/src/assets/img/icons/empty-query.js +2 -2
- package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
- package/dist/src/assets/img/icons/eye-closed.js +2 -2
- package/dist/src/assets/img/icons/eye.d.ts +2 -2
- package/dist/src/assets/img/icons/eye.js +2 -2
- package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
- package/dist/src/assets/img/icons/favorite-filled.js +2 -2
- package/dist/src/assets/img/icons/login-required.d.ts +1 -1
- package/dist/src/assets/img/icons/login-required.js +2 -2
- package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/account.js +2 -2
- package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
- package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/data.js +2 -2
- package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
- package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/film.js +2 -2
- package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/images.js +2 -2
- package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
- package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/software.js +2 -2
- package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
- package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
- package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/video.js +2 -2
- package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/web.js +2 -2
- package/dist/src/assets/img/icons/null-result.d.ts +2 -2
- package/dist/src/assets/img/icons/null-result.js +2 -2
- package/dist/src/assets/img/icons/restricted.d.ts +1 -1
- package/dist/src/assets/img/icons/restricted.js +2 -2
- package/dist/src/assets/img/icons/reviews.d.ts +1 -1
- package/dist/src/assets/img/icons/reviews.js +2 -2
- package/dist/src/assets/img/icons/upload.d.ts +1 -1
- package/dist/src/assets/img/icons/upload.js +2 -2
- package/dist/src/assets/img/icons/views.d.ts +1 -1
- package/dist/src/assets/img/icons/views.js +2 -2
- package/dist/src/circular-activity-indicator.d.ts +5 -5
- package/dist/src/circular-activity-indicator.js +17 -17
- package/dist/src/collection-browser.d.ts +279 -279
- package/dist/src/collection-browser.js +1156 -1156
- package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
- package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
- package/dist/src/collection-facets/facets-template.d.ts +16 -16
- package/dist/src/collection-facets/facets-template.js +125 -125
- package/dist/src/collection-facets/more-facets-content.d.ts +75 -75
- package/dist/src/collection-facets/more-facets-content.js +340 -340
- package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
- package/dist/src/collection-facets/more-facets-pagination.js +192 -192
- package/dist/src/collection-facets.d.ts +81 -81
- package/dist/src/collection-facets.js +375 -375
- package/dist/src/empty-placeholder.d.ts +11 -11
- package/dist/src/empty-placeholder.js +42 -42
- package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
- package/dist/src/language-code-handler/language-code-handler.js +26 -26
- package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
- package/dist/src/language-code-handler/language-code-mapping.js +562 -562
- package/dist/src/mediatype/mediatype-config.d.ts +3 -3
- package/dist/src/mediatype/mediatype-config.js +85 -85
- package/dist/src/models.d.ts +115 -115
- package/dist/src/models.js +125 -125
- package/dist/src/restoration-state-handler.d.ts +45 -45
- package/dist/src/restoration-state-handler.js +230 -230
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
- package/dist/src/sort-filter-bar/alpha-bar.d.ts +20 -20
- package/dist/src/sort-filter-bar/alpha-bar.js +136 -128
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/compact.js +2 -2
- package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/list.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
- package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/tile.js +2 -2
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +108 -108
- package/dist/src/sort-filter-bar/sort-filter-bar.js +438 -438
- package/dist/src/styles/item-image-styles.d.ts +8 -8
- package/dist/src/styles/item-image-styles.js +9 -9
- package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
- package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
- package/dist/src/tiles/grid/account-tile.d.ts +20 -20
- package/dist/src/tiles/grid/account-tile.js +64 -64
- package/dist/src/tiles/grid/collection-tile.d.ts +17 -17
- package/dist/src/tiles/grid/collection-tile.js +71 -71
- package/dist/src/tiles/grid/item-tile.d.ts +32 -32
- package/dist/src/tiles/grid/item-tile.js +122 -122
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +7 -7
- package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
- package/dist/src/tiles/grid/tile-stats.js +40 -40
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
- package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
- package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
- package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
- package/dist/src/tiles/image-block.d.ts +17 -17
- package/dist/src/tiles/image-block.js +72 -72
- package/dist/src/tiles/item-image.d.ts +35 -35
- package/dist/src/tiles/item-image.js +117 -117
- package/dist/src/tiles/list/account-label.d.ts +1 -1
- package/dist/src/tiles/list/account-label.js +6 -6
- package/dist/src/tiles/list/date-label.d.ts +1 -1
- package/dist/src/tiles/list/date-label.js +12 -12
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
- package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
- package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
- package/dist/src/tiles/list/tile-list-compact.js +99 -99
- package/dist/src/tiles/list/tile-list.d.ts +55 -55
- package/dist/src/tiles/list/tile-list.js +301 -301
- package/dist/src/tiles/mediatype-icon.d.ts +9 -9
- package/dist/src/tiles/mediatype-icon.js +47 -47
- package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/icon-overlay.js +40 -40
- package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
- package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
- package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
- package/dist/src/tiles/overlay/text-overlay.js +42 -42
- package/dist/src/tiles/text-snippet-block.d.ts +27 -27
- package/dist/src/tiles/text-snippet-block.js +73 -73
- package/dist/src/tiles/tile-dispatcher.d.ts +58 -58
- package/dist/src/tiles/tile-dispatcher.js +194 -194
- package/dist/src/utils/analytics-events.d.ts +22 -22
- package/dist/src/utils/analytics-events.js +24 -24
- package/dist/src/utils/format-count.d.ts +7 -7
- package/dist/src/utils/format-count.js +76 -76
- package/dist/src/utils/format-date.d.ts +2 -2
- package/dist/src/utils/format-date.js +23 -23
- package/dist/src/utils/format-unit-size.d.ts +2 -2
- package/dist/src/utils/format-unit-size.js +33 -33
- package/dist/test/collection-browser.test.d.ts +1 -1
- package/dist/test/collection-browser.test.js +584 -584
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
- package/dist/test/collection-facets/facets-template.test.js +62 -62
- package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +114 -114
- package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
- package/dist/test/collection-facets.test.d.ts +2 -2
- package/dist/test/collection-facets.test.js +460 -460
- package/dist/test/empty-placeholder.test.d.ts +1 -1
- package/dist/test/empty-placeholder.test.js +33 -33
- package/dist/test/icon-overlay.test.d.ts +1 -1
- package/dist/test/icon-overlay.test.js +24 -24
- package/dist/test/image-block.test.d.ts +1 -1
- package/dist/test/image-block.test.js +48 -48
- package/dist/test/item-image.test.d.ts +1 -1
- package/dist/test/item-image.test.js +84 -84
- package/dist/test/mediatype-config.test.d.ts +1 -1
- package/dist/test/mediatype-config.test.js +16 -16
- package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
- package/dist/test/mocks/mock-analytics-handler.js +15 -15
- package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
- package/dist/test/mocks/mock-collection-name-cache.js +13 -13
- package/dist/test/mocks/mock-search-responses.d.ts +12 -12
- package/dist/test/mocks/mock-search-responses.js +341 -341
- package/dist/test/mocks/mock-search-service.d.ts +13 -13
- package/dist/test/mocks/mock-search-service.js +40 -40
- package/dist/test/restoration-state-handler.test.d.ts +1 -1
- package/dist/test/restoration-state-handler.test.js +125 -125
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
- package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
- package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +197 -197
- package/dist/test/text-overlay.test.d.ts +1 -1
- package/dist/test/text-overlay.test.js +48 -48
- package/dist/test/text-snippet-block.test.d.ts +1 -1
- package/dist/test/text-snippet-block.test.js +57 -57
- package/dist/test/tile-stats.test.d.ts +1 -1
- package/dist/test/tile-stats.test.js +33 -33
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/account-tile.test.js +76 -76
- package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/collection-tile.test.js +73 -73
- package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/item-tile.test.js +158 -158
- package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
- package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
- package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
- package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
- package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list.test.js +163 -163
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +67 -67
- package/dist/test/utils/format-count.test.d.ts +1 -1
- package/dist/test/utils/format-count.test.js +23 -23
- package/dist/test/utils/format-date.test.d.ts +1 -1
- package/dist/test/utils/format-date.test.js +17 -17
- package/dist/test/utils/format-unit-size.test.d.ts +1 -1
- package/dist/test/utils/format-unit-size.test.js +17 -17
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +1 -1
- package/renovate.json +6 -6
- package/src/sort-filter-bar/alpha-bar.ts +8 -0
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,192 +1,192 @@
|
|
|
1
|
-
import { __decorate } from "tslib";
|
|
2
|
-
/* eslint-disable import/no-duplicates */
|
|
3
|
-
import { html, css, LitElement, nothing, } from 'lit';
|
|
4
|
-
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
5
|
-
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
-
import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
|
|
7
|
-
import '@internetarchive/infinite-scroller';
|
|
8
|
-
import './tiles/tile-dispatcher';
|
|
9
|
-
import './tiles/collection-browser-loading-tile';
|
|
10
|
-
import './sort-filter-bar/sort-filter-bar';
|
|
11
|
-
import './collection-facets';
|
|
12
|
-
import './circular-activity-indicator';
|
|
13
|
-
import './sort-filter-bar/sort-filter-bar';
|
|
14
|
-
import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
|
|
15
|
-
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
16
|
-
import chevronIcon from './assets/img/icons/chevron';
|
|
17
|
-
import './empty-placeholder';
|
|
18
|
-
import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
|
|
19
|
-
let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
20
|
-
constructor() {
|
|
21
|
-
super(...arguments);
|
|
22
|
-
this.baseImageUrl = 'https://archive.org';
|
|
23
|
-
this.searchType = SearchType.METADATA;
|
|
24
|
-
this.sortParam = null;
|
|
25
|
-
this.selectedSort = SortField.relevance;
|
|
26
|
-
this.selectedTitleFilter = null;
|
|
27
|
-
this.selectedCreatorFilter = null;
|
|
28
|
-
this.sortDirection = null;
|
|
29
|
-
this.pageSize = 50;
|
|
30
|
-
this.showHistogramDatePicker = false;
|
|
31
|
-
/** describes where this component is being used */
|
|
32
|
-
this.searchContext = analyticsCategories.default;
|
|
33
|
-
this.pageContext = 'search';
|
|
34
|
-
this.restorationStateHandler = new RestorationStateHandler({
|
|
35
|
-
context: this.pageContext,
|
|
36
|
-
});
|
|
37
|
-
this.mobileBreakpoint = 600;
|
|
38
|
-
this.loggedIn = false;
|
|
39
|
-
this.modalManager = undefined;
|
|
40
|
-
/**
|
|
41
|
-
* If item management UI active
|
|
42
|
-
*/
|
|
43
|
-
this.isManageView = false;
|
|
44
|
-
/**
|
|
45
|
-
* The page that the consumer wants to load.
|
|
46
|
-
*/
|
|
47
|
-
this.initialPageNumber = 1;
|
|
48
|
-
/**
|
|
49
|
-
* This the the number of pages that we want to show.
|
|
50
|
-
*
|
|
51
|
-
* The data isn't necessarily loaded for all of the pages, but this lets us
|
|
52
|
-
* know how many cells we should render.
|
|
53
|
-
*/
|
|
54
|
-
this.pagesToRender = this.initialPageNumber;
|
|
55
|
-
this.searchResultsLoading = false;
|
|
56
|
-
this.facetsLoading = false;
|
|
57
|
-
this.fullYearAggregationLoading = false;
|
|
58
|
-
this.mobileView = false;
|
|
59
|
-
this.mobileFacetsVisible = false;
|
|
60
|
-
this.placeholderType = null;
|
|
61
|
-
this.prefixFilterCountMap = {};
|
|
62
|
-
/**
|
|
63
|
-
* When we're animated scrolling to the page, we don't want to fetch
|
|
64
|
-
* all of the pages as it scrolls so this lets us know if we're scrolling
|
|
65
|
-
*/
|
|
66
|
-
this.isScrollingToCell = false;
|
|
67
|
-
/**
|
|
68
|
-
* When we've reached the end of the data, stop trying to fetch more
|
|
69
|
-
*/
|
|
70
|
-
this.endOfDataReached = false;
|
|
71
|
-
/**
|
|
72
|
-
* When page width resizes from desktop to mobile, set true to
|
|
73
|
-
* disable expand/collapse transition when loading.
|
|
74
|
-
*/
|
|
75
|
-
this.isResizeToMobile = false;
|
|
76
|
-
this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
|
|
77
|
-
/**
|
|
78
|
-
* The results per page so we can paginate.
|
|
79
|
-
*
|
|
80
|
-
* This allows us to start in the middle of the search results and
|
|
81
|
-
* fetch data before or after the current page. If we don't have a key
|
|
82
|
-
* for the previous/next page, we'll fetch the next/previous page to populate it
|
|
83
|
-
*/
|
|
84
|
-
this.dataSource = {};
|
|
85
|
-
// we only want to scroll on the very first query change
|
|
86
|
-
// so this keeps track of whether we've already set the initial query
|
|
87
|
-
this.initialQueryChangeHappened = false;
|
|
88
|
-
this.historyPopOccurred = false;
|
|
89
|
-
// this maps the query to the pages being fetched for that query
|
|
90
|
-
this.pageFetchesInProgress = {};
|
|
91
|
-
}
|
|
92
|
-
tileModelAtCellIndex(index) {
|
|
93
|
-
var _a;
|
|
94
|
-
const pageNumber = Math.floor(index / this.pageSize) + 1;
|
|
95
|
-
const itemIndex = index % this.pageSize;
|
|
96
|
-
const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
|
|
97
|
-
/**
|
|
98
|
-
* If we encounter a model we don't have yet and we're not in the middle of an
|
|
99
|
-
* automated scroll, fetch the page and just return undefined.
|
|
100
|
-
* The datasource will be updated once the page is loaded and the cell will be rendered.
|
|
101
|
-
*
|
|
102
|
-
* We disable it during the automated scroll since we may fetch pages for cells the
|
|
103
|
-
* user may never see.
|
|
104
|
-
*/
|
|
105
|
-
if (!model && !this.isScrollingToCell) {
|
|
106
|
-
this.fetchPage(pageNumber);
|
|
107
|
-
}
|
|
108
|
-
return model;
|
|
109
|
-
}
|
|
110
|
-
get sortFilterQueries() {
|
|
111
|
-
const queries = [this.titleQuery, this.creatorQuery];
|
|
112
|
-
return queries.filter(q => q).join(' AND ');
|
|
113
|
-
}
|
|
114
|
-
// this is the total number of tiles we expect if
|
|
115
|
-
// the data returned is a full page worth
|
|
116
|
-
// this is useful for putting in placeholders for the expected number of tiles
|
|
117
|
-
get estimatedTileCount() {
|
|
118
|
-
return this.pagesToRender * this.pageSize;
|
|
119
|
-
}
|
|
120
|
-
// this is the actual number of tiles in the datasource,
|
|
121
|
-
// which is useful for removing excess placeholder tiles
|
|
122
|
-
// once we reached the end of the data
|
|
123
|
-
get actualTileCount() {
|
|
124
|
-
return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Go to the given page of results
|
|
128
|
-
*
|
|
129
|
-
* @param pageNumber
|
|
130
|
-
*/
|
|
131
|
-
goToPage(pageNumber) {
|
|
132
|
-
this.initialPageNumber = pageNumber;
|
|
133
|
-
this.pagesToRender = pageNumber;
|
|
134
|
-
return this.scrollToPage(pageNumber);
|
|
135
|
-
}
|
|
136
|
-
clearFilters() {
|
|
137
|
-
this.selectedFacets = defaultSelectedFacets;
|
|
138
|
-
this.sortParam = null;
|
|
139
|
-
this.selectedTitleFilter = null;
|
|
140
|
-
this.selectedCreatorFilter = null;
|
|
141
|
-
this.titleQuery = undefined;
|
|
142
|
-
this.creatorQuery = undefined;
|
|
143
|
-
this.selectedSort = SortField.relevance;
|
|
144
|
-
this.sortDirection = null;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Manually requests to perform a search, which will only be executed if one of
|
|
148
|
-
* the query, the search type, or the sort has changed.
|
|
149
|
-
*/
|
|
150
|
-
requestSearch() {
|
|
151
|
-
this.handleQueryChange();
|
|
152
|
-
}
|
|
153
|
-
render() {
|
|
154
|
-
this.setPlaceholderType();
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
/* eslint-disable import/no-duplicates */
|
|
3
|
+
import { html, css, LitElement, nothing, } from 'lit';
|
|
4
|
+
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
5
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
6
|
+
import { FilterConstraint, FilterMapBuilder, SearchType, } from '@internetarchive/search-service';
|
|
7
|
+
import '@internetarchive/infinite-scroller';
|
|
8
|
+
import './tiles/tile-dispatcher';
|
|
9
|
+
import './tiles/collection-browser-loading-tile';
|
|
10
|
+
import './sort-filter-bar/sort-filter-bar';
|
|
11
|
+
import './collection-facets';
|
|
12
|
+
import './circular-activity-indicator';
|
|
13
|
+
import './sort-filter-bar/sort-filter-bar';
|
|
14
|
+
import { SortField, SortFieldToMetadataField, defaultSelectedFacets, prefixFilterAggregationKeys, } from './models';
|
|
15
|
+
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
16
|
+
import chevronIcon from './assets/img/icons/chevron';
|
|
17
|
+
import './empty-placeholder';
|
|
18
|
+
import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
|
|
19
|
+
let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.baseImageUrl = 'https://archive.org';
|
|
23
|
+
this.searchType = SearchType.METADATA;
|
|
24
|
+
this.sortParam = null;
|
|
25
|
+
this.selectedSort = SortField.relevance;
|
|
26
|
+
this.selectedTitleFilter = null;
|
|
27
|
+
this.selectedCreatorFilter = null;
|
|
28
|
+
this.sortDirection = null;
|
|
29
|
+
this.pageSize = 50;
|
|
30
|
+
this.showHistogramDatePicker = false;
|
|
31
|
+
/** describes where this component is being used */
|
|
32
|
+
this.searchContext = analyticsCategories.default;
|
|
33
|
+
this.pageContext = 'search';
|
|
34
|
+
this.restorationStateHandler = new RestorationStateHandler({
|
|
35
|
+
context: this.pageContext,
|
|
36
|
+
});
|
|
37
|
+
this.mobileBreakpoint = 600;
|
|
38
|
+
this.loggedIn = false;
|
|
39
|
+
this.modalManager = undefined;
|
|
40
|
+
/**
|
|
41
|
+
* If item management UI active
|
|
42
|
+
*/
|
|
43
|
+
this.isManageView = false;
|
|
44
|
+
/**
|
|
45
|
+
* The page that the consumer wants to load.
|
|
46
|
+
*/
|
|
47
|
+
this.initialPageNumber = 1;
|
|
48
|
+
/**
|
|
49
|
+
* This the the number of pages that we want to show.
|
|
50
|
+
*
|
|
51
|
+
* The data isn't necessarily loaded for all of the pages, but this lets us
|
|
52
|
+
* know how many cells we should render.
|
|
53
|
+
*/
|
|
54
|
+
this.pagesToRender = this.initialPageNumber;
|
|
55
|
+
this.searchResultsLoading = false;
|
|
56
|
+
this.facetsLoading = false;
|
|
57
|
+
this.fullYearAggregationLoading = false;
|
|
58
|
+
this.mobileView = false;
|
|
59
|
+
this.mobileFacetsVisible = false;
|
|
60
|
+
this.placeholderType = null;
|
|
61
|
+
this.prefixFilterCountMap = {};
|
|
62
|
+
/**
|
|
63
|
+
* When we're animated scrolling to the page, we don't want to fetch
|
|
64
|
+
* all of the pages as it scrolls so this lets us know if we're scrolling
|
|
65
|
+
*/
|
|
66
|
+
this.isScrollingToCell = false;
|
|
67
|
+
/**
|
|
68
|
+
* When we've reached the end of the data, stop trying to fetch more
|
|
69
|
+
*/
|
|
70
|
+
this.endOfDataReached = false;
|
|
71
|
+
/**
|
|
72
|
+
* When page width resizes from desktop to mobile, set true to
|
|
73
|
+
* disable expand/collapse transition when loading.
|
|
74
|
+
*/
|
|
75
|
+
this.isResizeToMobile = false;
|
|
76
|
+
this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
|
|
77
|
+
/**
|
|
78
|
+
* The results per page so we can paginate.
|
|
79
|
+
*
|
|
80
|
+
* This allows us to start in the middle of the search results and
|
|
81
|
+
* fetch data before or after the current page. If we don't have a key
|
|
82
|
+
* for the previous/next page, we'll fetch the next/previous page to populate it
|
|
83
|
+
*/
|
|
84
|
+
this.dataSource = {};
|
|
85
|
+
// we only want to scroll on the very first query change
|
|
86
|
+
// so this keeps track of whether we've already set the initial query
|
|
87
|
+
this.initialQueryChangeHappened = false;
|
|
88
|
+
this.historyPopOccurred = false;
|
|
89
|
+
// this maps the query to the pages being fetched for that query
|
|
90
|
+
this.pageFetchesInProgress = {};
|
|
91
|
+
}
|
|
92
|
+
tileModelAtCellIndex(index) {
|
|
93
|
+
var _a;
|
|
94
|
+
const pageNumber = Math.floor(index / this.pageSize) + 1;
|
|
95
|
+
const itemIndex = index % this.pageSize;
|
|
96
|
+
const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
|
|
97
|
+
/**
|
|
98
|
+
* If we encounter a model we don't have yet and we're not in the middle of an
|
|
99
|
+
* automated scroll, fetch the page and just return undefined.
|
|
100
|
+
* The datasource will be updated once the page is loaded and the cell will be rendered.
|
|
101
|
+
*
|
|
102
|
+
* We disable it during the automated scroll since we may fetch pages for cells the
|
|
103
|
+
* user may never see.
|
|
104
|
+
*/
|
|
105
|
+
if (!model && !this.isScrollingToCell) {
|
|
106
|
+
this.fetchPage(pageNumber);
|
|
107
|
+
}
|
|
108
|
+
return model;
|
|
109
|
+
}
|
|
110
|
+
get sortFilterQueries() {
|
|
111
|
+
const queries = [this.titleQuery, this.creatorQuery];
|
|
112
|
+
return queries.filter(q => q).join(' AND ');
|
|
113
|
+
}
|
|
114
|
+
// this is the total number of tiles we expect if
|
|
115
|
+
// the data returned is a full page worth
|
|
116
|
+
// this is useful for putting in placeholders for the expected number of tiles
|
|
117
|
+
get estimatedTileCount() {
|
|
118
|
+
return this.pagesToRender * this.pageSize;
|
|
119
|
+
}
|
|
120
|
+
// this is the actual number of tiles in the datasource,
|
|
121
|
+
// which is useful for removing excess placeholder tiles
|
|
122
|
+
// once we reached the end of the data
|
|
123
|
+
get actualTileCount() {
|
|
124
|
+
return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Go to the given page of results
|
|
128
|
+
*
|
|
129
|
+
* @param pageNumber
|
|
130
|
+
*/
|
|
131
|
+
goToPage(pageNumber) {
|
|
132
|
+
this.initialPageNumber = pageNumber;
|
|
133
|
+
this.pagesToRender = pageNumber;
|
|
134
|
+
return this.scrollToPage(pageNumber);
|
|
135
|
+
}
|
|
136
|
+
clearFilters() {
|
|
137
|
+
this.selectedFacets = defaultSelectedFacets;
|
|
138
|
+
this.sortParam = null;
|
|
139
|
+
this.selectedTitleFilter = null;
|
|
140
|
+
this.selectedCreatorFilter = null;
|
|
141
|
+
this.titleQuery = undefined;
|
|
142
|
+
this.creatorQuery = undefined;
|
|
143
|
+
this.selectedSort = SortField.relevance;
|
|
144
|
+
this.sortDirection = null;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Manually requests to perform a search, which will only be executed if one of
|
|
148
|
+
* the query, the search type, or the sort has changed.
|
|
149
|
+
*/
|
|
150
|
+
requestSearch() {
|
|
151
|
+
this.handleQueryChange();
|
|
152
|
+
}
|
|
153
|
+
render() {
|
|
154
|
+
this.setPlaceholderType();
|
|
155
155
|
return html `
|
|
156
156
|
<div
|
|
157
157
|
id="content-container"
|
|
158
158
|
class=${this.mobileView ? 'mobile' : 'desktop'}
|
|
159
159
|
>
|
|
160
|
-
${this.placeholderType
|
|
161
|
-
? this.emptyPlaceholderTemplate
|
|
160
|
+
${this.placeholderType
|
|
161
|
+
? this.emptyPlaceholderTemplate
|
|
162
162
|
: this.collectionBrowserTemplate}
|
|
163
163
|
</div>
|
|
164
|
-
`;
|
|
165
|
-
}
|
|
166
|
-
setPlaceholderType() {
|
|
167
|
-
this.placeholderType = null;
|
|
168
|
-
if (!this.baseQuery) {
|
|
169
|
-
this.placeholderType = 'empty-query';
|
|
170
|
-
}
|
|
171
|
-
if ((!this.searchResultsLoading && this.totalResults === 0) ||
|
|
172
|
-
!this.searchService) {
|
|
173
|
-
this.placeholderType = 'null-result';
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
get emptyPlaceholderTemplate() {
|
|
164
|
+
`;
|
|
165
|
+
}
|
|
166
|
+
setPlaceholderType() {
|
|
167
|
+
this.placeholderType = null;
|
|
168
|
+
if (!this.baseQuery) {
|
|
169
|
+
this.placeholderType = 'empty-query';
|
|
170
|
+
}
|
|
171
|
+
if ((!this.searchResultsLoading && this.totalResults === 0) ||
|
|
172
|
+
!this.searchService) {
|
|
173
|
+
this.placeholderType = 'null-result';
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
get emptyPlaceholderTemplate() {
|
|
177
177
|
return html `
|
|
178
178
|
<empty-placeholder
|
|
179
179
|
.placeholderType=${this.placeholderType}
|
|
180
180
|
?isMobileView=${this.mobileView}
|
|
181
181
|
></empty-placeholder>
|
|
182
182
|
${this.infiniteScrollerTemplate}
|
|
183
|
-
`;
|
|
184
|
-
}
|
|
185
|
-
get collectionBrowserTemplate() {
|
|
186
|
-
var _a;
|
|
187
|
-
const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
|
|
188
|
-
const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
|
|
189
|
-
const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
|
|
183
|
+
`;
|
|
184
|
+
}
|
|
185
|
+
get collectionBrowserTemplate() {
|
|
186
|
+
var _a;
|
|
187
|
+
const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
|
|
188
|
+
const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
|
|
189
|
+
const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
|
|
190
190
|
return html `<div
|
|
191
191
|
id="left-column"
|
|
192
192
|
class="column${this.isResizeToMobile ? ' preload' : ''}"
|
|
@@ -204,8 +204,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
204
204
|
</div>
|
|
205
205
|
<div
|
|
206
206
|
id="facets-container"
|
|
207
|
-
class=${!this.mobileView || this.mobileFacetsVisible
|
|
208
|
-
? 'expanded'
|
|
207
|
+
class=${!this.mobileView || this.mobileFacetsVisible
|
|
208
|
+
? 'expanded'
|
|
209
209
|
: ''}
|
|
210
210
|
>
|
|
211
211
|
${this.facetsTemplate}
|
|
@@ -213,13 +213,13 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
213
213
|
</div>
|
|
214
214
|
<div id="right-column" class="column">
|
|
215
215
|
${this.sortFilterBarTemplate}
|
|
216
|
-
${this.displayMode === `list-compact`
|
|
217
|
-
? this.listHeaderTemplate
|
|
216
|
+
${this.displayMode === `list-compact`
|
|
217
|
+
? this.listHeaderTemplate
|
|
218
218
|
: nothing}
|
|
219
219
|
${this.infiniteScrollerTemplate}
|
|
220
|
-
</div>`;
|
|
221
|
-
}
|
|
222
|
-
get infiniteScrollerTemplate() {
|
|
220
|
+
</div>`;
|
|
221
|
+
}
|
|
222
|
+
get infiniteScrollerTemplate() {
|
|
223
223
|
return html `<infinite-scroller
|
|
224
224
|
class=${this.infiniteScrollerClasses}
|
|
225
225
|
itemCount=${this.placeholderType ? 0 : nothing}
|
|
@@ -227,16 +227,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
227
227
|
.placeholderCellTemplate=${this.placeholderCellTemplate}
|
|
228
228
|
@scrollThresholdReached=${this.scrollThresholdReached}
|
|
229
229
|
@visibleCellsChanged=${this.visibleCellsChanged}
|
|
230
|
-
></infinite-scroller>`;
|
|
231
|
-
}
|
|
232
|
-
get infiniteScrollerClasses() {
|
|
233
|
-
var _a;
|
|
234
|
-
return classMap({
|
|
235
|
-
[(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
|
|
236
|
-
hidden: !!this.placeholderType,
|
|
237
|
-
});
|
|
238
|
-
}
|
|
239
|
-
get sortFilterBarTemplate() {
|
|
230
|
+
></infinite-scroller>`;
|
|
231
|
+
}
|
|
232
|
+
get infiniteScrollerClasses() {
|
|
233
|
+
var _a;
|
|
234
|
+
return classMap({
|
|
235
|
+
[(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
|
|
236
|
+
hidden: !!this.placeholderType,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
get sortFilterBarTemplate() {
|
|
240
240
|
return html `
|
|
241
241
|
<sort-filter-bar
|
|
242
242
|
.selectedSort=${this.selectedSort}
|
|
@@ -252,113 +252,113 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
252
252
|
@creatorLetterChanged=${this.creatorLetterSelected}
|
|
253
253
|
>
|
|
254
254
|
</sort-filter-bar>
|
|
255
|
-
`;
|
|
256
|
-
}
|
|
257
|
-
userChangedSort(e) {
|
|
258
|
-
var _a;
|
|
259
|
-
const { selectedSort, sortDirection } = e.detail;
|
|
260
|
-
this.selectedSort = selectedSort;
|
|
261
|
-
this.sortDirection = sortDirection;
|
|
262
|
-
if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
|
|
263
|
-
this.goToPage(1);
|
|
264
|
-
}
|
|
265
|
-
this.currentPage = 1;
|
|
266
|
-
}
|
|
267
|
-
sendSortByAnalytics(prevSortDirection) {
|
|
268
|
-
var _a;
|
|
269
|
-
const directionCleared = prevSortDirection && !this.sortDirection;
|
|
270
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
271
|
-
category: this.searchContext,
|
|
272
|
-
action: analyticsActions.sortBy,
|
|
273
|
-
label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
selectedSortChanged() {
|
|
277
|
-
if (this.selectedSort === 'relevance' || this.sortDirection === null) {
|
|
278
|
-
this.sortParam = null;
|
|
279
|
-
return;
|
|
280
|
-
}
|
|
281
|
-
const sortField = SortFieldToMetadataField[this.selectedSort];
|
|
282
|
-
if (!sortField)
|
|
283
|
-
return;
|
|
284
|
-
this.sortParam = { field: sortField, direction: this.sortDirection };
|
|
285
|
-
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
286
|
-
this.updatePrefixFiltersForCurrentSort();
|
|
287
|
-
}
|
|
288
|
-
displayModeChanged(e) {
|
|
289
|
-
var _a;
|
|
290
|
-
this.displayMode = e.detail.displayMode;
|
|
291
|
-
if (this.displayMode) {
|
|
292
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
293
|
-
category: this.searchContext,
|
|
294
|
-
action: analyticsActions.displayMode,
|
|
295
|
-
label: this.displayMode,
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
/** Send Analytics when sorting by title's first letter
|
|
300
|
-
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
301
|
-
* */
|
|
302
|
-
sendFilterByTitleAnalytics(prevSelectedLetter) {
|
|
303
|
-
var _a;
|
|
304
|
-
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
305
|
-
return;
|
|
306
|
-
}
|
|
307
|
-
const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
|
|
308
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
309
|
-
category: this.searchContext,
|
|
310
|
-
action: analyticsActions.filterByTitle,
|
|
311
|
-
label: cleared
|
|
312
|
-
? `clear-${prevSelectedLetter}`
|
|
313
|
-
: `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
|
|
314
|
-
});
|
|
315
|
-
}
|
|
316
|
-
selectedTitleLetterChanged() {
|
|
317
|
-
this.titleQuery = this.selectedTitleFilter
|
|
318
|
-
? `firstTitle:${this.selectedTitleFilter}`
|
|
319
|
-
: undefined;
|
|
320
|
-
}
|
|
321
|
-
/** Send Analytics when filtering by creator's first letter
|
|
322
|
-
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
323
|
-
* */
|
|
324
|
-
sendFilterByCreatorAnalytics(prevSelectedLetter) {
|
|
325
|
-
var _a;
|
|
326
|
-
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
327
|
-
return;
|
|
328
|
-
}
|
|
329
|
-
const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
|
|
330
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
331
|
-
category: this.searchContext,
|
|
332
|
-
action: analyticsActions.filterByCreator,
|
|
333
|
-
label: cleared
|
|
334
|
-
? `clear-${prevSelectedLetter}`
|
|
335
|
-
: `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
selectedCreatorLetterChanged() {
|
|
339
|
-
this.creatorQuery = this.selectedCreatorFilter
|
|
340
|
-
? `firstCreator:${this.selectedCreatorFilter}`
|
|
341
|
-
: undefined;
|
|
342
|
-
}
|
|
343
|
-
titleLetterSelected(e) {
|
|
344
|
-
this.selectedCreatorFilter = null;
|
|
345
|
-
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
346
|
-
}
|
|
347
|
-
creatorLetterSelected(e) {
|
|
348
|
-
this.selectedTitleFilter = null;
|
|
349
|
-
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
350
|
-
}
|
|
351
|
-
get mobileFacetsTemplate() {
|
|
255
|
+
`;
|
|
256
|
+
}
|
|
257
|
+
userChangedSort(e) {
|
|
258
|
+
var _a;
|
|
259
|
+
const { selectedSort, sortDirection } = e.detail;
|
|
260
|
+
this.selectedSort = selectedSort;
|
|
261
|
+
this.sortDirection = sortDirection;
|
|
262
|
+
if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
|
|
263
|
+
this.goToPage(1);
|
|
264
|
+
}
|
|
265
|
+
this.currentPage = 1;
|
|
266
|
+
}
|
|
267
|
+
sendSortByAnalytics(prevSortDirection) {
|
|
268
|
+
var _a;
|
|
269
|
+
const directionCleared = prevSortDirection && !this.sortDirection;
|
|
270
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
271
|
+
category: this.searchContext,
|
|
272
|
+
action: analyticsActions.sortBy,
|
|
273
|
+
label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
selectedSortChanged() {
|
|
277
|
+
if (this.selectedSort === 'relevance' || this.sortDirection === null) {
|
|
278
|
+
this.sortParam = null;
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
const sortField = SortFieldToMetadataField[this.selectedSort];
|
|
282
|
+
if (!sortField)
|
|
283
|
+
return;
|
|
284
|
+
this.sortParam = { field: sortField, direction: this.sortDirection };
|
|
285
|
+
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
286
|
+
this.updatePrefixFiltersForCurrentSort();
|
|
287
|
+
}
|
|
288
|
+
displayModeChanged(e) {
|
|
289
|
+
var _a;
|
|
290
|
+
this.displayMode = e.detail.displayMode;
|
|
291
|
+
if (this.displayMode) {
|
|
292
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
293
|
+
category: this.searchContext,
|
|
294
|
+
action: analyticsActions.displayMode,
|
|
295
|
+
label: this.displayMode,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
/** Send Analytics when sorting by title's first letter
|
|
300
|
+
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
301
|
+
* */
|
|
302
|
+
sendFilterByTitleAnalytics(prevSelectedLetter) {
|
|
303
|
+
var _a;
|
|
304
|
+
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
|
|
308
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
309
|
+
category: this.searchContext,
|
|
310
|
+
action: analyticsActions.filterByTitle,
|
|
311
|
+
label: cleared
|
|
312
|
+
? `clear-${prevSelectedLetter}`
|
|
313
|
+
: `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
selectedTitleLetterChanged() {
|
|
317
|
+
this.titleQuery = this.selectedTitleFilter
|
|
318
|
+
? `firstTitle:${this.selectedTitleFilter}`
|
|
319
|
+
: undefined;
|
|
320
|
+
}
|
|
321
|
+
/** Send Analytics when filtering by creator's first letter
|
|
322
|
+
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
323
|
+
* */
|
|
324
|
+
sendFilterByCreatorAnalytics(prevSelectedLetter) {
|
|
325
|
+
var _a;
|
|
326
|
+
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
327
|
+
return;
|
|
328
|
+
}
|
|
329
|
+
const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
|
|
330
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
331
|
+
category: this.searchContext,
|
|
332
|
+
action: analyticsActions.filterByCreator,
|
|
333
|
+
label: cleared
|
|
334
|
+
? `clear-${prevSelectedLetter}`
|
|
335
|
+
: `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
selectedCreatorLetterChanged() {
|
|
339
|
+
this.creatorQuery = this.selectedCreatorFilter
|
|
340
|
+
? `firstCreator:${this.selectedCreatorFilter}`
|
|
341
|
+
: undefined;
|
|
342
|
+
}
|
|
343
|
+
titleLetterSelected(e) {
|
|
344
|
+
this.selectedCreatorFilter = null;
|
|
345
|
+
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
346
|
+
}
|
|
347
|
+
creatorLetterSelected(e) {
|
|
348
|
+
this.selectedTitleFilter = null;
|
|
349
|
+
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
350
|
+
}
|
|
351
|
+
get mobileFacetsTemplate() {
|
|
352
352
|
return html `
|
|
353
353
|
<div id="mobile-filter-collapse">
|
|
354
354
|
<h1
|
|
355
|
-
@click=${() => {
|
|
356
|
-
this.isResizeToMobile = false;
|
|
357
|
-
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
355
|
+
@click=${() => {
|
|
356
|
+
this.isResizeToMobile = false;
|
|
357
|
+
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
358
358
|
}}
|
|
359
|
-
@keyup=${() => {
|
|
360
|
-
this.isResizeToMobile = false;
|
|
361
|
-
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
359
|
+
@keyup=${() => {
|
|
360
|
+
this.isResizeToMobile = false;
|
|
361
|
+
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
362
362
|
}}
|
|
363
363
|
>
|
|
364
364
|
<span class="collapser ${this.mobileFacetsVisible ? 'open' : ''}">
|
|
@@ -367,9 +367,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
367
367
|
Filters
|
|
368
368
|
</h1>
|
|
369
369
|
</div>
|
|
370
|
-
`;
|
|
371
|
-
}
|
|
372
|
-
get facetsTemplate() {
|
|
370
|
+
`;
|
|
371
|
+
}
|
|
372
|
+
get facetsTemplate() {
|
|
373
373
|
return html `
|
|
374
374
|
<collection-facets
|
|
375
375
|
@facetsChanged=${this.facetsChanged}
|
|
@@ -397,16 +397,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
397
397
|
.analyticsHandler=${this.analyticsHandler}
|
|
398
398
|
>
|
|
399
399
|
</collection-facets>
|
|
400
|
-
`;
|
|
401
|
-
}
|
|
402
|
-
get loadingTemplate() {
|
|
400
|
+
`;
|
|
401
|
+
}
|
|
402
|
+
get loadingTemplate() {
|
|
403
403
|
return html `
|
|
404
404
|
<div class="loading-cover">
|
|
405
405
|
<circular-activity-indicator></circular-activity-indicator>
|
|
406
406
|
</div>
|
|
407
|
-
`;
|
|
408
|
-
}
|
|
409
|
-
get listHeaderTemplate() {
|
|
407
|
+
`;
|
|
408
|
+
}
|
|
409
|
+
get listHeaderTemplate() {
|
|
410
410
|
return html `
|
|
411
411
|
<div id="list-header">
|
|
412
412
|
<tile-dispatcher
|
|
@@ -418,704 +418,704 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
418
418
|
>
|
|
419
419
|
</tile-dispatcher>
|
|
420
420
|
</div>
|
|
421
|
-
`;
|
|
422
|
-
}
|
|
423
|
-
histogramDateRangeUpdated(e) {
|
|
424
|
-
var _a;
|
|
425
|
-
const { minDate, maxDate } = e.detail;
|
|
426
|
-
[this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
|
|
427
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
428
|
-
category: this.searchContext,
|
|
429
|
-
action: analyticsActions.histogramChanged,
|
|
430
|
-
label: this.dateRangeQueryClause,
|
|
431
|
-
});
|
|
432
|
-
}
|
|
433
|
-
get dateRangeQueryClause() {
|
|
434
|
-
if (!this.minSelectedDate || !this.maxSelectedDate) {
|
|
435
|
-
return undefined;
|
|
436
|
-
}
|
|
437
|
-
return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
|
|
438
|
-
}
|
|
439
|
-
firstUpdated() {
|
|
440
|
-
this.setupStateRestorationObserver();
|
|
441
|
-
this.restoreState();
|
|
442
|
-
}
|
|
443
|
-
updated(changed) {
|
|
444
|
-
var _a;
|
|
445
|
-
if (changed.has('displayMode') ||
|
|
446
|
-
changed.has('baseNavigationUrl') ||
|
|
447
|
-
changed.has('baseImageUrl') ||
|
|
448
|
-
changed.has('loggedIn')) {
|
|
449
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
450
|
-
}
|
|
451
|
-
if (changed.has('baseQuery')) {
|
|
452
|
-
this.emitBaseQueryChanged();
|
|
453
|
-
}
|
|
454
|
-
if (changed.has('searchType')) {
|
|
455
|
-
this.emitSearchTypeChanged();
|
|
456
|
-
}
|
|
457
|
-
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
458
|
-
this.persistState();
|
|
459
|
-
}
|
|
460
|
-
if (changed.has('baseQuery') ||
|
|
461
|
-
changed.has('titleQuery') ||
|
|
462
|
-
changed.has('creatorQuery') ||
|
|
463
|
-
changed.has('minSelectedDate') ||
|
|
464
|
-
changed.has('maxSelectedDate') ||
|
|
465
|
-
changed.has('sortParam') ||
|
|
466
|
-
changed.has('selectedFacets') ||
|
|
467
|
-
changed.has('searchService')) {
|
|
468
|
-
this.handleQueryChange();
|
|
469
|
-
}
|
|
470
|
-
if (changed.has('baseQuery') ||
|
|
471
|
-
changed.has('minSelectedDate') ||
|
|
472
|
-
changed.has('maxSelectedDate') ||
|
|
473
|
-
changed.has('selectedFacets')) {
|
|
474
|
-
this.refreshLetterCounts();
|
|
475
|
-
}
|
|
476
|
-
if (changed.has('selectedSort') || changed.has('sortDirection')) {
|
|
477
|
-
const prevSortDirection = changed.get('sortDirection');
|
|
478
|
-
this.sendSortByAnalytics(prevSortDirection);
|
|
479
|
-
this.selectedSortChanged();
|
|
480
|
-
}
|
|
481
|
-
if (changed.has('selectedTitleFilter')) {
|
|
482
|
-
this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
|
|
483
|
-
this.selectedTitleLetterChanged();
|
|
484
|
-
}
|
|
485
|
-
if (changed.has('selectedCreatorFilter')) {
|
|
486
|
-
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
487
|
-
this.selectedCreatorLetterChanged();
|
|
488
|
-
}
|
|
489
|
-
if (changed.has('pagesToRender')) {
|
|
490
|
-
if (!this.endOfDataReached && this.infiniteScroller) {
|
|
491
|
-
this.infiniteScroller.itemCount = this.estimatedTileCount;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (changed.has('resizeObserver')) {
|
|
495
|
-
const oldObserver = changed.get('resizeObserver');
|
|
496
|
-
if (oldObserver)
|
|
497
|
-
this.disconnectResizeObserver(oldObserver);
|
|
498
|
-
this.setupResizeObserver();
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
disconnectedCallback() {
|
|
502
|
-
if (this.resizeObserver) {
|
|
503
|
-
this.disconnectResizeObserver(this.resizeObserver);
|
|
504
|
-
}
|
|
505
|
-
if (this.boundNavigationHandler) {
|
|
506
|
-
window.removeEventListener('popstate', this.boundNavigationHandler);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
handleResize(entry) {
|
|
510
|
-
const previousView = this.mobileView;
|
|
511
|
-
if (entry.target === this.contentContainer) {
|
|
512
|
-
this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
|
|
513
|
-
// If changing from desktop to mobile disable transition
|
|
514
|
-
if (this.mobileView && !previousView) {
|
|
515
|
-
this.isResizeToMobile = true;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
emitBaseQueryChanged() {
|
|
520
|
-
this.dispatchEvent(new CustomEvent('baseQueryChanged', {
|
|
521
|
-
detail: {
|
|
522
|
-
baseQuery: this.baseQuery,
|
|
523
|
-
},
|
|
524
|
-
}));
|
|
525
|
-
}
|
|
526
|
-
emitSearchTypeChanged() {
|
|
527
|
-
this.dispatchEvent(new CustomEvent('searchTypeChanged', {
|
|
528
|
-
detail: this.searchType,
|
|
529
|
-
}));
|
|
530
|
-
}
|
|
531
|
-
disconnectResizeObserver(resizeObserver) {
|
|
532
|
-
resizeObserver.removeObserver({
|
|
533
|
-
target: this.contentContainer,
|
|
534
|
-
handler: this,
|
|
535
|
-
});
|
|
536
|
-
}
|
|
537
|
-
setupResizeObserver() {
|
|
538
|
-
if (!this.resizeObserver)
|
|
539
|
-
return;
|
|
540
|
-
this.resizeObserver.addObserver({
|
|
541
|
-
target: this.contentContainer,
|
|
542
|
-
handler: this,
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
/**
|
|
546
|
-
* When the visible cells change from the infinite scroller, we want to emit
|
|
547
|
-
* which page is currently visible so the consumer can update its UI or the URL
|
|
548
|
-
*
|
|
549
|
-
* @param e
|
|
550
|
-
* @returns
|
|
551
|
-
*/
|
|
552
|
-
visibleCellsChanged(e) {
|
|
553
|
-
if (this.isScrollingToCell)
|
|
554
|
-
return;
|
|
555
|
-
const { visibleCellIndices } = e.detail;
|
|
556
|
-
if (visibleCellIndices.length === 0)
|
|
557
|
-
return;
|
|
558
|
-
const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
|
|
559
|
-
const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
|
|
560
|
-
if (this.currentPage !== lastVisibleCellPage) {
|
|
561
|
-
this.currentPage = lastVisibleCellPage;
|
|
562
|
-
}
|
|
563
|
-
const event = new CustomEvent('visiblePageChanged', {
|
|
564
|
-
detail: {
|
|
565
|
-
pageNumber: lastVisibleCellPage,
|
|
566
|
-
},
|
|
567
|
-
});
|
|
568
|
-
this.dispatchEvent(event);
|
|
569
|
-
}
|
|
570
|
-
async handleQueryChange() {
|
|
571
|
-
var _a;
|
|
572
|
-
// only reset if the query has actually changed
|
|
573
|
-
if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
|
|
574
|
-
return;
|
|
575
|
-
this.previousQueryKey = this.pageFetchQueryKey;
|
|
576
|
-
this.dataSource = {};
|
|
577
|
-
this.totalResults = undefined;
|
|
578
|
-
this.aggregations = undefined;
|
|
579
|
-
this.fullYearsHistogramAggregation = undefined;
|
|
580
|
-
this.pageFetchesInProgress = {};
|
|
581
|
-
this.endOfDataReached = false;
|
|
582
|
-
this.pagesToRender = this.initialPageNumber;
|
|
583
|
-
// Reset the infinite scroller's item count, so that it
|
|
584
|
-
// shows tile placeholders until the new query's results load in
|
|
585
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
586
|
-
if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
|
|
587
|
-
this.scrollToPage(this.initialPageNumber);
|
|
588
|
-
}
|
|
589
|
-
this.initialQueryChangeHappened = true;
|
|
590
|
-
// if the query changed as part of a window.history pop event, we don't want to
|
|
591
|
-
// persist the state because it overwrites the forward history
|
|
592
|
-
if (!this.historyPopOccurred) {
|
|
593
|
-
this.persistState();
|
|
594
|
-
this.historyPopOccurred = false;
|
|
595
|
-
}
|
|
596
|
-
await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
|
|
597
|
-
}
|
|
598
|
-
setupStateRestorationObserver() {
|
|
599
|
-
if (this.boundNavigationHandler)
|
|
600
|
-
return;
|
|
601
|
-
this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
|
|
602
|
-
// when the user navigates back, we want to update the UI to match the URL
|
|
603
|
-
window.addEventListener('popstate', this.boundNavigationHandler);
|
|
604
|
-
}
|
|
605
|
-
historyNavigationHandler() {
|
|
606
|
-
this.historyPopOccurred = true;
|
|
607
|
-
this.restoreState();
|
|
608
|
-
}
|
|
609
|
-
restoreState() {
|
|
610
|
-
var _a, _b, _c, _d, _e, _f;
|
|
611
|
-
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
612
|
-
this.displayMode = restorationState.displayMode;
|
|
613
|
-
if (restorationState.searchType != null)
|
|
614
|
-
this.searchType = restorationState.searchType;
|
|
615
|
-
this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
|
|
616
|
-
this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
|
|
617
|
-
this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
|
|
618
|
-
this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
|
|
619
|
-
this.selectedFacets = restorationState.selectedFacets;
|
|
620
|
-
this.baseQuery = restorationState.baseQuery;
|
|
621
|
-
this.titleQuery = restorationState.titleQuery;
|
|
622
|
-
this.creatorQuery = restorationState.creatorQuery;
|
|
623
|
-
this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
|
|
624
|
-
this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
|
|
625
|
-
this.minSelectedDate = restorationState.minSelectedDate;
|
|
626
|
-
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
627
|
-
if (this.currentPage > 1) {
|
|
628
|
-
this.goToPage(this.currentPage);
|
|
629
|
-
}
|
|
630
|
-
}
|
|
631
|
-
persistState() {
|
|
632
|
-
var _a, _b, _c, _d, _e;
|
|
633
|
-
const restorationState = {
|
|
634
|
-
displayMode: this.displayMode,
|
|
635
|
-
searchType: this.searchType,
|
|
636
|
-
sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
|
|
637
|
-
selectedSort: this.selectedSort,
|
|
638
|
-
sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
|
|
639
|
-
selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
|
|
640
|
-
baseQuery: this.baseQuery,
|
|
641
|
-
currentPage: this.currentPage,
|
|
642
|
-
titleQuery: this.titleQuery,
|
|
643
|
-
creatorQuery: this.creatorQuery,
|
|
644
|
-
minSelectedDate: this.minSelectedDate,
|
|
645
|
-
maxSelectedDate: this.maxSelectedDate,
|
|
646
|
-
selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
|
|
647
|
-
selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
|
|
648
|
-
};
|
|
649
|
-
this.restorationStateHandler.persistState(restorationState);
|
|
650
|
-
}
|
|
651
|
-
async doInitialPageFetch() {
|
|
652
|
-
this.searchResultsLoading = true;
|
|
653
|
-
await this.fetchPage(this.initialPageNumber);
|
|
654
|
-
this.searchResultsLoading = false;
|
|
655
|
-
}
|
|
656
|
-
get filterMap() {
|
|
657
|
-
const builder = new FilterMapBuilder();
|
|
658
|
-
// Add the date range, if applicable
|
|
659
|
-
if (this.minSelectedDate) {
|
|
660
|
-
builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
|
|
661
|
-
}
|
|
662
|
-
if (this.maxSelectedDate) {
|
|
663
|
-
builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
|
|
664
|
-
}
|
|
665
|
-
// Add any selected facets
|
|
666
|
-
if (this.selectedFacets) {
|
|
667
|
-
for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
|
|
668
|
-
const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
|
|
669
|
-
for (const [value, bucket] of Object.entries(values)) {
|
|
670
|
-
let constraint;
|
|
671
|
-
if (bucket.state === 'selected') {
|
|
672
|
-
constraint = FilterConstraint.INCLUDE;
|
|
673
|
-
}
|
|
674
|
-
else if (bucket.state === 'hidden') {
|
|
675
|
-
constraint = FilterConstraint.EXCLUDE;
|
|
676
|
-
}
|
|
677
|
-
if (constraint) {
|
|
678
|
-
builder.addFilter(name, value, constraint);
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
const filterMap = builder.build();
|
|
684
|
-
return filterMap;
|
|
685
|
-
}
|
|
686
|
-
/** The base query joined with any title/creator letter filters */
|
|
687
|
-
get filteredQuery() {
|
|
688
|
-
if (!this.baseQuery)
|
|
689
|
-
return undefined;
|
|
690
|
-
let filteredQuery = this.baseQuery;
|
|
691
|
-
const { sortFilterQueries } = this;
|
|
692
|
-
if (sortFilterQueries) {
|
|
693
|
-
filteredQuery += ` AND ${sortFilterQueries}`;
|
|
694
|
-
}
|
|
695
|
-
return filteredQuery;
|
|
696
|
-
}
|
|
697
|
-
/** The full query, including year facets and date range clauses */
|
|
698
|
-
get fullQuery() {
|
|
699
|
-
if (!this.baseQuery)
|
|
700
|
-
return undefined;
|
|
701
|
-
let fullQuery = this.baseQuery;
|
|
702
|
-
const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
|
|
703
|
-
if (facetQuery) {
|
|
704
|
-
fullQuery += ` AND ${facetQuery}`;
|
|
705
|
-
}
|
|
706
|
-
if (dateRangeQueryClause) {
|
|
707
|
-
fullQuery += ` AND ${dateRangeQueryClause}`;
|
|
708
|
-
}
|
|
709
|
-
if (sortFilterQueries) {
|
|
710
|
-
fullQuery += ` AND ${sortFilterQueries}`;
|
|
711
|
-
}
|
|
712
|
-
return fullQuery;
|
|
713
|
-
}
|
|
714
|
-
/** The full query without any title/creator letter filters */
|
|
715
|
-
get fullQueryWithoutAlphaFilters() {
|
|
716
|
-
if (!this.baseQuery)
|
|
717
|
-
return undefined;
|
|
718
|
-
let fullQuery = this.baseQuery;
|
|
719
|
-
const { facetQuery, dateRangeQueryClause } = this;
|
|
720
|
-
if (facetQuery) {
|
|
721
|
-
fullQuery += ` AND ${facetQuery}`;
|
|
722
|
-
}
|
|
723
|
-
if (dateRangeQueryClause) {
|
|
724
|
-
fullQuery += ` AND ${dateRangeQueryClause}`;
|
|
725
|
-
}
|
|
726
|
-
return fullQuery;
|
|
727
|
-
}
|
|
728
|
-
/**
|
|
729
|
-
* Generates a query string for the given facets
|
|
730
|
-
*
|
|
731
|
-
* Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
|
|
732
|
-
*/
|
|
733
|
-
get facetQuery() {
|
|
734
|
-
if (!this.selectedFacets)
|
|
735
|
-
return undefined;
|
|
736
|
-
const facetClauses = [];
|
|
737
|
-
for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
|
|
738
|
-
facetClauses.push(this.buildFacetClause(facetName, facetValues));
|
|
739
|
-
}
|
|
740
|
-
return this.joinFacetClauses(facetClauses);
|
|
741
|
-
}
|
|
742
|
-
/**
|
|
743
|
-
* Builds an OR-joined facet clause for the given facet name and values.
|
|
744
|
-
*
|
|
745
|
-
* E.g., for name `subject` and values
|
|
746
|
-
* `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
|
|
747
|
-
* this will produce the clause
|
|
748
|
-
* `subject:("foo" OR -"bar")`.
|
|
749
|
-
*
|
|
750
|
-
* @param facetName The facet type (e.g., 'collection')
|
|
751
|
-
* @param facetValues The facet buckets, mapped by their keys
|
|
752
|
-
*/
|
|
753
|
-
buildFacetClause(facetName, facetValues) {
|
|
754
|
-
const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
|
|
755
|
-
const facetEntries = Object.entries(values);
|
|
756
|
-
if (facetEntries.length === 0)
|
|
757
|
-
return '';
|
|
758
|
-
const facetValuesArray = [];
|
|
759
|
-
for (const [key, facetData] of facetEntries) {
|
|
760
|
-
const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
|
|
761
|
-
facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
|
|
762
|
-
}
|
|
763
|
-
const valueQuery = facetValuesArray.join(` OR `);
|
|
764
|
-
return `${facetQueryName}:(${valueQuery})`;
|
|
765
|
-
}
|
|
766
|
-
/**
|
|
767
|
-
* Handles some special pre-request normalization steps for certain facet types
|
|
768
|
-
* that require them.
|
|
769
|
-
*
|
|
770
|
-
* @param facetName The name of the facet type (e.g., 'language')
|
|
771
|
-
* @param facetValues An array of values for that facet type
|
|
772
|
-
*/
|
|
773
|
-
prepareFacetForFetch(facetName, facetValues) {
|
|
774
|
-
// eslint-disable-next-line prefer-const
|
|
775
|
-
let [normalizedName, normalizedValues] = [facetName, facetValues];
|
|
776
|
-
// The full "search engine" name of the lending field is "lending___status"
|
|
777
|
-
if (facetName === 'lending') {
|
|
778
|
-
normalizedName = 'lending___status';
|
|
779
|
-
}
|
|
780
|
-
return {
|
|
781
|
-
name: normalizedName,
|
|
782
|
-
values: normalizedValues,
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
/**
|
|
786
|
-
* Takes an array of facet clauses, and combines them into a
|
|
787
|
-
* full AND-joined facet query string. Empty clauses are ignored.
|
|
788
|
-
*/
|
|
789
|
-
joinFacetClauses(facetClauses) {
|
|
790
|
-
const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
|
|
791
|
-
return nonEmptyFacetClauses.length > 0
|
|
792
|
-
? `(${nonEmptyFacetClauses.join(' AND ')})`
|
|
793
|
-
: undefined;
|
|
794
|
-
}
|
|
795
|
-
facetsChanged(e) {
|
|
796
|
-
this.selectedFacets = e.detail;
|
|
797
|
-
}
|
|
798
|
-
facetClickHandler(name, facetSelected, negative) {
|
|
799
|
-
var _a, _b;
|
|
800
|
-
if (negative) {
|
|
801
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
802
|
-
category: this.searchContext,
|
|
803
|
-
action: facetSelected
|
|
804
|
-
? analyticsActions.facetNegativeSelected
|
|
805
|
-
: analyticsActions.facetNegativeDeselected,
|
|
806
|
-
label: name,
|
|
807
|
-
});
|
|
808
|
-
}
|
|
809
|
-
else {
|
|
810
|
-
(_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
|
|
811
|
-
category: this.searchContext,
|
|
812
|
-
action: facetSelected
|
|
813
|
-
? analyticsActions.facetSelected
|
|
814
|
-
: analyticsActions.facetDeselected,
|
|
815
|
-
label: name,
|
|
816
|
-
});
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
async fetchFacets() {
|
|
820
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
821
|
-
if (!this.filteredQuery)
|
|
822
|
-
return;
|
|
823
|
-
const params = {
|
|
824
|
-
query: this.filteredQuery,
|
|
825
|
-
rows: 0,
|
|
826
|
-
filters: this.filterMap,
|
|
827
|
-
// Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
|
|
828
|
-
aggregationsSize: 10,
|
|
829
|
-
// Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
|
|
830
|
-
// The default aggregations for the search_results page type should be what we need here.
|
|
831
|
-
};
|
|
832
|
-
this.facetsLoading = true;
|
|
833
|
-
this.previousSearchType = this.searchType;
|
|
834
|
-
const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
|
|
835
|
-
this.facetsLoading = false;
|
|
836
|
-
this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
|
|
837
|
-
this.fullYearsHistogramAggregation =
|
|
838
|
-
(_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
|
|
839
|
-
}
|
|
840
|
-
scrollToPage(pageNumber) {
|
|
841
|
-
return new Promise(resolve => {
|
|
842
|
-
const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
|
|
843
|
-
// without this setTimeout, Safari just pauses until the `fetchPage` is complete
|
|
844
|
-
// then scrolls to the cell
|
|
845
|
-
setTimeout(() => {
|
|
846
|
-
var _a;
|
|
847
|
-
this.isScrollingToCell = true;
|
|
848
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
|
|
849
|
-
// This timeout is to give the scroll animation time to finish
|
|
850
|
-
// then updating the infinite scroller once we're done scrolling
|
|
851
|
-
// There's no scroll animation completion callback so we're
|
|
852
|
-
// giving it 0.5s to finish.
|
|
853
|
-
setTimeout(() => {
|
|
854
|
-
var _a;
|
|
855
|
-
this.isScrollingToCell = false;
|
|
856
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
857
|
-
resolve();
|
|
858
|
-
}, 500);
|
|
859
|
-
}, 0);
|
|
860
|
-
});
|
|
861
|
-
}
|
|
862
|
-
/**
|
|
863
|
-
* The query key is a string that uniquely identifies the current search.
|
|
864
|
-
* It consists of:
|
|
865
|
-
* - The current base query
|
|
866
|
-
* - The current search type
|
|
867
|
-
* - Any currently-applied facets
|
|
868
|
-
* - Any currently-applied date range
|
|
869
|
-
* - Any currently-applied prefix filters
|
|
870
|
-
* - The current sort options
|
|
871
|
-
*
|
|
872
|
-
* This lets us keep track of queries so we don't persist data that's
|
|
873
|
-
* no longer relevant.
|
|
874
|
-
*/
|
|
875
|
-
get pageFetchQueryKey() {
|
|
876
|
-
var _a, _b;
|
|
877
|
-
return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
|
|
878
|
-
}
|
|
879
|
-
async fetchPage(pageNumber) {
|
|
880
|
-
var _a, _b, _c, _d, _e;
|
|
881
|
-
if (!this.filteredQuery)
|
|
882
|
-
return;
|
|
883
|
-
// if we already have data, don't fetch again
|
|
884
|
-
if (this.dataSource[pageNumber])
|
|
885
|
-
return;
|
|
886
|
-
if (this.endOfDataReached)
|
|
887
|
-
return;
|
|
888
|
-
// if a fetch is already in progress for this query and page, don't fetch again
|
|
889
|
-
const { pageFetchQueryKey } = this;
|
|
890
|
-
const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
|
|
891
|
-
if (pageFetches.has(pageNumber))
|
|
892
|
-
return;
|
|
893
|
-
pageFetches.add(pageNumber);
|
|
894
|
-
this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
|
|
895
|
-
const sortParams = this.sortParam ? [this.sortParam] : [];
|
|
896
|
-
const params = {
|
|
897
|
-
query: this.filteredQuery,
|
|
898
|
-
page: pageNumber,
|
|
899
|
-
rows: this.pageSize,
|
|
900
|
-
sort: sortParams,
|
|
901
|
-
filters: this.filterMap,
|
|
902
|
-
aggregations: { omit: true },
|
|
903
|
-
};
|
|
904
|
-
const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
|
|
905
|
-
const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
|
|
906
|
-
if (!success)
|
|
907
|
-
return;
|
|
908
|
-
this.totalResults = success.response.totalResults;
|
|
909
|
-
// this is checking to see if the query has changed since the data was fetched
|
|
910
|
-
// if so, we just want to discard the data since there should be a new query
|
|
911
|
-
// right behind it
|
|
912
|
-
const searchQuery = success.request.clientParameters.user_query;
|
|
913
|
-
const searchSort = success.request.clientParameters.sort;
|
|
914
|
-
let sortChanged = false;
|
|
915
|
-
if (!searchSort || searchSort.length === 0) {
|
|
916
|
-
// if we went from no sort to sort, the sort has changed
|
|
917
|
-
if (this.sortParam) {
|
|
918
|
-
sortChanged = true;
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
else {
|
|
922
|
-
// check if the sort has changed
|
|
923
|
-
for (const sortType of searchSort) {
|
|
924
|
-
const [field, direction] = sortType.split(':');
|
|
925
|
-
if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
|
|
926
|
-
direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
|
|
927
|
-
sortChanged = true;
|
|
928
|
-
break;
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
|
|
933
|
-
if (queryChangedSinceFetch)
|
|
934
|
-
return;
|
|
935
|
-
const { results } = success.response;
|
|
936
|
-
if (results && results.length > 0) {
|
|
937
|
-
this.preloadCollectionNames(results);
|
|
938
|
-
this.updateDataSource(pageNumber, results);
|
|
939
|
-
}
|
|
940
|
-
// When we reach the end of the data, we can set the infinite scroller's
|
|
941
|
-
// item count to the real total number of results (rather than the
|
|
942
|
-
// temporary estimates based on pages rendered so far).
|
|
943
|
-
if (results.length < this.pageSize) {
|
|
944
|
-
this.endOfDataReached = true;
|
|
945
|
-
if (this.infiniteScroller) {
|
|
946
|
-
this.infiniteScroller.itemCount = this.totalResults;
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
(_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
|
|
950
|
-
this.searchResultsLoading = false;
|
|
951
|
-
}
|
|
952
|
-
preloadCollectionNames(results) {
|
|
953
|
-
var _a;
|
|
954
|
-
const collectionIds = results
|
|
955
|
-
.map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
|
|
956
|
-
.flat();
|
|
957
|
-
const collectionIdsArray = Array.from(new Set(collectionIds));
|
|
958
|
-
(_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
|
|
959
|
-
}
|
|
960
|
-
/**
|
|
961
|
-
* This is useful for determining whether we need to reload the scroller.
|
|
962
|
-
*
|
|
963
|
-
* When the fetch completes, we need to reload the scroller if the cells for that
|
|
964
|
-
* page are visible, but if the page is not currenlty visible, we don't need to reload
|
|
965
|
-
*/
|
|
966
|
-
get currentVisiblePageNumbers() {
|
|
967
|
-
var _a, _b;
|
|
968
|
-
const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
|
|
969
|
-
const visiblePages = new Set();
|
|
970
|
-
visibleCells.forEach(cellIndex => {
|
|
971
|
-
const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
|
|
972
|
-
visiblePages.add(visiblePage);
|
|
973
|
-
});
|
|
974
|
-
return Array.from(visiblePages);
|
|
975
|
-
}
|
|
976
|
-
/**
|
|
977
|
-
* Update the datasource from the fetch response
|
|
978
|
-
*
|
|
979
|
-
* @param pageNumber
|
|
980
|
-
* @param results
|
|
981
|
-
*/
|
|
982
|
-
updateDataSource(pageNumber, results) {
|
|
983
|
-
var _a;
|
|
984
|
-
// copy our existing datasource so when we set it below, it gets set
|
|
985
|
-
// instead of modifying the existing dataSource since object changes
|
|
986
|
-
// don't trigger a re-render
|
|
987
|
-
const datasource = { ...this.dataSource };
|
|
988
|
-
const tiles = [];
|
|
989
|
-
results === null || results === void 0 ? void 0 : results.forEach(result => {
|
|
990
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
991
|
-
if (!result.identifier)
|
|
992
|
-
return;
|
|
993
|
-
let loginRequired = false;
|
|
994
|
-
let contentWarning = false;
|
|
995
|
-
// Check if item and item in "modifying" collection, setting above flags
|
|
996
|
-
if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
|
|
997
|
-
((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
|
|
998
|
-
for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
|
|
999
|
-
if (collection === 'loggedin') {
|
|
1000
|
-
loginRequired = true;
|
|
1001
|
-
if (contentWarning)
|
|
1002
|
-
break;
|
|
1003
|
-
}
|
|
1004
|
-
if (collection === 'no-preview') {
|
|
1005
|
-
contentWarning = true;
|
|
1006
|
-
if (loginRequired)
|
|
1007
|
-
break;
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
}
|
|
1011
|
-
tiles.push({
|
|
1012
|
-
averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
|
|
1013
|
-
collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
|
|
1014
|
-
collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
|
|
1015
|
-
collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
|
|
1016
|
-
commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
|
|
1017
|
-
creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
|
|
1018
|
-
creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
|
|
1019
|
-
dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
|
|
1020
|
-
dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
|
|
1021
|
-
datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
|
|
1022
|
-
dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
|
|
1023
|
-
description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
|
|
1024
|
-
favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
|
|
1025
|
-
href: (_z = result.__href__) === null || _z === void 0 ? void 0 : _z.value,
|
|
1026
|
-
identifier: result.identifier,
|
|
1027
|
-
issue: (_0 = result.issue) === null || _0 === void 0 ? void 0 : _0.value,
|
|
1028
|
-
itemCount: (_2 = (_1 = result.item_count) === null || _1 === void 0 ? void 0 : _1.value) !== null && _2 !== void 0 ? _2 : 0,
|
|
1029
|
-
mediatype: (_4 = (_3 = result.mediatype) === null || _3 === void 0 ? void 0 : _3.value) !== null && _4 !== void 0 ? _4 : 'data',
|
|
1030
|
-
snippets: (_6 = (_5 = result.highlight) === null || _5 === void 0 ? void 0 : _5.values) !== null && _6 !== void 0 ? _6 : [],
|
|
1031
|
-
source: (_7 = result.source) === null || _7 === void 0 ? void 0 : _7.value,
|
|
1032
|
-
subjects: (_9 = (_8 = result.subject) === null || _8 === void 0 ? void 0 : _8.values) !== null && _9 !== void 0 ? _9 : [],
|
|
1033
|
-
title: (_11 = (_10 = result.title) === null || _10 === void 0 ? void 0 : _10.value) !== null && _11 !== void 0 ? _11 : '',
|
|
1034
|
-
volume: (_12 = result.volume) === null || _12 === void 0 ? void 0 : _12.value,
|
|
1035
|
-
viewCount: (_14 = (_13 = result.downloads) === null || _13 === void 0 ? void 0 : _13.value) !== null && _14 !== void 0 ? _14 : 0,
|
|
1036
|
-
weeklyViewCount: (_15 = result.week) === null || _15 === void 0 ? void 0 : _15.value,
|
|
1037
|
-
loginRequired,
|
|
1038
|
-
contentWarning,
|
|
1039
|
-
});
|
|
1040
|
-
});
|
|
1041
|
-
datasource[pageNumber] = tiles;
|
|
1042
|
-
this.dataSource = datasource;
|
|
1043
|
-
const visiblePages = this.currentVisiblePageNumbers;
|
|
1044
|
-
const needsReload = visiblePages.includes(pageNumber);
|
|
1045
|
-
if (needsReload) {
|
|
1046
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
1047
|
-
}
|
|
1048
|
-
}
|
|
1049
|
-
/** Fetches the aggregation buckets for the given prefix filter type. */
|
|
1050
|
-
async fetchPrefixFilterBuckets(filterType) {
|
|
1051
|
-
var _a, _b, _c, _d, _e, _f;
|
|
1052
|
-
if (!this.fullQueryWithoutAlphaFilters)
|
|
1053
|
-
return [];
|
|
1054
|
-
const filterAggregationKey = prefixFilterAggregationKeys[filterType];
|
|
1055
|
-
const params = {
|
|
1056
|
-
query: this.fullQueryWithoutAlphaFilters,
|
|
1057
|
-
rows: 0,
|
|
1058
|
-
// Only fetch the firstTitle or firstCreator aggregation
|
|
1059
|
-
aggregations: { simpleParams: [filterAggregationKey] },
|
|
1060
|
-
// Fetch all 26 letter buckets
|
|
1061
|
-
aggregationsSize: 26,
|
|
1062
|
-
};
|
|
1063
|
-
const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
|
|
1064
|
-
return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
|
|
1065
|
-
}
|
|
1066
|
-
/** Fetches and caches the prefix filter counts for the given filter type. */
|
|
1067
|
-
async updatePrefixFilterCounts(filterType) {
|
|
1068
|
-
const buckets = await this.fetchPrefixFilterBuckets(filterType);
|
|
1069
|
-
// Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
|
|
1070
|
-
this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
|
|
1071
|
-
this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
|
|
1072
|
-
acc[bucket.key.toUpperCase()] = bucket.doc_count;
|
|
1073
|
-
return acc;
|
|
1074
|
-
}, {});
|
|
1075
|
-
}
|
|
1076
|
-
/**
|
|
1077
|
-
* Fetches and caches the prefix filter counts for the current sort type,
|
|
1078
|
-
* provided it is one that permits prefix filtering. (If not, this does nothing).
|
|
1079
|
-
*/
|
|
1080
|
-
async updatePrefixFiltersForCurrentSort() {
|
|
1081
|
-
if (['title', 'creator'].includes(this.selectedSort)) {
|
|
1082
|
-
const filterType = this.selectedSort;
|
|
1083
|
-
if (!this.prefixFilterCountMap[filterType]) {
|
|
1084
|
-
this.updatePrefixFilterCounts(filterType);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
/**
|
|
1089
|
-
* Clears the cached letter counts for both title and creator, and
|
|
1090
|
-
* fetches a new set of counts for whichever of them is the currently
|
|
1091
|
-
* selected sort option (which may be neither).
|
|
1092
|
-
*
|
|
1093
|
-
* Call this whenever the counts are invalidated (e.g., by a query change).
|
|
1094
|
-
*/
|
|
1095
|
-
refreshLetterCounts() {
|
|
1096
|
-
this.prefixFilterCountMap = {};
|
|
1097
|
-
this.updatePrefixFiltersForCurrentSort();
|
|
1098
|
-
}
|
|
1099
|
-
/**
|
|
1100
|
-
* Callback when a result is selected
|
|
1101
|
-
*/
|
|
1102
|
-
resultSelected(event) {
|
|
1103
|
-
var _a, _b;
|
|
1104
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
1105
|
-
category: this.searchContext,
|
|
1106
|
-
action: analyticsActions.resultSelected,
|
|
1107
|
-
label: event.detail.mediatype,
|
|
1108
|
-
});
|
|
1109
|
-
(_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
|
|
1110
|
-
category: this.searchContext,
|
|
1111
|
-
action: analyticsActions.resultSelected,
|
|
1112
|
-
label: `page-${this.currentPage}`,
|
|
1113
|
-
});
|
|
1114
|
-
}
|
|
1115
|
-
cellForIndex(index) {
|
|
1116
|
-
const model = this.tileModelAtCellIndex(index);
|
|
1117
|
-
if (!model)
|
|
1118
|
-
return undefined;
|
|
421
|
+
`;
|
|
422
|
+
}
|
|
423
|
+
histogramDateRangeUpdated(e) {
|
|
424
|
+
var _a;
|
|
425
|
+
const { minDate, maxDate } = e.detail;
|
|
426
|
+
[this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
|
|
427
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
428
|
+
category: this.searchContext,
|
|
429
|
+
action: analyticsActions.histogramChanged,
|
|
430
|
+
label: this.dateRangeQueryClause,
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
get dateRangeQueryClause() {
|
|
434
|
+
if (!this.minSelectedDate || !this.maxSelectedDate) {
|
|
435
|
+
return undefined;
|
|
436
|
+
}
|
|
437
|
+
return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
|
|
438
|
+
}
|
|
439
|
+
firstUpdated() {
|
|
440
|
+
this.setupStateRestorationObserver();
|
|
441
|
+
this.restoreState();
|
|
442
|
+
}
|
|
443
|
+
updated(changed) {
|
|
444
|
+
var _a;
|
|
445
|
+
if (changed.has('displayMode') ||
|
|
446
|
+
changed.has('baseNavigationUrl') ||
|
|
447
|
+
changed.has('baseImageUrl') ||
|
|
448
|
+
changed.has('loggedIn')) {
|
|
449
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
450
|
+
}
|
|
451
|
+
if (changed.has('baseQuery')) {
|
|
452
|
+
this.emitBaseQueryChanged();
|
|
453
|
+
}
|
|
454
|
+
if (changed.has('searchType')) {
|
|
455
|
+
this.emitSearchTypeChanged();
|
|
456
|
+
}
|
|
457
|
+
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
458
|
+
this.persistState();
|
|
459
|
+
}
|
|
460
|
+
if (changed.has('baseQuery') ||
|
|
461
|
+
changed.has('titleQuery') ||
|
|
462
|
+
changed.has('creatorQuery') ||
|
|
463
|
+
changed.has('minSelectedDate') ||
|
|
464
|
+
changed.has('maxSelectedDate') ||
|
|
465
|
+
changed.has('sortParam') ||
|
|
466
|
+
changed.has('selectedFacets') ||
|
|
467
|
+
changed.has('searchService')) {
|
|
468
|
+
this.handleQueryChange();
|
|
469
|
+
}
|
|
470
|
+
if (changed.has('baseQuery') ||
|
|
471
|
+
changed.has('minSelectedDate') ||
|
|
472
|
+
changed.has('maxSelectedDate') ||
|
|
473
|
+
changed.has('selectedFacets')) {
|
|
474
|
+
this.refreshLetterCounts();
|
|
475
|
+
}
|
|
476
|
+
if (changed.has('selectedSort') || changed.has('sortDirection')) {
|
|
477
|
+
const prevSortDirection = changed.get('sortDirection');
|
|
478
|
+
this.sendSortByAnalytics(prevSortDirection);
|
|
479
|
+
this.selectedSortChanged();
|
|
480
|
+
}
|
|
481
|
+
if (changed.has('selectedTitleFilter')) {
|
|
482
|
+
this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
|
|
483
|
+
this.selectedTitleLetterChanged();
|
|
484
|
+
}
|
|
485
|
+
if (changed.has('selectedCreatorFilter')) {
|
|
486
|
+
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
487
|
+
this.selectedCreatorLetterChanged();
|
|
488
|
+
}
|
|
489
|
+
if (changed.has('pagesToRender')) {
|
|
490
|
+
if (!this.endOfDataReached && this.infiniteScroller) {
|
|
491
|
+
this.infiniteScroller.itemCount = this.estimatedTileCount;
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
if (changed.has('resizeObserver')) {
|
|
495
|
+
const oldObserver = changed.get('resizeObserver');
|
|
496
|
+
if (oldObserver)
|
|
497
|
+
this.disconnectResizeObserver(oldObserver);
|
|
498
|
+
this.setupResizeObserver();
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
disconnectedCallback() {
|
|
502
|
+
if (this.resizeObserver) {
|
|
503
|
+
this.disconnectResizeObserver(this.resizeObserver);
|
|
504
|
+
}
|
|
505
|
+
if (this.boundNavigationHandler) {
|
|
506
|
+
window.removeEventListener('popstate', this.boundNavigationHandler);
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
handleResize(entry) {
|
|
510
|
+
const previousView = this.mobileView;
|
|
511
|
+
if (entry.target === this.contentContainer) {
|
|
512
|
+
this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
|
|
513
|
+
// If changing from desktop to mobile disable transition
|
|
514
|
+
if (this.mobileView && !previousView) {
|
|
515
|
+
this.isResizeToMobile = true;
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
emitBaseQueryChanged() {
|
|
520
|
+
this.dispatchEvent(new CustomEvent('baseQueryChanged', {
|
|
521
|
+
detail: {
|
|
522
|
+
baseQuery: this.baseQuery,
|
|
523
|
+
},
|
|
524
|
+
}));
|
|
525
|
+
}
|
|
526
|
+
emitSearchTypeChanged() {
|
|
527
|
+
this.dispatchEvent(new CustomEvent('searchTypeChanged', {
|
|
528
|
+
detail: this.searchType,
|
|
529
|
+
}));
|
|
530
|
+
}
|
|
531
|
+
disconnectResizeObserver(resizeObserver) {
|
|
532
|
+
resizeObserver.removeObserver({
|
|
533
|
+
target: this.contentContainer,
|
|
534
|
+
handler: this,
|
|
535
|
+
});
|
|
536
|
+
}
|
|
537
|
+
setupResizeObserver() {
|
|
538
|
+
if (!this.resizeObserver)
|
|
539
|
+
return;
|
|
540
|
+
this.resizeObserver.addObserver({
|
|
541
|
+
target: this.contentContainer,
|
|
542
|
+
handler: this,
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* When the visible cells change from the infinite scroller, we want to emit
|
|
547
|
+
* which page is currently visible so the consumer can update its UI or the URL
|
|
548
|
+
*
|
|
549
|
+
* @param e
|
|
550
|
+
* @returns
|
|
551
|
+
*/
|
|
552
|
+
visibleCellsChanged(e) {
|
|
553
|
+
if (this.isScrollingToCell)
|
|
554
|
+
return;
|
|
555
|
+
const { visibleCellIndices } = e.detail;
|
|
556
|
+
if (visibleCellIndices.length === 0)
|
|
557
|
+
return;
|
|
558
|
+
const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
|
|
559
|
+
const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
|
|
560
|
+
if (this.currentPage !== lastVisibleCellPage) {
|
|
561
|
+
this.currentPage = lastVisibleCellPage;
|
|
562
|
+
}
|
|
563
|
+
const event = new CustomEvent('visiblePageChanged', {
|
|
564
|
+
detail: {
|
|
565
|
+
pageNumber: lastVisibleCellPage,
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
this.dispatchEvent(event);
|
|
569
|
+
}
|
|
570
|
+
async handleQueryChange() {
|
|
571
|
+
var _a;
|
|
572
|
+
// only reset if the query has actually changed
|
|
573
|
+
if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
|
|
574
|
+
return;
|
|
575
|
+
this.previousQueryKey = this.pageFetchQueryKey;
|
|
576
|
+
this.dataSource = {};
|
|
577
|
+
this.totalResults = undefined;
|
|
578
|
+
this.aggregations = undefined;
|
|
579
|
+
this.fullYearsHistogramAggregation = undefined;
|
|
580
|
+
this.pageFetchesInProgress = {};
|
|
581
|
+
this.endOfDataReached = false;
|
|
582
|
+
this.pagesToRender = this.initialPageNumber;
|
|
583
|
+
// Reset the infinite scroller's item count, so that it
|
|
584
|
+
// shows tile placeholders until the new query's results load in
|
|
585
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
586
|
+
if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
|
|
587
|
+
this.scrollToPage(this.initialPageNumber);
|
|
588
|
+
}
|
|
589
|
+
this.initialQueryChangeHappened = true;
|
|
590
|
+
// if the query changed as part of a window.history pop event, we don't want to
|
|
591
|
+
// persist the state because it overwrites the forward history
|
|
592
|
+
if (!this.historyPopOccurred) {
|
|
593
|
+
this.persistState();
|
|
594
|
+
this.historyPopOccurred = false;
|
|
595
|
+
}
|
|
596
|
+
await Promise.all([this.doInitialPageFetch(), this.fetchFacets()]);
|
|
597
|
+
}
|
|
598
|
+
setupStateRestorationObserver() {
|
|
599
|
+
if (this.boundNavigationHandler)
|
|
600
|
+
return;
|
|
601
|
+
this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
|
|
602
|
+
// when the user navigates back, we want to update the UI to match the URL
|
|
603
|
+
window.addEventListener('popstate', this.boundNavigationHandler);
|
|
604
|
+
}
|
|
605
|
+
historyNavigationHandler() {
|
|
606
|
+
this.historyPopOccurred = true;
|
|
607
|
+
this.restoreState();
|
|
608
|
+
}
|
|
609
|
+
restoreState() {
|
|
610
|
+
var _a, _b, _c, _d, _e, _f;
|
|
611
|
+
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
612
|
+
this.displayMode = restorationState.displayMode;
|
|
613
|
+
if (restorationState.searchType != null)
|
|
614
|
+
this.searchType = restorationState.searchType;
|
|
615
|
+
this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
|
|
616
|
+
this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
|
|
617
|
+
this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
|
|
618
|
+
this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
|
|
619
|
+
this.selectedFacets = restorationState.selectedFacets;
|
|
620
|
+
this.baseQuery = restorationState.baseQuery;
|
|
621
|
+
this.titleQuery = restorationState.titleQuery;
|
|
622
|
+
this.creatorQuery = restorationState.creatorQuery;
|
|
623
|
+
this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
|
|
624
|
+
this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
|
|
625
|
+
this.minSelectedDate = restorationState.minSelectedDate;
|
|
626
|
+
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
627
|
+
if (this.currentPage > 1) {
|
|
628
|
+
this.goToPage(this.currentPage);
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
persistState() {
|
|
632
|
+
var _a, _b, _c, _d, _e;
|
|
633
|
+
const restorationState = {
|
|
634
|
+
displayMode: this.displayMode,
|
|
635
|
+
searchType: this.searchType,
|
|
636
|
+
sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
|
|
637
|
+
selectedSort: this.selectedSort,
|
|
638
|
+
sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
|
|
639
|
+
selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
|
|
640
|
+
baseQuery: this.baseQuery,
|
|
641
|
+
currentPage: this.currentPage,
|
|
642
|
+
titleQuery: this.titleQuery,
|
|
643
|
+
creatorQuery: this.creatorQuery,
|
|
644
|
+
minSelectedDate: this.minSelectedDate,
|
|
645
|
+
maxSelectedDate: this.maxSelectedDate,
|
|
646
|
+
selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
|
|
647
|
+
selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
|
|
648
|
+
};
|
|
649
|
+
this.restorationStateHandler.persistState(restorationState);
|
|
650
|
+
}
|
|
651
|
+
async doInitialPageFetch() {
|
|
652
|
+
this.searchResultsLoading = true;
|
|
653
|
+
await this.fetchPage(this.initialPageNumber);
|
|
654
|
+
this.searchResultsLoading = false;
|
|
655
|
+
}
|
|
656
|
+
get filterMap() {
|
|
657
|
+
const builder = new FilterMapBuilder();
|
|
658
|
+
// Add the date range, if applicable
|
|
659
|
+
if (this.minSelectedDate) {
|
|
660
|
+
builder.addFilter('year', this.minSelectedDate, FilterConstraint.GREATER_OR_EQUAL);
|
|
661
|
+
}
|
|
662
|
+
if (this.maxSelectedDate) {
|
|
663
|
+
builder.addFilter('year', this.maxSelectedDate, FilterConstraint.LESS_OR_EQUAL);
|
|
664
|
+
}
|
|
665
|
+
// Add any selected facets
|
|
666
|
+
if (this.selectedFacets) {
|
|
667
|
+
for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
|
|
668
|
+
const { name, values } = this.prepareFacetForFetch(facetName, facetValues);
|
|
669
|
+
for (const [value, bucket] of Object.entries(values)) {
|
|
670
|
+
let constraint;
|
|
671
|
+
if (bucket.state === 'selected') {
|
|
672
|
+
constraint = FilterConstraint.INCLUDE;
|
|
673
|
+
}
|
|
674
|
+
else if (bucket.state === 'hidden') {
|
|
675
|
+
constraint = FilterConstraint.EXCLUDE;
|
|
676
|
+
}
|
|
677
|
+
if (constraint) {
|
|
678
|
+
builder.addFilter(name, value, constraint);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
const filterMap = builder.build();
|
|
684
|
+
return filterMap;
|
|
685
|
+
}
|
|
686
|
+
/** The base query joined with any title/creator letter filters */
|
|
687
|
+
get filteredQuery() {
|
|
688
|
+
if (!this.baseQuery)
|
|
689
|
+
return undefined;
|
|
690
|
+
let filteredQuery = this.baseQuery;
|
|
691
|
+
const { sortFilterQueries } = this;
|
|
692
|
+
if (sortFilterQueries) {
|
|
693
|
+
filteredQuery += ` AND ${sortFilterQueries}`;
|
|
694
|
+
}
|
|
695
|
+
return filteredQuery;
|
|
696
|
+
}
|
|
697
|
+
/** The full query, including year facets and date range clauses */
|
|
698
|
+
get fullQuery() {
|
|
699
|
+
if (!this.baseQuery)
|
|
700
|
+
return undefined;
|
|
701
|
+
let fullQuery = this.baseQuery;
|
|
702
|
+
const { facetQuery, dateRangeQueryClause, sortFilterQueries } = this;
|
|
703
|
+
if (facetQuery) {
|
|
704
|
+
fullQuery += ` AND ${facetQuery}`;
|
|
705
|
+
}
|
|
706
|
+
if (dateRangeQueryClause) {
|
|
707
|
+
fullQuery += ` AND ${dateRangeQueryClause}`;
|
|
708
|
+
}
|
|
709
|
+
if (sortFilterQueries) {
|
|
710
|
+
fullQuery += ` AND ${sortFilterQueries}`;
|
|
711
|
+
}
|
|
712
|
+
return fullQuery;
|
|
713
|
+
}
|
|
714
|
+
/** The full query without any title/creator letter filters */
|
|
715
|
+
get fullQueryWithoutAlphaFilters() {
|
|
716
|
+
if (!this.baseQuery)
|
|
717
|
+
return undefined;
|
|
718
|
+
let fullQuery = this.baseQuery;
|
|
719
|
+
const { facetQuery, dateRangeQueryClause } = this;
|
|
720
|
+
if (facetQuery) {
|
|
721
|
+
fullQuery += ` AND ${facetQuery}`;
|
|
722
|
+
}
|
|
723
|
+
if (dateRangeQueryClause) {
|
|
724
|
+
fullQuery += ` AND ${dateRangeQueryClause}`;
|
|
725
|
+
}
|
|
726
|
+
return fullQuery;
|
|
727
|
+
}
|
|
728
|
+
/**
|
|
729
|
+
* Generates a query string for the given facets
|
|
730
|
+
*
|
|
731
|
+
* Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
|
|
732
|
+
*/
|
|
733
|
+
get facetQuery() {
|
|
734
|
+
if (!this.selectedFacets)
|
|
735
|
+
return undefined;
|
|
736
|
+
const facetClauses = [];
|
|
737
|
+
for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
|
|
738
|
+
facetClauses.push(this.buildFacetClause(facetName, facetValues));
|
|
739
|
+
}
|
|
740
|
+
return this.joinFacetClauses(facetClauses);
|
|
741
|
+
}
|
|
742
|
+
/**
|
|
743
|
+
* Builds an OR-joined facet clause for the given facet name and values.
|
|
744
|
+
*
|
|
745
|
+
* E.g., for name `subject` and values
|
|
746
|
+
* `{ foo: { state: 'selected' }, bar: { state: 'hidden' } }`
|
|
747
|
+
* this will produce the clause
|
|
748
|
+
* `subject:("foo" OR -"bar")`.
|
|
749
|
+
*
|
|
750
|
+
* @param facetName The facet type (e.g., 'collection')
|
|
751
|
+
* @param facetValues The facet buckets, mapped by their keys
|
|
752
|
+
*/
|
|
753
|
+
buildFacetClause(facetName, facetValues) {
|
|
754
|
+
const { name: facetQueryName, values } = this.prepareFacetForFetch(facetName, facetValues);
|
|
755
|
+
const facetEntries = Object.entries(values);
|
|
756
|
+
if (facetEntries.length === 0)
|
|
757
|
+
return '';
|
|
758
|
+
const facetValuesArray = [];
|
|
759
|
+
for (const [key, facetData] of facetEntries) {
|
|
760
|
+
const plusMinusPrefix = facetData.state === 'hidden' ? '-' : '';
|
|
761
|
+
facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
|
|
762
|
+
}
|
|
763
|
+
const valueQuery = facetValuesArray.join(` OR `);
|
|
764
|
+
return `${facetQueryName}:(${valueQuery})`;
|
|
765
|
+
}
|
|
766
|
+
/**
|
|
767
|
+
* Handles some special pre-request normalization steps for certain facet types
|
|
768
|
+
* that require them.
|
|
769
|
+
*
|
|
770
|
+
* @param facetName The name of the facet type (e.g., 'language')
|
|
771
|
+
* @param facetValues An array of values for that facet type
|
|
772
|
+
*/
|
|
773
|
+
prepareFacetForFetch(facetName, facetValues) {
|
|
774
|
+
// eslint-disable-next-line prefer-const
|
|
775
|
+
let [normalizedName, normalizedValues] = [facetName, facetValues];
|
|
776
|
+
// The full "search engine" name of the lending field is "lending___status"
|
|
777
|
+
if (facetName === 'lending') {
|
|
778
|
+
normalizedName = 'lending___status';
|
|
779
|
+
}
|
|
780
|
+
return {
|
|
781
|
+
name: normalizedName,
|
|
782
|
+
values: normalizedValues,
|
|
783
|
+
};
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Takes an array of facet clauses, and combines them into a
|
|
787
|
+
* full AND-joined facet query string. Empty clauses are ignored.
|
|
788
|
+
*/
|
|
789
|
+
joinFacetClauses(facetClauses) {
|
|
790
|
+
const nonEmptyFacetClauses = facetClauses.filter(clause => clause.length > 0);
|
|
791
|
+
return nonEmptyFacetClauses.length > 0
|
|
792
|
+
? `(${nonEmptyFacetClauses.join(' AND ')})`
|
|
793
|
+
: undefined;
|
|
794
|
+
}
|
|
795
|
+
facetsChanged(e) {
|
|
796
|
+
this.selectedFacets = e.detail;
|
|
797
|
+
}
|
|
798
|
+
facetClickHandler(name, facetSelected, negative) {
|
|
799
|
+
var _a, _b;
|
|
800
|
+
if (negative) {
|
|
801
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
802
|
+
category: this.searchContext,
|
|
803
|
+
action: facetSelected
|
|
804
|
+
? analyticsActions.facetNegativeSelected
|
|
805
|
+
: analyticsActions.facetNegativeDeselected,
|
|
806
|
+
label: name,
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
(_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
|
|
811
|
+
category: this.searchContext,
|
|
812
|
+
action: facetSelected
|
|
813
|
+
? analyticsActions.facetSelected
|
|
814
|
+
: analyticsActions.facetDeselected,
|
|
815
|
+
label: name,
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
async fetchFacets() {
|
|
820
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
821
|
+
if (!this.filteredQuery)
|
|
822
|
+
return;
|
|
823
|
+
const params = {
|
|
824
|
+
query: this.filteredQuery,
|
|
825
|
+
rows: 0,
|
|
826
|
+
filters: this.filterMap,
|
|
827
|
+
// Fetch a few extra buckets beyond the 6 we show, in case some get suppressed
|
|
828
|
+
aggregationsSize: 10,
|
|
829
|
+
// Note: we don't need an aggregations param to fetch the default aggregations from the PPS.
|
|
830
|
+
// The default aggregations for the search_results page type should be what we need here.
|
|
831
|
+
};
|
|
832
|
+
this.facetsLoading = true;
|
|
833
|
+
this.previousSearchType = this.searchType;
|
|
834
|
+
const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
|
|
835
|
+
this.facetsLoading = false;
|
|
836
|
+
this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
|
|
837
|
+
this.fullYearsHistogramAggregation =
|
|
838
|
+
(_f = (_e = (_d = (_c = results === null || results === void 0 ? void 0 : results.success) === null || _c === void 0 ? void 0 : _c.response) === null || _d === void 0 ? void 0 : _d.aggregations) === null || _e === void 0 ? void 0 : _e.year_histogram) !== null && _f !== void 0 ? _f : (_j = (_h = (_g = results === null || results === void 0 ? void 0 : results.success) === null || _g === void 0 ? void 0 : _g.response) === null || _h === void 0 ? void 0 : _h.aggregations) === null || _j === void 0 ? void 0 : _j['year-histogram']; // Temp fix until PPS FTS key is fixed to use underscore
|
|
839
|
+
}
|
|
840
|
+
scrollToPage(pageNumber) {
|
|
841
|
+
return new Promise(resolve => {
|
|
842
|
+
const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
|
|
843
|
+
// without this setTimeout, Safari just pauses until the `fetchPage` is complete
|
|
844
|
+
// then scrolls to the cell
|
|
845
|
+
setTimeout(() => {
|
|
846
|
+
var _a;
|
|
847
|
+
this.isScrollingToCell = true;
|
|
848
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
|
|
849
|
+
// This timeout is to give the scroll animation time to finish
|
|
850
|
+
// then updating the infinite scroller once we're done scrolling
|
|
851
|
+
// There's no scroll animation completion callback so we're
|
|
852
|
+
// giving it 0.5s to finish.
|
|
853
|
+
setTimeout(() => {
|
|
854
|
+
var _a;
|
|
855
|
+
this.isScrollingToCell = false;
|
|
856
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
857
|
+
resolve();
|
|
858
|
+
}, 500);
|
|
859
|
+
}, 0);
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
/**
|
|
863
|
+
* The query key is a string that uniquely identifies the current search.
|
|
864
|
+
* It consists of:
|
|
865
|
+
* - The current base query
|
|
866
|
+
* - The current search type
|
|
867
|
+
* - Any currently-applied facets
|
|
868
|
+
* - Any currently-applied date range
|
|
869
|
+
* - Any currently-applied prefix filters
|
|
870
|
+
* - The current sort options
|
|
871
|
+
*
|
|
872
|
+
* This lets us keep track of queries so we don't persist data that's
|
|
873
|
+
* no longer relevant.
|
|
874
|
+
*/
|
|
875
|
+
get pageFetchQueryKey() {
|
|
876
|
+
var _a, _b;
|
|
877
|
+
return `${this.fullQuery}-${this.searchType}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
|
|
878
|
+
}
|
|
879
|
+
async fetchPage(pageNumber) {
|
|
880
|
+
var _a, _b, _c, _d, _e;
|
|
881
|
+
if (!this.filteredQuery)
|
|
882
|
+
return;
|
|
883
|
+
// if we already have data, don't fetch again
|
|
884
|
+
if (this.dataSource[pageNumber])
|
|
885
|
+
return;
|
|
886
|
+
if (this.endOfDataReached)
|
|
887
|
+
return;
|
|
888
|
+
// if a fetch is already in progress for this query and page, don't fetch again
|
|
889
|
+
const { pageFetchQueryKey } = this;
|
|
890
|
+
const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
|
|
891
|
+
if (pageFetches.has(pageNumber))
|
|
892
|
+
return;
|
|
893
|
+
pageFetches.add(pageNumber);
|
|
894
|
+
this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
|
|
895
|
+
const sortParams = this.sortParam ? [this.sortParam] : [];
|
|
896
|
+
const params = {
|
|
897
|
+
query: this.filteredQuery,
|
|
898
|
+
page: pageNumber,
|
|
899
|
+
rows: this.pageSize,
|
|
900
|
+
sort: sortParams,
|
|
901
|
+
filters: this.filterMap,
|
|
902
|
+
aggregations: { omit: true },
|
|
903
|
+
};
|
|
904
|
+
const searchResponse = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params, this.searchType));
|
|
905
|
+
const success = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success;
|
|
906
|
+
if (!success)
|
|
907
|
+
return;
|
|
908
|
+
this.totalResults = success.response.totalResults;
|
|
909
|
+
// this is checking to see if the query has changed since the data was fetched
|
|
910
|
+
// if so, we just want to discard the data since there should be a new query
|
|
911
|
+
// right behind it
|
|
912
|
+
const searchQuery = success.request.clientParameters.user_query;
|
|
913
|
+
const searchSort = success.request.clientParameters.sort;
|
|
914
|
+
let sortChanged = false;
|
|
915
|
+
if (!searchSort || searchSort.length === 0) {
|
|
916
|
+
// if we went from no sort to sort, the sort has changed
|
|
917
|
+
if (this.sortParam) {
|
|
918
|
+
sortChanged = true;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
else {
|
|
922
|
+
// check if the sort has changed
|
|
923
|
+
for (const sortType of searchSort) {
|
|
924
|
+
const [field, direction] = sortType.split(':');
|
|
925
|
+
if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
|
|
926
|
+
direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
|
|
927
|
+
sortChanged = true;
|
|
928
|
+
break;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
}
|
|
932
|
+
const queryChangedSinceFetch = searchQuery !== this.filteredQuery || sortChanged;
|
|
933
|
+
if (queryChangedSinceFetch)
|
|
934
|
+
return;
|
|
935
|
+
const { results } = success.response;
|
|
936
|
+
if (results && results.length > 0) {
|
|
937
|
+
this.preloadCollectionNames(results);
|
|
938
|
+
this.updateDataSource(pageNumber, results);
|
|
939
|
+
}
|
|
940
|
+
// When we reach the end of the data, we can set the infinite scroller's
|
|
941
|
+
// item count to the real total number of results (rather than the
|
|
942
|
+
// temporary estimates based on pages rendered so far).
|
|
943
|
+
if (results.length < this.pageSize) {
|
|
944
|
+
this.endOfDataReached = true;
|
|
945
|
+
if (this.infiniteScroller) {
|
|
946
|
+
this.infiniteScroller.itemCount = this.totalResults;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
(_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
|
|
950
|
+
this.searchResultsLoading = false;
|
|
951
|
+
}
|
|
952
|
+
preloadCollectionNames(results) {
|
|
953
|
+
var _a;
|
|
954
|
+
const collectionIds = results
|
|
955
|
+
.map(result => { var _a; return (_a = result.collection) === null || _a === void 0 ? void 0 : _a.values; })
|
|
956
|
+
.flat();
|
|
957
|
+
const collectionIdsArray = Array.from(new Set(collectionIds));
|
|
958
|
+
(_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* This is useful for determining whether we need to reload the scroller.
|
|
962
|
+
*
|
|
963
|
+
* When the fetch completes, we need to reload the scroller if the cells for that
|
|
964
|
+
* page are visible, but if the page is not currenlty visible, we don't need to reload
|
|
965
|
+
*/
|
|
966
|
+
get currentVisiblePageNumbers() {
|
|
967
|
+
var _a, _b;
|
|
968
|
+
const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
|
|
969
|
+
const visiblePages = new Set();
|
|
970
|
+
visibleCells.forEach(cellIndex => {
|
|
971
|
+
const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
|
|
972
|
+
visiblePages.add(visiblePage);
|
|
973
|
+
});
|
|
974
|
+
return Array.from(visiblePages);
|
|
975
|
+
}
|
|
976
|
+
/**
|
|
977
|
+
* Update the datasource from the fetch response
|
|
978
|
+
*
|
|
979
|
+
* @param pageNumber
|
|
980
|
+
* @param results
|
|
981
|
+
*/
|
|
982
|
+
updateDataSource(pageNumber, results) {
|
|
983
|
+
var _a;
|
|
984
|
+
// copy our existing datasource so when we set it below, it gets set
|
|
985
|
+
// instead of modifying the existing dataSource since object changes
|
|
986
|
+
// don't trigger a re-render
|
|
987
|
+
const datasource = { ...this.dataSource };
|
|
988
|
+
const tiles = [];
|
|
989
|
+
results === null || results === void 0 ? void 0 : results.forEach(result => {
|
|
990
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15;
|
|
991
|
+
if (!result.identifier)
|
|
992
|
+
return;
|
|
993
|
+
let loginRequired = false;
|
|
994
|
+
let contentWarning = false;
|
|
995
|
+
// Check if item and item in "modifying" collection, setting above flags
|
|
996
|
+
if (((_a = result.collection) === null || _a === void 0 ? void 0 : _a.values.length) &&
|
|
997
|
+
((_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
|
|
998
|
+
for (const collection of (_d = (_c = result.collection) === null || _c === void 0 ? void 0 : _c.values) !== null && _d !== void 0 ? _d : []) {
|
|
999
|
+
if (collection === 'loggedin') {
|
|
1000
|
+
loginRequired = true;
|
|
1001
|
+
if (contentWarning)
|
|
1002
|
+
break;
|
|
1003
|
+
}
|
|
1004
|
+
if (collection === 'no-preview') {
|
|
1005
|
+
contentWarning = true;
|
|
1006
|
+
if (loginRequired)
|
|
1007
|
+
break;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
tiles.push({
|
|
1012
|
+
averageRating: (_e = result.avg_rating) === null || _e === void 0 ? void 0 : _e.value,
|
|
1013
|
+
collections: (_g = (_f = result.collection) === null || _f === void 0 ? void 0 : _f.values) !== null && _g !== void 0 ? _g : [],
|
|
1014
|
+
collectionFilesCount: (_j = (_h = result.collection_files_count) === null || _h === void 0 ? void 0 : _h.value) !== null && _j !== void 0 ? _j : 0,
|
|
1015
|
+
collectionSize: (_l = (_k = result.collection_size) === null || _k === void 0 ? void 0 : _k.value) !== null && _l !== void 0 ? _l : 0,
|
|
1016
|
+
commentCount: (_o = (_m = result.num_reviews) === null || _m === void 0 ? void 0 : _m.value) !== null && _o !== void 0 ? _o : 0,
|
|
1017
|
+
creator: (_p = result.creator) === null || _p === void 0 ? void 0 : _p.value,
|
|
1018
|
+
creators: (_r = (_q = result.creator) === null || _q === void 0 ? void 0 : _q.values) !== null && _r !== void 0 ? _r : [],
|
|
1019
|
+
dateAdded: (_s = result.addeddate) === null || _s === void 0 ? void 0 : _s.value,
|
|
1020
|
+
dateArchived: (_t = result.publicdate) === null || _t === void 0 ? void 0 : _t.value,
|
|
1021
|
+
datePublished: (_u = result.date) === null || _u === void 0 ? void 0 : _u.value,
|
|
1022
|
+
dateReviewed: (_v = result.reviewdate) === null || _v === void 0 ? void 0 : _v.value,
|
|
1023
|
+
description: (_w = result.description) === null || _w === void 0 ? void 0 : _w.values.join('\n'),
|
|
1024
|
+
favCount: (_y = (_x = result.num_favorites) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 0,
|
|
1025
|
+
href: (_z = result.__href__) === null || _z === void 0 ? void 0 : _z.value,
|
|
1026
|
+
identifier: result.identifier,
|
|
1027
|
+
issue: (_0 = result.issue) === null || _0 === void 0 ? void 0 : _0.value,
|
|
1028
|
+
itemCount: (_2 = (_1 = result.item_count) === null || _1 === void 0 ? void 0 : _1.value) !== null && _2 !== void 0 ? _2 : 0,
|
|
1029
|
+
mediatype: (_4 = (_3 = result.mediatype) === null || _3 === void 0 ? void 0 : _3.value) !== null && _4 !== void 0 ? _4 : 'data',
|
|
1030
|
+
snippets: (_6 = (_5 = result.highlight) === null || _5 === void 0 ? void 0 : _5.values) !== null && _6 !== void 0 ? _6 : [],
|
|
1031
|
+
source: (_7 = result.source) === null || _7 === void 0 ? void 0 : _7.value,
|
|
1032
|
+
subjects: (_9 = (_8 = result.subject) === null || _8 === void 0 ? void 0 : _8.values) !== null && _9 !== void 0 ? _9 : [],
|
|
1033
|
+
title: (_11 = (_10 = result.title) === null || _10 === void 0 ? void 0 : _10.value) !== null && _11 !== void 0 ? _11 : '',
|
|
1034
|
+
volume: (_12 = result.volume) === null || _12 === void 0 ? void 0 : _12.value,
|
|
1035
|
+
viewCount: (_14 = (_13 = result.downloads) === null || _13 === void 0 ? void 0 : _13.value) !== null && _14 !== void 0 ? _14 : 0,
|
|
1036
|
+
weeklyViewCount: (_15 = result.week) === null || _15 === void 0 ? void 0 : _15.value,
|
|
1037
|
+
loginRequired,
|
|
1038
|
+
contentWarning,
|
|
1039
|
+
});
|
|
1040
|
+
});
|
|
1041
|
+
datasource[pageNumber] = tiles;
|
|
1042
|
+
this.dataSource = datasource;
|
|
1043
|
+
const visiblePages = this.currentVisiblePageNumbers;
|
|
1044
|
+
const needsReload = visiblePages.includes(pageNumber);
|
|
1045
|
+
if (needsReload) {
|
|
1046
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
1047
|
+
}
|
|
1048
|
+
}
|
|
1049
|
+
/** Fetches the aggregation buckets for the given prefix filter type. */
|
|
1050
|
+
async fetchPrefixFilterBuckets(filterType) {
|
|
1051
|
+
var _a, _b, _c, _d, _e, _f;
|
|
1052
|
+
if (!this.fullQueryWithoutAlphaFilters)
|
|
1053
|
+
return [];
|
|
1054
|
+
const filterAggregationKey = prefixFilterAggregationKeys[filterType];
|
|
1055
|
+
const params = {
|
|
1056
|
+
query: this.fullQueryWithoutAlphaFilters,
|
|
1057
|
+
rows: 0,
|
|
1058
|
+
// Only fetch the firstTitle or firstCreator aggregation
|
|
1059
|
+
aggregations: { simpleParams: [filterAggregationKey] },
|
|
1060
|
+
// Fetch all 26 letter buckets
|
|
1061
|
+
aggregationsSize: 26,
|
|
1062
|
+
};
|
|
1063
|
+
const searchResponse = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params, this.searchType));
|
|
1064
|
+
return ((_f = (_e = (_d = (_c = (_b = searchResponse === null || searchResponse === void 0 ? void 0 : searchResponse.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d[filterAggregationKey]) === null || _e === void 0 ? void 0 : _e.buckets) !== null && _f !== void 0 ? _f : []);
|
|
1065
|
+
}
|
|
1066
|
+
/** Fetches and caches the prefix filter counts for the given filter type. */
|
|
1067
|
+
async updatePrefixFilterCounts(filterType) {
|
|
1068
|
+
const buckets = await this.fetchPrefixFilterBuckets(filterType);
|
|
1069
|
+
// Unpack the aggregation buckets into a simple map like { 'A': 50, 'B': 25, ... }
|
|
1070
|
+
this.prefixFilterCountMap = { ...this.prefixFilterCountMap }; // Clone the object to trigger an update
|
|
1071
|
+
this.prefixFilterCountMap[filterType] = buckets.reduce((acc, bucket) => {
|
|
1072
|
+
acc[bucket.key.toUpperCase()] = bucket.doc_count;
|
|
1073
|
+
return acc;
|
|
1074
|
+
}, {});
|
|
1075
|
+
}
|
|
1076
|
+
/**
|
|
1077
|
+
* Fetches and caches the prefix filter counts for the current sort type,
|
|
1078
|
+
* provided it is one that permits prefix filtering. (If not, this does nothing).
|
|
1079
|
+
*/
|
|
1080
|
+
async updatePrefixFiltersForCurrentSort() {
|
|
1081
|
+
if (['title', 'creator'].includes(this.selectedSort)) {
|
|
1082
|
+
const filterType = this.selectedSort;
|
|
1083
|
+
if (!this.prefixFilterCountMap[filterType]) {
|
|
1084
|
+
this.updatePrefixFilterCounts(filterType);
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
/**
|
|
1089
|
+
* Clears the cached letter counts for both title and creator, and
|
|
1090
|
+
* fetches a new set of counts for whichever of them is the currently
|
|
1091
|
+
* selected sort option (which may be neither).
|
|
1092
|
+
*
|
|
1093
|
+
* Call this whenever the counts are invalidated (e.g., by a query change).
|
|
1094
|
+
*/
|
|
1095
|
+
refreshLetterCounts() {
|
|
1096
|
+
this.prefixFilterCountMap = {};
|
|
1097
|
+
this.updatePrefixFiltersForCurrentSort();
|
|
1098
|
+
}
|
|
1099
|
+
/**
|
|
1100
|
+
* Callback when a result is selected
|
|
1101
|
+
*/
|
|
1102
|
+
resultSelected(event) {
|
|
1103
|
+
var _a, _b;
|
|
1104
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
1105
|
+
category: this.searchContext,
|
|
1106
|
+
action: analyticsActions.resultSelected,
|
|
1107
|
+
label: event.detail.mediatype,
|
|
1108
|
+
});
|
|
1109
|
+
(_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
|
|
1110
|
+
category: this.searchContext,
|
|
1111
|
+
action: analyticsActions.resultSelected,
|
|
1112
|
+
label: `page-${this.currentPage}`,
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
cellForIndex(index) {
|
|
1116
|
+
const model = this.tileModelAtCellIndex(index);
|
|
1117
|
+
if (!model)
|
|
1118
|
+
return undefined;
|
|
1119
1119
|
return html `
|
|
1120
1120
|
<tile-dispatcher
|
|
1121
1121
|
.baseNavigationUrl=${this.baseNavigationUrl}
|
|
@@ -1131,19 +1131,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1131
1131
|
@resultSelected=${(e) => this.resultSelected(e)}
|
|
1132
1132
|
>
|
|
1133
1133
|
</tile-dispatcher>
|
|
1134
|
-
`;
|
|
1135
|
-
}
|
|
1136
|
-
/**
|
|
1137
|
-
* When the user scrolls near to the bottom of the page, fetch the next page
|
|
1138
|
-
* increase the number of pages to render and start fetching data for the new page
|
|
1139
|
-
*/
|
|
1140
|
-
scrollThresholdReached() {
|
|
1141
|
-
if (!this.endOfDataReached) {
|
|
1142
|
-
this.pagesToRender += 1;
|
|
1143
|
-
this.fetchPage(this.pagesToRender);
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
};
|
|
1134
|
+
`;
|
|
1135
|
+
}
|
|
1136
|
+
/**
|
|
1137
|
+
* When the user scrolls near to the bottom of the page, fetch the next page
|
|
1138
|
+
* increase the number of pages to render and start fetching data for the new page
|
|
1139
|
+
*/
|
|
1140
|
+
scrollThresholdReached() {
|
|
1141
|
+
if (!this.endOfDataReached) {
|
|
1142
|
+
this.pagesToRender += 1;
|
|
1143
|
+
this.fetchPage(this.pagesToRender);
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
1147
|
CollectionBrowser.styles = css `
|
|
1148
1148
|
:host {
|
|
1149
1149
|
display: block;
|
|
@@ -1367,144 +1367,144 @@ CollectionBrowser.styles = css `
|
|
|
1367
1367
|
infinite-scroller.hidden {
|
|
1368
1368
|
display: none;
|
|
1369
1369
|
}
|
|
1370
|
-
`;
|
|
1371
|
-
__decorate([
|
|
1372
|
-
property({ type: String })
|
|
1373
|
-
], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
|
|
1374
|
-
__decorate([
|
|
1375
|
-
property({ type: String })
|
|
1376
|
-
], CollectionBrowser.prototype, "baseImageUrl", void 0);
|
|
1377
|
-
__decorate([
|
|
1378
|
-
property({ type: Object })
|
|
1379
|
-
], CollectionBrowser.prototype, "searchService", void 0);
|
|
1380
|
-
__decorate([
|
|
1381
|
-
property({ type: String })
|
|
1382
|
-
], CollectionBrowser.prototype, "searchType", void 0);
|
|
1383
|
-
__decorate([
|
|
1384
|
-
property({ type: String })
|
|
1385
|
-
], CollectionBrowser.prototype, "baseQuery", void 0);
|
|
1386
|
-
__decorate([
|
|
1387
|
-
property({ type: String })
|
|
1388
|
-
], CollectionBrowser.prototype, "displayMode", void 0);
|
|
1389
|
-
__decorate([
|
|
1390
|
-
property({ type: Object })
|
|
1391
|
-
], CollectionBrowser.prototype, "sortParam", void 0);
|
|
1392
|
-
__decorate([
|
|
1393
|
-
property({ type: String })
|
|
1394
|
-
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
1395
|
-
__decorate([
|
|
1396
|
-
property({ type: String })
|
|
1397
|
-
], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
|
|
1398
|
-
__decorate([
|
|
1399
|
-
property({ type: String })
|
|
1400
|
-
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1401
|
-
__decorate([
|
|
1402
|
-
property({ type: String })
|
|
1403
|
-
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1404
|
-
__decorate([
|
|
1405
|
-
property({ type: Number })
|
|
1406
|
-
], CollectionBrowser.prototype, "pageSize", void 0);
|
|
1407
|
-
__decorate([
|
|
1408
|
-
property({ type: Object })
|
|
1409
|
-
], CollectionBrowser.prototype, "resizeObserver", void 0);
|
|
1410
|
-
__decorate([
|
|
1411
|
-
property({ type: String })
|
|
1412
|
-
], CollectionBrowser.prototype, "titleQuery", void 0);
|
|
1413
|
-
__decorate([
|
|
1414
|
-
property({ type: String })
|
|
1415
|
-
], CollectionBrowser.prototype, "creatorQuery", void 0);
|
|
1416
|
-
__decorate([
|
|
1417
|
-
property({ type: Number })
|
|
1418
|
-
], CollectionBrowser.prototype, "currentPage", void 0);
|
|
1419
|
-
__decorate([
|
|
1420
|
-
property({ type: String })
|
|
1421
|
-
], CollectionBrowser.prototype, "minSelectedDate", void 0);
|
|
1422
|
-
__decorate([
|
|
1423
|
-
property({ type: String })
|
|
1424
|
-
], CollectionBrowser.prototype, "maxSelectedDate", void 0);
|
|
1425
|
-
__decorate([
|
|
1426
|
-
property({ type: Object })
|
|
1427
|
-
], CollectionBrowser.prototype, "selectedFacets", void 0);
|
|
1428
|
-
__decorate([
|
|
1429
|
-
property({ type: Boolean })
|
|
1430
|
-
], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
|
|
1431
|
-
__decorate([
|
|
1432
|
-
property({ type: String, reflect: true })
|
|
1433
|
-
], CollectionBrowser.prototype, "searchContext", void 0);
|
|
1434
|
-
__decorate([
|
|
1435
|
-
property({ type: Object })
|
|
1436
|
-
], CollectionBrowser.prototype, "collectionNameCache", void 0);
|
|
1437
|
-
__decorate([
|
|
1438
|
-
property({ type: String })
|
|
1439
|
-
], CollectionBrowser.prototype, "pageContext", void 0);
|
|
1440
|
-
__decorate([
|
|
1441
|
-
property({ type: Object })
|
|
1442
|
-
], CollectionBrowser.prototype, "restorationStateHandler", void 0);
|
|
1443
|
-
__decorate([
|
|
1444
|
-
property({ type: Number })
|
|
1445
|
-
], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
|
|
1446
|
-
__decorate([
|
|
1447
|
-
property({ type: Boolean })
|
|
1448
|
-
], CollectionBrowser.prototype, "loggedIn", void 0);
|
|
1449
|
-
__decorate([
|
|
1450
|
-
property({ type: Object })
|
|
1451
|
-
], CollectionBrowser.prototype, "modalManager", void 0);
|
|
1452
|
-
__decorate([
|
|
1453
|
-
property({ type: Object })
|
|
1454
|
-
], CollectionBrowser.prototype, "featureFeedbackService", void 0);
|
|
1455
|
-
__decorate([
|
|
1456
|
-
property({ type: Object })
|
|
1457
|
-
], CollectionBrowser.prototype, "recaptchaManager", void 0);
|
|
1458
|
-
__decorate([
|
|
1459
|
-
property({ type: Boolean })
|
|
1460
|
-
], CollectionBrowser.prototype, "isManageView", void 0);
|
|
1461
|
-
__decorate([
|
|
1462
|
-
state()
|
|
1463
|
-
], CollectionBrowser.prototype, "pagesToRender", void 0);
|
|
1464
|
-
__decorate([
|
|
1465
|
-
state()
|
|
1466
|
-
], CollectionBrowser.prototype, "searchResultsLoading", void 0);
|
|
1467
|
-
__decorate([
|
|
1468
|
-
state()
|
|
1469
|
-
], CollectionBrowser.prototype, "facetsLoading", void 0);
|
|
1470
|
-
__decorate([
|
|
1471
|
-
state()
|
|
1472
|
-
], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
|
|
1473
|
-
__decorate([
|
|
1474
|
-
state()
|
|
1475
|
-
], CollectionBrowser.prototype, "aggregations", void 0);
|
|
1476
|
-
__decorate([
|
|
1477
|
-
state()
|
|
1478
|
-
], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
|
|
1479
|
-
__decorate([
|
|
1480
|
-
state()
|
|
1481
|
-
], CollectionBrowser.prototype, "previousSearchType", void 0);
|
|
1482
|
-
__decorate([
|
|
1483
|
-
state()
|
|
1484
|
-
], CollectionBrowser.prototype, "totalResults", void 0);
|
|
1485
|
-
__decorate([
|
|
1486
|
-
state()
|
|
1487
|
-
], CollectionBrowser.prototype, "mobileView", void 0);
|
|
1488
|
-
__decorate([
|
|
1489
|
-
state()
|
|
1490
|
-
], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
|
|
1491
|
-
__decorate([
|
|
1492
|
-
state()
|
|
1493
|
-
], CollectionBrowser.prototype, "placeholderType", void 0);
|
|
1494
|
-
__decorate([
|
|
1495
|
-
state()
|
|
1496
|
-
], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
|
|
1497
|
-
__decorate([
|
|
1498
|
-
query('#content-container')
|
|
1499
|
-
], CollectionBrowser.prototype, "contentContainer", void 0);
|
|
1500
|
-
__decorate([
|
|
1501
|
-
property({ type: Object, attribute: false })
|
|
1502
|
-
], CollectionBrowser.prototype, "analyticsHandler", void 0);
|
|
1503
|
-
__decorate([
|
|
1504
|
-
query('infinite-scroller')
|
|
1505
|
-
], CollectionBrowser.prototype, "infiniteScroller", void 0);
|
|
1506
|
-
CollectionBrowser = __decorate([
|
|
1507
|
-
customElement('collection-browser')
|
|
1508
|
-
], CollectionBrowser);
|
|
1509
|
-
export { CollectionBrowser };
|
|
1370
|
+
`;
|
|
1371
|
+
__decorate([
|
|
1372
|
+
property({ type: String })
|
|
1373
|
+
], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
|
|
1374
|
+
__decorate([
|
|
1375
|
+
property({ type: String })
|
|
1376
|
+
], CollectionBrowser.prototype, "baseImageUrl", void 0);
|
|
1377
|
+
__decorate([
|
|
1378
|
+
property({ type: Object })
|
|
1379
|
+
], CollectionBrowser.prototype, "searchService", void 0);
|
|
1380
|
+
__decorate([
|
|
1381
|
+
property({ type: String })
|
|
1382
|
+
], CollectionBrowser.prototype, "searchType", void 0);
|
|
1383
|
+
__decorate([
|
|
1384
|
+
property({ type: String })
|
|
1385
|
+
], CollectionBrowser.prototype, "baseQuery", void 0);
|
|
1386
|
+
__decorate([
|
|
1387
|
+
property({ type: String })
|
|
1388
|
+
], CollectionBrowser.prototype, "displayMode", void 0);
|
|
1389
|
+
__decorate([
|
|
1390
|
+
property({ type: Object })
|
|
1391
|
+
], CollectionBrowser.prototype, "sortParam", void 0);
|
|
1392
|
+
__decorate([
|
|
1393
|
+
property({ type: String })
|
|
1394
|
+
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
1395
|
+
__decorate([
|
|
1396
|
+
property({ type: String })
|
|
1397
|
+
], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
|
|
1398
|
+
__decorate([
|
|
1399
|
+
property({ type: String })
|
|
1400
|
+
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1401
|
+
__decorate([
|
|
1402
|
+
property({ type: String })
|
|
1403
|
+
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1404
|
+
__decorate([
|
|
1405
|
+
property({ type: Number })
|
|
1406
|
+
], CollectionBrowser.prototype, "pageSize", void 0);
|
|
1407
|
+
__decorate([
|
|
1408
|
+
property({ type: Object })
|
|
1409
|
+
], CollectionBrowser.prototype, "resizeObserver", void 0);
|
|
1410
|
+
__decorate([
|
|
1411
|
+
property({ type: String })
|
|
1412
|
+
], CollectionBrowser.prototype, "titleQuery", void 0);
|
|
1413
|
+
__decorate([
|
|
1414
|
+
property({ type: String })
|
|
1415
|
+
], CollectionBrowser.prototype, "creatorQuery", void 0);
|
|
1416
|
+
__decorate([
|
|
1417
|
+
property({ type: Number })
|
|
1418
|
+
], CollectionBrowser.prototype, "currentPage", void 0);
|
|
1419
|
+
__decorate([
|
|
1420
|
+
property({ type: String })
|
|
1421
|
+
], CollectionBrowser.prototype, "minSelectedDate", void 0);
|
|
1422
|
+
__decorate([
|
|
1423
|
+
property({ type: String })
|
|
1424
|
+
], CollectionBrowser.prototype, "maxSelectedDate", void 0);
|
|
1425
|
+
__decorate([
|
|
1426
|
+
property({ type: Object })
|
|
1427
|
+
], CollectionBrowser.prototype, "selectedFacets", void 0);
|
|
1428
|
+
__decorate([
|
|
1429
|
+
property({ type: Boolean })
|
|
1430
|
+
], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
|
|
1431
|
+
__decorate([
|
|
1432
|
+
property({ type: String, reflect: true })
|
|
1433
|
+
], CollectionBrowser.prototype, "searchContext", void 0);
|
|
1434
|
+
__decorate([
|
|
1435
|
+
property({ type: Object })
|
|
1436
|
+
], CollectionBrowser.prototype, "collectionNameCache", void 0);
|
|
1437
|
+
__decorate([
|
|
1438
|
+
property({ type: String })
|
|
1439
|
+
], CollectionBrowser.prototype, "pageContext", void 0);
|
|
1440
|
+
__decorate([
|
|
1441
|
+
property({ type: Object })
|
|
1442
|
+
], CollectionBrowser.prototype, "restorationStateHandler", void 0);
|
|
1443
|
+
__decorate([
|
|
1444
|
+
property({ type: Number })
|
|
1445
|
+
], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
|
|
1446
|
+
__decorate([
|
|
1447
|
+
property({ type: Boolean })
|
|
1448
|
+
], CollectionBrowser.prototype, "loggedIn", void 0);
|
|
1449
|
+
__decorate([
|
|
1450
|
+
property({ type: Object })
|
|
1451
|
+
], CollectionBrowser.prototype, "modalManager", void 0);
|
|
1452
|
+
__decorate([
|
|
1453
|
+
property({ type: Object })
|
|
1454
|
+
], CollectionBrowser.prototype, "featureFeedbackService", void 0);
|
|
1455
|
+
__decorate([
|
|
1456
|
+
property({ type: Object })
|
|
1457
|
+
], CollectionBrowser.prototype, "recaptchaManager", void 0);
|
|
1458
|
+
__decorate([
|
|
1459
|
+
property({ type: Boolean })
|
|
1460
|
+
], CollectionBrowser.prototype, "isManageView", void 0);
|
|
1461
|
+
__decorate([
|
|
1462
|
+
state()
|
|
1463
|
+
], CollectionBrowser.prototype, "pagesToRender", void 0);
|
|
1464
|
+
__decorate([
|
|
1465
|
+
state()
|
|
1466
|
+
], CollectionBrowser.prototype, "searchResultsLoading", void 0);
|
|
1467
|
+
__decorate([
|
|
1468
|
+
state()
|
|
1469
|
+
], CollectionBrowser.prototype, "facetsLoading", void 0);
|
|
1470
|
+
__decorate([
|
|
1471
|
+
state()
|
|
1472
|
+
], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
|
|
1473
|
+
__decorate([
|
|
1474
|
+
state()
|
|
1475
|
+
], CollectionBrowser.prototype, "aggregations", void 0);
|
|
1476
|
+
__decorate([
|
|
1477
|
+
state()
|
|
1478
|
+
], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
|
|
1479
|
+
__decorate([
|
|
1480
|
+
state()
|
|
1481
|
+
], CollectionBrowser.prototype, "previousSearchType", void 0);
|
|
1482
|
+
__decorate([
|
|
1483
|
+
state()
|
|
1484
|
+
], CollectionBrowser.prototype, "totalResults", void 0);
|
|
1485
|
+
__decorate([
|
|
1486
|
+
state()
|
|
1487
|
+
], CollectionBrowser.prototype, "mobileView", void 0);
|
|
1488
|
+
__decorate([
|
|
1489
|
+
state()
|
|
1490
|
+
], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
|
|
1491
|
+
__decorate([
|
|
1492
|
+
state()
|
|
1493
|
+
], CollectionBrowser.prototype, "placeholderType", void 0);
|
|
1494
|
+
__decorate([
|
|
1495
|
+
state()
|
|
1496
|
+
], CollectionBrowser.prototype, "prefixFilterCountMap", void 0);
|
|
1497
|
+
__decorate([
|
|
1498
|
+
query('#content-container')
|
|
1499
|
+
], CollectionBrowser.prototype, "contentContainer", void 0);
|
|
1500
|
+
__decorate([
|
|
1501
|
+
property({ type: Object, attribute: false })
|
|
1502
|
+
], CollectionBrowser.prototype, "analyticsHandler", void 0);
|
|
1503
|
+
__decorate([
|
|
1504
|
+
query('infinite-scroller')
|
|
1505
|
+
], CollectionBrowser.prototype, "infiniteScroller", void 0);
|
|
1506
|
+
CollectionBrowser = __decorate([
|
|
1507
|
+
customElement('collection-browser')
|
|
1508
|
+
], CollectionBrowser);
|
|
1509
|
+
export { CollectionBrowser };
|
|
1510
1510
|
//# sourceMappingURL=collection-browser.js.map
|