@internetarchive/collection-browser 2.1.9 → 2.1.11-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -29
- package/.husky/pre-commit +4 -4
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +12 -12
- package/dist/index.js +12 -12
- package/dist/src/app-root.d.ts +91 -88
- package/dist/src/app-root.js +501 -475
- package/dist/src/app-root.js.map +1 -1
- 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/contract.d.ts +2 -2
- package/dist/src/assets/img/icons/contract.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/expand.d.ts +2 -2
- package/dist/src/assets/img/icons/expand.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/favorite-unfilled.d.ts +1 -1
- package/dist/src/assets/img/icons/favorite-unfilled.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/search.d.ts +1 -1
- package/dist/src/assets/img/icons/mediatype/search.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 +453 -446
- package/dist/src/collection-browser.js +1422 -1408
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row.d.ts +30 -30
- package/dist/src/collection-facets/facet-row.js +114 -114
- 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 +17 -17
- package/dist/src/collection-facets/facets-template.js +114 -114
- package/dist/src/collection-facets/more-facets-content.d.ts +74 -74
- package/dist/src/collection-facets/more-facets-content.js +360 -360
- package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
- package/dist/src/collection-facets/more-facets-pagination.js +196 -196
- package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
- package/dist/src/collection-facets/toggle-switch.js +94 -94
- package/dist/src/collection-facets.d.ts +103 -103
- package/dist/src/collection-facets.js +510 -510
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +241 -236
- package/dist/src/data-source/collection-browser-data-source-interface.js +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +378 -364
- package/dist/src/data-source/collection-browser-data-source.js +987 -946
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +44 -43
- package/dist/src/data-source/collection-browser-query-state.js +1 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/data-source/models.d.ts +28 -28
- package/dist/src/data-source/models.js +8 -8
- package/dist/src/empty-placeholder.d.ts +23 -23
- package/dist/src/empty-placeholder.js +74 -74
- package/dist/src/expanded-date-picker.d.ts +43 -43
- package/dist/src/expanded-date-picker.js +109 -109
- 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/manage/manage-bar.d.ts +30 -30
- package/dist/src/manage/manage-bar.js +61 -61
- package/dist/src/mediatype/mediatype-config.d.ts +3 -3
- package/dist/src/mediatype/mediatype-config.js +91 -91
- package/dist/src/models.d.ts +198 -198
- package/dist/src/models.js +381 -381
- package/dist/src/restoration-state-handler.d.ts +70 -70
- package/dist/src/restoration-state-handler.js +357 -357
- 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 +21 -21
- package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
- 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-toggle-disabled.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
- package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
- package/dist/src/sort-filter-bar/img/sort-toggle-up.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 +222 -221
- package/dist/src/sort-filter-bar/sort-filter-bar.js +696 -691
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/styles/ia-button.d.ts +2 -2
- package/dist/src/styles/ia-button.js +16 -16
- package/dist/src/styles/item-image-styles.d.ts +8 -8
- package/dist/src/styles/item-image-styles.js +9 -9
- package/dist/src/styles/sr-only.d.ts +1 -1
- package/dist/src/styles/sr-only.js +2 -2
- package/dist/src/tiles/base-tile-component.d.ts +19 -19
- package/dist/src/tiles/base-tile-component.js +63 -63
- 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 +18 -18
- package/dist/src/tiles/grid/account-tile.js +72 -72
- package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
- package/dist/src/tiles/grid/collection-tile.js +80 -80
- package/dist/src/tiles/grid/item-tile.d.ts +30 -30
- package/dist/src/tiles/grid/item-tile.js +149 -149
- package/dist/src/tiles/grid/search-tile.d.ts +10 -10
- package/dist/src/tiles/grid/search-tile.js +51 -51
- 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 +8 -8
- package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
- package/dist/src/tiles/grid/tile-stats.js +53 -53
- 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 +73 -73
- package/dist/src/tiles/item-image.d.ts +39 -39
- package/dist/src/tiles/item-image.js +154 -154
- package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
- package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
- package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
- package/dist/src/tiles/list/tile-list-compact.js +114 -114
- package/dist/src/tiles/list/tile-list.d.ts +50 -50
- package/dist/src/tiles/list/tile-list.js +315 -315
- 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/review-block.d.ts +12 -12
- package/dist/src/tiles/review-block.js +56 -56
- 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 +64 -64
- package/dist/src/tiles/tile-dispatcher.js +229 -229
- package/dist/src/tiles/tile-display-value-provider.d.ts +47 -47
- package/dist/src/tiles/tile-display-value-provider.js +94 -94
- package/dist/src/utils/analytics-events.d.ts +26 -26
- package/dist/src/utils/analytics-events.js +28 -28
- package/dist/src/utils/array-equals.d.ts +4 -4
- package/dist/src/utils/array-equals.js +10 -10
- package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -11
- package/dist/src/utils/collapse-repeated-quotes.js +13 -13
- 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 +25 -25
- package/dist/src/utils/format-unit-size.d.ts +2 -2
- package/dist/src/utils/format-unit-size.js +33 -33
- package/dist/src/utils/local-date-from-utc.d.ts +9 -9
- package/dist/src/utils/local-date-from-utc.js +15 -15
- package/dist/src/utils/log.d.ts +7 -7
- package/dist/src/utils/log.js +15 -15
- package/dist/src/utils/resolve-mediatype.d.ts +8 -8
- package/dist/src/utils/resolve-mediatype.js +23 -23
- package/dist/src/utils/sha1.d.ts +2 -2
- package/dist/src/utils/sha1.js +8 -8
- package/dist/test/collection-browser.test.d.ts +1 -1
- package/dist/test/collection-browser.test.js +1283 -1283
- package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
- package/dist/test/collection-facets/facet-row.test.js +203 -203
- package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
- package/dist/test/collection-facets/facets-template.test.js +105 -105
- package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +139 -139
- 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/toggle-switch.test.d.ts +1 -1
- package/dist/test/collection-facets/toggle-switch.test.js +73 -73
- package/dist/test/collection-facets.test.d.ts +2 -2
- package/dist/test/collection-facets.test.js +652 -652
- package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -1
- package/dist/test/data-source/collection-browser-data-source.test.js +89 -89
- package/dist/test/empty-placeholder.test.d.ts +1 -1
- package/dist/test/empty-placeholder.test.js +63 -63
- package/dist/test/expanded-date-picker.test.d.ts +1 -1
- package/dist/test/expanded-date-picker.test.js +95 -95
- 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 +85 -85
- package/dist/test/manage/manage-bar.test.d.ts +1 -1
- package/dist/test/manage/manage-bar.test.js +81 -81
- 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-search-responses.d.ts +24 -24
- package/dist/test/mocks/mock-search-responses.js +860 -860
- package/dist/test/mocks/mock-search-service.d.ts +15 -15
- package/dist/test/mocks/mock-search-service.js +53 -53
- package/dist/test/restoration-state-handler.test.d.ts +1 -1
- package/dist/test/restoration-state-handler.test.js +270 -270
- package/dist/test/review-block.test.d.ts +1 -1
- package/dist/test/review-block.test.js +44 -44
- 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 +426 -426
- 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 +81 -81
- 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 +312 -312
- package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
- package/dist/test/tiles/grid/search-tile.test.js +51 -51
- package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -259
- 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 +143 -143
- package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
- package/dist/test/tiles/list/tile-list.test.js +297 -297
- package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
- package/dist/test/tiles/tile-dispatcher.test.js +100 -100
- package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
- package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
- package/dist/test/utils/array-equals.test.d.ts +1 -1
- package/dist/test/utils/array-equals.test.js +26 -26
- 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/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
- package/dist/test/utils/local-date-from-utc.test.js +26 -26
- 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/app-root.ts +24 -1
- package/src/collection-browser.ts +16 -1
- package/src/data-source/collection-browser-data-source-interface.ts +7 -1
- package/src/data-source/collection-browser-data-source.ts +56 -6
- package/src/data-source/collection-browser-query-state.ts +1 -0
- package/src/sort-filter-bar/sort-filter-bar.ts +5 -0
- package/tsconfig.json +21 -21
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -41
|
@@ -1,351 +1,358 @@
|
|
|
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 { msg } from '@lit/localize';
|
|
7
|
-
import { SearchType, } from '@internetarchive/search-service';
|
|
8
|
-
import '@internetarchive/infinite-scroller';
|
|
9
|
-
import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
|
|
10
|
-
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
11
|
-
import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
|
|
12
|
-
import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
|
|
13
|
-
import chevronIcon from './assets/img/icons/chevron';
|
|
14
|
-
import { srOnlyStyle } from './styles/sr-only';
|
|
15
|
-
import { sha1 } from './utils/sha1';
|
|
16
|
-
import { formatDate } from './utils/format-date';
|
|
17
|
-
import { log } from './utils/log';
|
|
18
|
-
import './empty-placeholder';
|
|
19
|
-
import './tiles/tile-dispatcher';
|
|
20
|
-
import './tiles/collection-browser-loading-tile';
|
|
21
|
-
import './sort-filter-bar/sort-filter-bar';
|
|
22
|
-
import './manage/manage-bar';
|
|
23
|
-
import './collection-facets';
|
|
24
|
-
import './circular-activity-indicator';
|
|
25
|
-
let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
26
|
-
constructor() {
|
|
27
|
-
super();
|
|
28
|
-
this.baseImageUrl = 'https://archive.org';
|
|
29
|
-
/**
|
|
30
|
-
* Which backend should be targeted by searches (e.g., metadata or FTS)
|
|
31
|
-
*/
|
|
32
|
-
this.searchType = SearchType.METADATA;
|
|
33
|
-
this.defaultSortParam = null;
|
|
34
|
-
this.selectedSort = SortField.default;
|
|
35
|
-
this.selectedTitleFilter = null;
|
|
36
|
-
this.selectedCreatorFilter = null;
|
|
37
|
-
this.sortDirection = null;
|
|
38
|
-
this.pageSize = 50;
|
|
39
|
-
/**
|
|
40
|
-
* Whether to show the date picker (above the facets)
|
|
41
|
-
*/
|
|
42
|
-
this.showHistogramDatePicker = false;
|
|
43
|
-
/**
|
|
44
|
-
* Whether placeholder views should be suppressed. If true, searches that produce an
|
|
45
|
-
* error or empty result set will simply show a blank results view instead of a placeholder.
|
|
46
|
-
*/
|
|
47
|
-
this.suppressPlaceholders = false;
|
|
48
|
-
/**
|
|
49
|
-
* Whether the result count text should be suppressed.
|
|
50
|
-
* If true, no "X Results" message will be shown.
|
|
51
|
-
*/
|
|
52
|
-
this.suppressResultCount = false;
|
|
53
|
-
/**
|
|
54
|
-
* Whether the scrolling result view should be suppressed entirely.
|
|
55
|
-
* If true, no infinite scroller (and thus no result tiles) will be rendered.
|
|
56
|
-
*/
|
|
57
|
-
this.suppressResultTiles = false;
|
|
58
|
-
/**
|
|
59
|
-
* Whether to suppress persistence of the query to the URL.
|
|
60
|
-
* If true, the `query` param will not be added to the URL or updated on query changes.
|
|
61
|
-
*/
|
|
62
|
-
this.suppressURLQuery = false;
|
|
63
|
-
/**
|
|
64
|
-
* Whether to suppress the display of facets.
|
|
65
|
-
* If true, the facet sidebar content will be replaced by a message that facets are
|
|
66
|
-
* temporarily unavailable.
|
|
67
|
-
*/
|
|
68
|
-
this.suppressFacets = false;
|
|
69
|
-
/**
|
|
70
|
-
* Whether to suppress display of the sort bar.
|
|
71
|
-
* If true, the entire sort bar (incl. display modes) will be omitted from rendering.
|
|
72
|
-
*/
|
|
73
|
-
this.suppressSortBar = false;
|
|
74
|
-
/**
|
|
75
|
-
* Whether to suppress showing the display mode options in the sort bar.
|
|
76
|
-
* If true, those options will be omitted (though the rest of the sort bar may still render).
|
|
77
|
-
*/
|
|
78
|
-
this.suppressDisplayModes = false;
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
this
|
|
89
|
-
this.
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
this.
|
|
95
|
-
|
|
96
|
-
this.
|
|
97
|
-
/**
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
*
|
|
114
|
-
*/
|
|
115
|
-
this.
|
|
116
|
-
/**
|
|
117
|
-
*
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
this.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
this.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
*
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
this.
|
|
143
|
-
/**
|
|
144
|
-
*
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
this.
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
*
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
*
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (
|
|
274
|
-
this.
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
this.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
this.
|
|
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 { msg } from '@lit/localize';
|
|
7
|
+
import { SearchType, } from '@internetarchive/search-service';
|
|
8
|
+
import '@internetarchive/infinite-scroller';
|
|
9
|
+
import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
|
|
10
|
+
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
11
|
+
import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
|
|
12
|
+
import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
|
|
13
|
+
import chevronIcon from './assets/img/icons/chevron';
|
|
14
|
+
import { srOnlyStyle } from './styles/sr-only';
|
|
15
|
+
import { sha1 } from './utils/sha1';
|
|
16
|
+
import { formatDate } from './utils/format-date';
|
|
17
|
+
import { log } from './utils/log';
|
|
18
|
+
import './empty-placeholder';
|
|
19
|
+
import './tiles/tile-dispatcher';
|
|
20
|
+
import './tiles/collection-browser-loading-tile';
|
|
21
|
+
import './sort-filter-bar/sort-filter-bar';
|
|
22
|
+
import './manage/manage-bar';
|
|
23
|
+
import './collection-facets';
|
|
24
|
+
import './circular-activity-indicator';
|
|
25
|
+
let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
26
|
+
constructor() {
|
|
27
|
+
super();
|
|
28
|
+
this.baseImageUrl = 'https://archive.org';
|
|
29
|
+
/**
|
|
30
|
+
* Which backend should be targeted by searches (e.g., metadata or FTS)
|
|
31
|
+
*/
|
|
32
|
+
this.searchType = SearchType.METADATA;
|
|
33
|
+
this.defaultSortParam = null;
|
|
34
|
+
this.selectedSort = SortField.default;
|
|
35
|
+
this.selectedTitleFilter = null;
|
|
36
|
+
this.selectedCreatorFilter = null;
|
|
37
|
+
this.sortDirection = null;
|
|
38
|
+
this.pageSize = 50;
|
|
39
|
+
/**
|
|
40
|
+
* Whether to show the date picker (above the facets)
|
|
41
|
+
*/
|
|
42
|
+
this.showHistogramDatePicker = false;
|
|
43
|
+
/**
|
|
44
|
+
* Whether placeholder views should be suppressed. If true, searches that produce an
|
|
45
|
+
* error or empty result set will simply show a blank results view instead of a placeholder.
|
|
46
|
+
*/
|
|
47
|
+
this.suppressPlaceholders = false;
|
|
48
|
+
/**
|
|
49
|
+
* Whether the result count text should be suppressed.
|
|
50
|
+
* If true, no "X Results" message will be shown.
|
|
51
|
+
*/
|
|
52
|
+
this.suppressResultCount = false;
|
|
53
|
+
/**
|
|
54
|
+
* Whether the scrolling result view should be suppressed entirely.
|
|
55
|
+
* If true, no infinite scroller (and thus no result tiles) will be rendered.
|
|
56
|
+
*/
|
|
57
|
+
this.suppressResultTiles = false;
|
|
58
|
+
/**
|
|
59
|
+
* Whether to suppress persistence of the query to the URL.
|
|
60
|
+
* If true, the `query` param will not be added to the URL or updated on query changes.
|
|
61
|
+
*/
|
|
62
|
+
this.suppressURLQuery = false;
|
|
63
|
+
/**
|
|
64
|
+
* Whether to suppress the display of facets entirely.
|
|
65
|
+
* If true, the facet sidebar content will be replaced by a message that facets are
|
|
66
|
+
* temporarily unavailable.
|
|
67
|
+
*/
|
|
68
|
+
this.suppressFacets = false;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to suppress display of the sort bar.
|
|
71
|
+
* If true, the entire sort bar (incl. display modes) will be omitted from rendering.
|
|
72
|
+
*/
|
|
73
|
+
this.suppressSortBar = false;
|
|
74
|
+
/**
|
|
75
|
+
* Whether to suppress showing the display mode options in the sort bar.
|
|
76
|
+
* If true, those options will be omitted (though the rest of the sort bar may still render).
|
|
77
|
+
*/
|
|
78
|
+
this.suppressDisplayModes = false;
|
|
79
|
+
/**
|
|
80
|
+
* Whether facets should be lazy-loaded.
|
|
81
|
+
* If false (default), facet data will be loaded eagerly along with search hits.
|
|
82
|
+
* If true, facet data will only be requested once the facet pane actually becomes visible,
|
|
83
|
+
* either by displaying in desktop mode or by the mobile facet dropdown being opened.
|
|
84
|
+
*/
|
|
85
|
+
this.lazyLoadFacets = false;
|
|
86
|
+
this.clearResultsOnEmptyQuery = false;
|
|
87
|
+
this.collectionPagePath = '/details/';
|
|
88
|
+
/** describes where this component is being used */
|
|
89
|
+
this.searchContext = analyticsCategories.default;
|
|
90
|
+
this.pageContext = 'search';
|
|
91
|
+
this.restorationStateHandler = new RestorationStateHandler({
|
|
92
|
+
context: this.pageContext,
|
|
93
|
+
});
|
|
94
|
+
this.mobileBreakpoint = 600;
|
|
95
|
+
this.loggedIn = false;
|
|
96
|
+
this.modalManager = undefined;
|
|
97
|
+
/**
|
|
98
|
+
* If item management UI active
|
|
99
|
+
*/
|
|
100
|
+
this.isManageView = false;
|
|
101
|
+
this.manageViewLabel = 'Select items to remove';
|
|
102
|
+
/** Whether to replace the default sort options with a slot for customization (default: false) */
|
|
103
|
+
this.enableSortOptionsSlot = false;
|
|
104
|
+
/**
|
|
105
|
+
* The results per page so we can paginate.
|
|
106
|
+
*
|
|
107
|
+
* This allows us to start in the middle of the search results and
|
|
108
|
+
* fetch data before or after the current page. If we don't have a key
|
|
109
|
+
* for the previous/next page, we'll fetch the next/previous page to populate it
|
|
110
|
+
*/
|
|
111
|
+
this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
|
|
112
|
+
/**
|
|
113
|
+
* The page that the consumer wants to load.
|
|
114
|
+
*/
|
|
115
|
+
this.initialPageNumber = 1;
|
|
116
|
+
/**
|
|
117
|
+
* This the the number of pages that we want to show.
|
|
118
|
+
*
|
|
119
|
+
* The data isn't necessarily loaded for all of the pages, but this lets us
|
|
120
|
+
* know how many cells we should render.
|
|
121
|
+
*/
|
|
122
|
+
this.pagesToRender = this.initialPageNumber;
|
|
123
|
+
/**
|
|
124
|
+
* Whether the initial page fetch for a new query is currently in progress.
|
|
125
|
+
*/
|
|
126
|
+
this.searchResultsLoading = false;
|
|
127
|
+
this.facetsLoading = false;
|
|
128
|
+
this.mobileView = false;
|
|
129
|
+
this.mobileFacetsVisible = false;
|
|
130
|
+
this.defaultSortField = SortField.relevance;
|
|
131
|
+
this.defaultSortDirection = null;
|
|
132
|
+
this.placeholderType = null;
|
|
133
|
+
/**
|
|
134
|
+
* When we're animated scrolling to the page, we don't want to fetch
|
|
135
|
+
* all of the pages as it scrolls so this lets us know if we're scrolling
|
|
136
|
+
*/
|
|
137
|
+
this.isScrollingToCell = false;
|
|
138
|
+
/**
|
|
139
|
+
* When page width resizes from desktop to mobile, set true to
|
|
140
|
+
* disable expand/collapse transition when loading.
|
|
141
|
+
*/
|
|
142
|
+
this.isResizeToMobile = false;
|
|
143
|
+
/**
|
|
144
|
+
* Flag indicating that a new data source is currently being installed.
|
|
145
|
+
* During the install, any URL persistence operation should replace the current entry
|
|
146
|
+
* instead of creating a new one.
|
|
147
|
+
*/
|
|
148
|
+
this.dataSourceInstallInProgress = false;
|
|
149
|
+
this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
|
|
150
|
+
/**
|
|
151
|
+
* How many tiles to offset the data source by, to account for any removed tiles.
|
|
152
|
+
*/
|
|
153
|
+
this.tileModelOffset = 0;
|
|
154
|
+
/**
|
|
155
|
+
* Updates the height of the left column according to its position on the page.
|
|
156
|
+
* Arrow function ensures proper `this` binding.
|
|
157
|
+
*/
|
|
158
|
+
this.updateLeftColumnHeight = () => {
|
|
159
|
+
var _a, _b, _c, _d, _e;
|
|
160
|
+
if (this.mobileView) {
|
|
161
|
+
(_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
|
|
165
|
+
(_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', `${window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0) - 3}px`);
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Toggles whether the fade-out is visible at the bottom of the facets.
|
|
170
|
+
* It should only be visible if the facets are not scrolled to the bottom.
|
|
171
|
+
* Arrow function ensures proper `this` binding.
|
|
172
|
+
*/
|
|
173
|
+
this.updateFacetFadeOut = (entries) => {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
|
|
176
|
+
fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
|
|
177
|
+
};
|
|
178
|
+
// we only want to scroll on the very first query change
|
|
179
|
+
// so this keeps track of whether we've already set the initial query
|
|
180
|
+
this.initialQueryChangeHappened = false;
|
|
181
|
+
this.historyPopOccurred = false;
|
|
182
|
+
this.addController(this.dataSource);
|
|
183
|
+
}
|
|
184
|
+
tileModelAtCellIndex(index) {
|
|
185
|
+
const model = this.dataSource.getTileModelAt(index);
|
|
186
|
+
/**
|
|
187
|
+
* If we encounter a model we don't have yet and we're not in the middle of an
|
|
188
|
+
* automated scroll, fetch the page and just return undefined.
|
|
189
|
+
* The datasource will be updated once the page is loaded and the cell will be rendered.
|
|
190
|
+
*
|
|
191
|
+
* We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
|
|
192
|
+
* user may never see.
|
|
193
|
+
*/
|
|
194
|
+
if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
|
|
195
|
+
const pageNumber = Math.floor(index / this.pageSize) + 1;
|
|
196
|
+
this.dataSource.fetchPage(pageNumber);
|
|
197
|
+
}
|
|
198
|
+
return model;
|
|
199
|
+
}
|
|
200
|
+
// this is the total number of tiles we expect if
|
|
201
|
+
// the data returned is a full page worth
|
|
202
|
+
// this is useful for putting in placeholders for the expected number of tiles
|
|
203
|
+
get estimatedTileCount() {
|
|
204
|
+
return this.pagesToRender * this.pageSize;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Returns a promise resolving to a unique string that persists for the current browser session.
|
|
208
|
+
* Used in generating unique IDs for search requests, so that multiple requests coming from the
|
|
209
|
+
* same browser session can be identified.
|
|
210
|
+
*/
|
|
211
|
+
async getSessionId() {
|
|
212
|
+
try {
|
|
213
|
+
const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
|
|
214
|
+
if (storedSessionId) {
|
|
215
|
+
return storedSessionId;
|
|
216
|
+
}
|
|
217
|
+
// If we enter this method a second time while a first session ID is already being generated,
|
|
218
|
+
// ensure we produce the same ID from both calls instead of generating another one.
|
|
219
|
+
if (this.sessionIdGenPromise) {
|
|
220
|
+
return this.sessionIdGenPromise;
|
|
221
|
+
}
|
|
222
|
+
this.sessionIdGenPromise = sha1(Math.random().toString());
|
|
223
|
+
const newSessionId = await this.sessionIdGenPromise;
|
|
224
|
+
sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
|
|
225
|
+
return newSessionId;
|
|
226
|
+
}
|
|
227
|
+
catch (err) {
|
|
228
|
+
// Either we can't generate the hash or we're restricted from accessing sessionStorage
|
|
229
|
+
return '';
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Go to the given page of results
|
|
234
|
+
*
|
|
235
|
+
* @param pageNumber
|
|
236
|
+
*/
|
|
237
|
+
goToPage(pageNumber) {
|
|
238
|
+
this.initialPageNumber = pageNumber;
|
|
239
|
+
this.pagesToRender = pageNumber;
|
|
240
|
+
return this.scrollToPage(pageNumber);
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Sets the state for whether the initial set of search results is loading in.
|
|
244
|
+
*/
|
|
245
|
+
setSearchResultsLoading(loading) {
|
|
246
|
+
this.searchResultsLoading = loading;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Sets the state for whether facet data is loading in
|
|
250
|
+
*/
|
|
251
|
+
setFacetsLoading(loading) {
|
|
252
|
+
this.facetsLoading = loading;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Sets the total number of results to be displayed for the current search
|
|
256
|
+
*/
|
|
257
|
+
setTotalResultCount(totalResults) {
|
|
258
|
+
this.totalResults = totalResults;
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Clears all selected/negated facets, date ranges, and letter filters.
|
|
262
|
+
*
|
|
263
|
+
* By default, the current sort field/direction are not cleared,
|
|
264
|
+
* but this can be overridden by setting the `sort` option to `true`.
|
|
265
|
+
*
|
|
266
|
+
* Similarly, it is possible to finely control what is cleared by
|
|
267
|
+
* setting any of the `facets`, `dateRange`, or `letterFilters` flags
|
|
268
|
+
* in the options object.
|
|
269
|
+
*/
|
|
270
|
+
clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
|
|
271
|
+
// Don't bother clearing facets if none are checked, so that we don't
|
|
272
|
+
// trigger unnecessary update cycles.
|
|
273
|
+
if (facets && this.hasCheckedFacets) {
|
|
274
|
+
this.selectedFacets = getDefaultSelectedFacets();
|
|
275
|
+
}
|
|
276
|
+
if (dateRange) {
|
|
277
|
+
this.minSelectedDate = undefined;
|
|
278
|
+
this.maxSelectedDate = undefined;
|
|
279
|
+
}
|
|
280
|
+
if (letterFilters) {
|
|
281
|
+
this.selectedTitleFilter = null;
|
|
282
|
+
this.selectedCreatorFilter = null;
|
|
283
|
+
}
|
|
284
|
+
if (sort) {
|
|
285
|
+
this.sortDirection = null;
|
|
286
|
+
this.selectedSort = SortField.default;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Returns true if the current value of `this.selectedFacets` contains
|
|
291
|
+
* any facet buckets than have been selected or negated, or false otherwise.
|
|
292
|
+
*/
|
|
293
|
+
get hasCheckedFacets() {
|
|
294
|
+
if (!this.selectedFacets)
|
|
295
|
+
return false;
|
|
296
|
+
for (const facetGroup of Object.values(this.selectedFacets)) {
|
|
297
|
+
for (const bucket of Object.values(facetGroup)) {
|
|
298
|
+
if (bucket.state !== 'none')
|
|
299
|
+
return true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
return false;
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Returns true if there are any currently selected/negated facet buckets,
|
|
306
|
+
* any selected date range, or any selected letter filters. False otherwise.
|
|
307
|
+
*
|
|
308
|
+
* Ignores sorting options.
|
|
309
|
+
*/
|
|
310
|
+
get hasActiveFilters() {
|
|
311
|
+
return !!(this.hasCheckedFacets ||
|
|
312
|
+
this.minSelectedDate ||
|
|
313
|
+
this.maxSelectedDate ||
|
|
314
|
+
this.selectedTitleFilter ||
|
|
315
|
+
this.selectedCreatorFilter);
|
|
316
|
+
}
|
|
317
|
+
render() {
|
|
318
|
+
this.setPlaceholderType();
|
|
312
319
|
return html `
|
|
313
320
|
<div
|
|
314
321
|
id="content-container"
|
|
315
322
|
class=${this.mobileView ? 'mobile' : 'desktop'}
|
|
316
323
|
>
|
|
317
|
-
${this.placeholderType
|
|
318
|
-
? this.emptyPlaceholderTemplate
|
|
324
|
+
${this.placeholderType
|
|
325
|
+
? this.emptyPlaceholderTemplate
|
|
319
326
|
: this.collectionBrowserTemplate}
|
|
320
327
|
</div>
|
|
321
|
-
`;
|
|
322
|
-
}
|
|
323
|
-
setPlaceholderType() {
|
|
324
|
-
var _a;
|
|
325
|
-
const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
|
|
326
|
-
const isCollection = !!this.withinCollection;
|
|
327
|
-
const isProfile = !!this.withinProfile;
|
|
328
|
-
const noResults = !this.searchResultsLoading &&
|
|
329
|
-
(this.dataSource.size === 0 || !this.searchService);
|
|
330
|
-
this.placeholderType = null;
|
|
331
|
-
if (this.suppressPlaceholders)
|
|
332
|
-
return;
|
|
333
|
-
if (!hasQuery && !isCollection && !isProfile) {
|
|
334
|
-
this.placeholderType = 'empty-query';
|
|
335
|
-
}
|
|
336
|
-
else if (noResults) {
|
|
337
|
-
// Within a collection, no query + no results means the collection simply has no viewable items.
|
|
338
|
-
// Otherwise, we must have a user query that produced 0 results.
|
|
339
|
-
this.placeholderType =
|
|
340
|
-
!hasQuery && isCollection ? 'empty-collection' : 'no-results';
|
|
341
|
-
}
|
|
342
|
-
if (this.dataSource.queryErrorMessage) {
|
|
343
|
-
this.placeholderType =
|
|
344
|
-
!hasQuery && isCollection ? 'collection-error' : 'query-error';
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
get emptyPlaceholderTemplate() {
|
|
348
|
-
var _a;
|
|
328
|
+
`;
|
|
329
|
+
}
|
|
330
|
+
setPlaceholderType() {
|
|
331
|
+
var _a;
|
|
332
|
+
const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
|
|
333
|
+
const isCollection = !!this.withinCollection;
|
|
334
|
+
const isProfile = !!this.withinProfile;
|
|
335
|
+
const noResults = !this.searchResultsLoading &&
|
|
336
|
+
(this.dataSource.size === 0 || !this.searchService);
|
|
337
|
+
this.placeholderType = null;
|
|
338
|
+
if (this.suppressPlaceholders)
|
|
339
|
+
return;
|
|
340
|
+
if (!hasQuery && !isCollection && !isProfile) {
|
|
341
|
+
this.placeholderType = 'empty-query';
|
|
342
|
+
}
|
|
343
|
+
else if (noResults) {
|
|
344
|
+
// Within a collection, no query + no results means the collection simply has no viewable items.
|
|
345
|
+
// Otherwise, we must have a user query that produced 0 results.
|
|
346
|
+
this.placeholderType =
|
|
347
|
+
!hasQuery && isCollection ? 'empty-collection' : 'no-results';
|
|
348
|
+
}
|
|
349
|
+
if (this.dataSource.queryErrorMessage) {
|
|
350
|
+
this.placeholderType =
|
|
351
|
+
!hasQuery && isCollection ? 'collection-error' : 'query-error';
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
get emptyPlaceholderTemplate() {
|
|
355
|
+
var _a;
|
|
349
356
|
return html `
|
|
350
357
|
<empty-placeholder
|
|
351
358
|
.placeholderType=${this.placeholderType}
|
|
@@ -354,33 +361,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
354
361
|
.detailMessage=${(_a = this.dataSource.queryErrorMessage) !== null && _a !== void 0 ? _a : ''}
|
|
355
362
|
.baseNavigationUrl=${this.baseNavigationUrl}
|
|
356
363
|
></empty-placeholder>
|
|
357
|
-
`;
|
|
358
|
-
}
|
|
359
|
-
/**
|
|
360
|
-
* Top-level template for rendering the left (facets) and right (results) columns.
|
|
361
|
-
*/
|
|
362
|
-
get collectionBrowserTemplate() {
|
|
364
|
+
`;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Top-level template for rendering the left (facets) and right (results) columns.
|
|
368
|
+
*/
|
|
369
|
+
get collectionBrowserTemplate() {
|
|
363
370
|
return html `
|
|
364
371
|
<div id="left-column-scroll-sentinel"></div>
|
|
365
372
|
${this.leftColumnTemplate} ${this.rightColumnTemplate}
|
|
366
|
-
`;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Template for either the mobile or desktop version of the left column, depending
|
|
370
|
-
* on current component state.
|
|
371
|
-
*/
|
|
372
|
-
get leftColumnTemplate() {
|
|
373
|
-
if (this.mobileView) {
|
|
374
|
-
return this.mobileLeftColumnTemplate;
|
|
375
|
-
}
|
|
376
|
-
return this.desktopLeftColumnTemplate;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Template for the mobile version of the "left column" (which in this case, appears
|
|
380
|
-
* *above* the search results rather than beside them), for rendering the
|
|
381
|
-
* accordion-style facets.
|
|
382
|
-
*/
|
|
383
|
-
get mobileLeftColumnTemplate() {
|
|
373
|
+
`;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Template for either the mobile or desktop version of the left column, depending
|
|
377
|
+
* on current component state.
|
|
378
|
+
*/
|
|
379
|
+
get leftColumnTemplate() {
|
|
380
|
+
if (this.mobileView) {
|
|
381
|
+
return this.mobileLeftColumnTemplate;
|
|
382
|
+
}
|
|
383
|
+
return this.desktopLeftColumnTemplate;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Template for the mobile version of the "left column" (which in this case, appears
|
|
387
|
+
* *above* the search results rather than beside them), for rendering the
|
|
388
|
+
* accordion-style facets.
|
|
389
|
+
*/
|
|
390
|
+
get mobileLeftColumnTemplate() {
|
|
384
391
|
return html `
|
|
385
392
|
<div
|
|
386
393
|
id="left-column"
|
|
@@ -389,12 +396,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
389
396
|
${this.facetTopViewSlot} ${this.resultsCountTemplate}
|
|
390
397
|
<div id="facets-header-container">${this.mobileFacetsTemplate}</div>
|
|
391
398
|
</div>
|
|
392
|
-
`;
|
|
393
|
-
}
|
|
394
|
-
/**
|
|
395
|
-
* Template for the desktop version of the left column, displaying the facets sidebar.
|
|
396
|
-
*/
|
|
397
|
-
get desktopLeftColumnTemplate() {
|
|
399
|
+
`;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Template for the desktop version of the left column, displaying the facets sidebar.
|
|
403
|
+
*/
|
|
404
|
+
get desktopLeftColumnTemplate() {
|
|
398
405
|
return html `
|
|
399
406
|
<div id="left-column" class="column">
|
|
400
407
|
${this.facetTopViewSlot}
|
|
@@ -408,28 +415,28 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
408
415
|
</div>
|
|
409
416
|
<div id="facets-bottom-fade"></div>
|
|
410
417
|
</div>
|
|
411
|
-
`;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Slot which is placed at top of the facets area for user-profile page
|
|
415
|
-
* - mainly used to render userlists
|
|
416
|
-
*/
|
|
417
|
-
get facetTopViewSlot() {
|
|
418
|
+
`;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Slot which is placed at top of the facets area for user-profile page
|
|
422
|
+
* - mainly used to render userlists
|
|
423
|
+
*/
|
|
424
|
+
get facetTopViewSlot() {
|
|
418
425
|
return html `<div id="facet-top-view">
|
|
419
426
|
<slot name="facet-top-slot"></slot>
|
|
420
|
-
</div>`;
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Template for the "X Results" count at the top of the search results.
|
|
424
|
-
* Changes to the "Searching..." label if the search results are still loading.
|
|
425
|
-
*/
|
|
426
|
-
get resultsCountTemplate() {
|
|
427
|
-
var _a;
|
|
428
|
-
if (this.suppressResultCount)
|
|
429
|
-
return nothing;
|
|
430
|
-
const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
|
|
431
|
-
const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
|
|
432
|
-
const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
|
|
427
|
+
</div>`;
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Template for the "X Results" count at the top of the search results.
|
|
431
|
+
* Changes to the "Searching..." label if the search results are still loading.
|
|
432
|
+
*/
|
|
433
|
+
get resultsCountTemplate() {
|
|
434
|
+
var _a;
|
|
435
|
+
if (this.suppressResultCount)
|
|
436
|
+
return nothing;
|
|
437
|
+
const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
|
|
438
|
+
const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
|
|
439
|
+
const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
|
|
433
440
|
return html `
|
|
434
441
|
<div id="results-total">
|
|
435
442
|
<span id="big-results-count">
|
|
@@ -439,30 +446,30 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
439
446
|
${shouldShowSearching ? nothing : resultsLabel}
|
|
440
447
|
</span>
|
|
441
448
|
</div>
|
|
442
|
-
`;
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Template for the right column of the collection browser, where the result
|
|
446
|
-
* tiles and sort/filter bar are shown.
|
|
447
|
-
*/
|
|
448
|
-
get rightColumnTemplate() {
|
|
449
|
+
`;
|
|
450
|
+
}
|
|
451
|
+
/**
|
|
452
|
+
* Template for the right column of the collection browser, where the result
|
|
453
|
+
* tiles and sort/filter bar are shown.
|
|
454
|
+
*/
|
|
455
|
+
get rightColumnTemplate() {
|
|
449
456
|
return html `
|
|
450
457
|
<div id="right-column" class="column">
|
|
451
458
|
<div id="cb-top-view">
|
|
452
459
|
<slot name="cb-top-slot"></slot>
|
|
453
460
|
</div>
|
|
454
|
-
${this.isManageView
|
|
455
|
-
? this.manageBarTemplate
|
|
461
|
+
${this.isManageView
|
|
462
|
+
? this.manageBarTemplate
|
|
456
463
|
: this.sortFilterBarTemplate}
|
|
457
464
|
<slot name="cb-results"></slot>
|
|
458
|
-
${this.displayMode === `list-compact` && this.totalResults
|
|
459
|
-
? this.listHeaderTemplate
|
|
465
|
+
${this.displayMode === `list-compact` && this.totalResults
|
|
466
|
+
? this.listHeaderTemplate
|
|
460
467
|
: nothing}
|
|
461
468
|
${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
|
|
462
469
|
</div>
|
|
463
|
-
`;
|
|
464
|
-
}
|
|
465
|
-
get infiniteScrollerTemplate() {
|
|
470
|
+
`;
|
|
471
|
+
}
|
|
472
|
+
get infiniteScrollerTemplate() {
|
|
466
473
|
return html `<infinite-scroller
|
|
467
474
|
class=${this.infiniteScrollerClasses}
|
|
468
475
|
itemCount=${this.placeholderType ? 0 : nothing}
|
|
@@ -471,22 +478,22 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
471
478
|
.placeholderCellTemplate=${this.placeholderCellTemplate}
|
|
472
479
|
@scrollThresholdReached=${this.scrollThresholdReached}
|
|
473
480
|
@visibleCellsChanged=${this.visibleCellsChanged}
|
|
474
|
-
>${this.displayMode === 'grid'
|
|
475
|
-
? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
|
|
481
|
+
>${this.displayMode === 'grid'
|
|
482
|
+
? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
|
|
476
483
|
: nothing}
|
|
477
|
-
</infinite-scroller>`;
|
|
478
|
-
}
|
|
479
|
-
get infiniteScrollerClasses() {
|
|
480
|
-
var _a;
|
|
481
|
-
return classMap({
|
|
482
|
-
[(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
|
|
483
|
-
hidden: !!this.placeholderType,
|
|
484
|
-
});
|
|
485
|
-
}
|
|
486
|
-
get sortFilterBarTemplate() {
|
|
487
|
-
var _a;
|
|
488
|
-
if (this.suppressSortBar)
|
|
489
|
-
return nothing;
|
|
484
|
+
</infinite-scroller>`;
|
|
485
|
+
}
|
|
486
|
+
get infiniteScrollerClasses() {
|
|
487
|
+
var _a;
|
|
488
|
+
return classMap({
|
|
489
|
+
[(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
|
|
490
|
+
hidden: !!this.placeholderType,
|
|
491
|
+
});
|
|
492
|
+
}
|
|
493
|
+
get sortFilterBarTemplate() {
|
|
494
|
+
var _a;
|
|
495
|
+
if (this.suppressSortBar)
|
|
496
|
+
return nothing;
|
|
490
497
|
return html `
|
|
491
498
|
<sort-filter-bar
|
|
492
499
|
.defaultSortField=${this.defaultSortField}
|
|
@@ -511,9 +518,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
511
518
|
<slot name="sort-options" slot="sort-options"></slot>
|
|
512
519
|
<slot name="sort-options-right" slot="sort-options-right"></slot>
|
|
513
520
|
</sort-filter-bar>
|
|
514
|
-
`;
|
|
515
|
-
}
|
|
516
|
-
get manageBarTemplate() {
|
|
521
|
+
`;
|
|
522
|
+
}
|
|
523
|
+
get manageBarTemplate() {
|
|
517
524
|
return html `
|
|
518
525
|
<manage-bar
|
|
519
526
|
.label=${this.manageViewLabel}
|
|
@@ -523,170 +530,170 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
523
530
|
@removeItems=${this.handleRemoveItems}
|
|
524
531
|
@selectAll=${() => this.dataSource.checkAllTiles()}
|
|
525
532
|
@unselectAll=${() => this.dataSource.uncheckAllTiles()}
|
|
526
|
-
@cancel=${() => {
|
|
527
|
-
this.isManageView = false;
|
|
528
|
-
this.dataSource.uncheckAllTiles();
|
|
533
|
+
@cancel=${() => {
|
|
534
|
+
this.isManageView = false;
|
|
535
|
+
this.dataSource.uncheckAllTiles();
|
|
529
536
|
}}
|
|
530
537
|
></manage-bar>
|
|
531
|
-
`;
|
|
532
|
-
}
|
|
533
|
-
/**
|
|
534
|
-
* Handler for when the user requests to remove all checked items via the manage bar.
|
|
535
|
-
* Emits an `itemRemovalRequested` event with all checked tile models.
|
|
536
|
-
*/
|
|
537
|
-
handleRemoveItems() {
|
|
538
|
-
this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
|
|
539
|
-
detail: {
|
|
540
|
-
items: this.dataSource.checkedTileModels.map(model => {
|
|
541
|
-
const cloned = model.clone();
|
|
542
|
-
cloned.dateStr = formatDate(model.datePublished, 'long');
|
|
543
|
-
return cloned;
|
|
544
|
-
}),
|
|
545
|
-
},
|
|
546
|
-
}));
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Removes all tile models that are currently checked & adjusts the paging
|
|
550
|
-
* of the data source to account for any new gaps in the data.
|
|
551
|
-
*/
|
|
552
|
-
removeCheckedTiles() {
|
|
553
|
-
this.dataSource.removeCheckedTiles();
|
|
554
|
-
}
|
|
555
|
-
userChangedSort(e) {
|
|
556
|
-
var _a;
|
|
557
|
-
const { selectedSort, sortDirection } = e.detail;
|
|
558
|
-
this.selectedSort = selectedSort;
|
|
559
|
-
this.sortDirection = sortDirection;
|
|
560
|
-
if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
|
|
561
|
-
this.goToPage(1);
|
|
562
|
-
}
|
|
563
|
-
this.currentPage = 1;
|
|
564
|
-
}
|
|
565
|
-
sendSortByAnalytics(prevSortDirection) {
|
|
566
|
-
var _a;
|
|
567
|
-
const directionCleared = prevSortDirection && !this.sortDirection;
|
|
568
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
569
|
-
category: this.searchContext,
|
|
570
|
-
action: analyticsActions.sortBy,
|
|
571
|
-
label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
|
|
572
|
-
});
|
|
573
|
-
}
|
|
574
|
-
selectedSortChanged() {
|
|
575
|
-
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
576
|
-
this.dataSource.updatePrefixFiltersForCurrentSort();
|
|
577
|
-
}
|
|
578
|
-
get sortParam() {
|
|
579
|
-
var _a;
|
|
580
|
-
const sortOption = SORT_OPTIONS[this.selectedSort];
|
|
581
|
-
if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
|
|
582
|
-
return null;
|
|
583
|
-
}
|
|
584
|
-
// If the sort option specified in the URL is unrecognized, we just use it as-is
|
|
585
|
-
const urlSortParam = new URL(window.location.href).searchParams.get('sort');
|
|
586
|
-
const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
|
|
587
|
-
// If the sort direction is still null at this point, then we assume ascending
|
|
588
|
-
// (i.e., it was unrecognized and had no directional flag)
|
|
589
|
-
if (!this.sortDirection)
|
|
590
|
-
this.sortDirection = 'asc';
|
|
591
|
-
if (!sortField)
|
|
592
|
-
return null;
|
|
593
|
-
return { field: sortField, direction: this.sortDirection };
|
|
594
|
-
}
|
|
595
|
-
displayModeChanged(e) {
|
|
596
|
-
var _a;
|
|
597
|
-
this.displayMode = e.detail.displayMode;
|
|
598
|
-
if (this.displayMode) {
|
|
599
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
600
|
-
category: this.searchContext,
|
|
601
|
-
action: analyticsActions.displayMode,
|
|
602
|
-
label: this.displayMode,
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
/**
|
|
607
|
-
* Returns a query clause identifying the currently selected title filter,
|
|
608
|
-
* e.g., `firstTitle:X`.
|
|
609
|
-
*/
|
|
610
|
-
get titleQuery() {
|
|
611
|
-
return this.selectedTitleFilter
|
|
612
|
-
? `firstTitle:${this.selectedTitleFilter}`
|
|
613
|
-
: undefined;
|
|
614
|
-
}
|
|
615
|
-
/**
|
|
616
|
-
* Returns a query clause identifying the currently selected creator filter,
|
|
617
|
-
* e.g., `firstCreator:X`.
|
|
618
|
-
*/
|
|
619
|
-
get creatorQuery() {
|
|
620
|
-
return this.selectedCreatorFilter
|
|
621
|
-
? `firstCreator:${this.selectedCreatorFilter}`
|
|
622
|
-
: undefined;
|
|
623
|
-
}
|
|
624
|
-
/**
|
|
625
|
-
* Send Analytics when sorting by title's first letter
|
|
626
|
-
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
627
|
-
*/
|
|
628
|
-
sendFilterByTitleAnalytics(prevSelectedLetter) {
|
|
629
|
-
var _a;
|
|
630
|
-
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
631
|
-
return;
|
|
632
|
-
}
|
|
633
|
-
const cleared = prevSelectedLetter && !this.selectedTitleFilter;
|
|
634
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
635
|
-
category: this.searchContext,
|
|
636
|
-
action: analyticsActions.filterByTitle,
|
|
637
|
-
label: cleared
|
|
638
|
-
? `clear-${prevSelectedLetter}`
|
|
639
|
-
: `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
/**
|
|
643
|
-
* Send Analytics when filtering by creator's first letter
|
|
644
|
-
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
645
|
-
*/
|
|
646
|
-
sendFilterByCreatorAnalytics(prevSelectedLetter) {
|
|
647
|
-
var _a;
|
|
648
|
-
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
649
|
-
return;
|
|
650
|
-
}
|
|
651
|
-
const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
|
|
652
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
653
|
-
category: this.searchContext,
|
|
654
|
-
action: analyticsActions.filterByCreator,
|
|
655
|
-
label: cleared
|
|
656
|
-
? `clear-${prevSelectedLetter}`
|
|
657
|
-
: `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
|
|
658
|
-
});
|
|
659
|
-
}
|
|
660
|
-
/**
|
|
661
|
-
* Handler for changes to which letter is selected in the title alphabet bar.
|
|
662
|
-
*/
|
|
663
|
-
titleLetterSelected(e) {
|
|
664
|
-
this.selectedCreatorFilter = null;
|
|
665
|
-
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
666
|
-
}
|
|
667
|
-
/**
|
|
668
|
-
* Handler for changes to which letter is selected in the creator alphabet bar.
|
|
669
|
-
*/
|
|
670
|
-
creatorLetterSelected(e) {
|
|
671
|
-
this.selectedTitleFilter = null;
|
|
672
|
-
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* The full template for how the facets should be structured in mobile view,
|
|
676
|
-
* including the collapsible container (with header) and the facets themselves.
|
|
677
|
-
*/
|
|
678
|
-
get mobileFacetsTemplate() {
|
|
679
|
-
const toggleFacetsVisible = (e) => {
|
|
680
|
-
var _a;
|
|
681
|
-
this.isResizeToMobile = false;
|
|
682
|
-
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
683
|
-
const target = e.target;
|
|
684
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
685
|
-
category: this.searchContext,
|
|
686
|
-
action: analyticsActions.mobileFacetsToggled,
|
|
687
|
-
label: target.open ? 'open' : 'closed',
|
|
688
|
-
});
|
|
689
|
-
};
|
|
538
|
+
`;
|
|
539
|
+
}
|
|
540
|
+
/**
|
|
541
|
+
* Handler for when the user requests to remove all checked items via the manage bar.
|
|
542
|
+
* Emits an `itemRemovalRequested` event with all checked tile models.
|
|
543
|
+
*/
|
|
544
|
+
handleRemoveItems() {
|
|
545
|
+
this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
|
|
546
|
+
detail: {
|
|
547
|
+
items: this.dataSource.checkedTileModels.map(model => {
|
|
548
|
+
const cloned = model.clone();
|
|
549
|
+
cloned.dateStr = formatDate(model.datePublished, 'long');
|
|
550
|
+
return cloned;
|
|
551
|
+
}),
|
|
552
|
+
},
|
|
553
|
+
}));
|
|
554
|
+
}
|
|
555
|
+
/**
|
|
556
|
+
* Removes all tile models that are currently checked & adjusts the paging
|
|
557
|
+
* of the data source to account for any new gaps in the data.
|
|
558
|
+
*/
|
|
559
|
+
removeCheckedTiles() {
|
|
560
|
+
this.dataSource.removeCheckedTiles();
|
|
561
|
+
}
|
|
562
|
+
userChangedSort(e) {
|
|
563
|
+
var _a;
|
|
564
|
+
const { selectedSort, sortDirection } = e.detail;
|
|
565
|
+
this.selectedSort = selectedSort;
|
|
566
|
+
this.sortDirection = sortDirection;
|
|
567
|
+
if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
|
|
568
|
+
this.goToPage(1);
|
|
569
|
+
}
|
|
570
|
+
this.currentPage = 1;
|
|
571
|
+
}
|
|
572
|
+
sendSortByAnalytics(prevSortDirection) {
|
|
573
|
+
var _a;
|
|
574
|
+
const directionCleared = prevSortDirection && !this.sortDirection;
|
|
575
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
576
|
+
category: this.searchContext,
|
|
577
|
+
action: analyticsActions.sortBy,
|
|
578
|
+
label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
selectedSortChanged() {
|
|
582
|
+
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
583
|
+
this.dataSource.updatePrefixFiltersForCurrentSort();
|
|
584
|
+
}
|
|
585
|
+
get sortParam() {
|
|
586
|
+
var _a;
|
|
587
|
+
const sortOption = SORT_OPTIONS[this.selectedSort];
|
|
588
|
+
if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
|
|
589
|
+
return null;
|
|
590
|
+
}
|
|
591
|
+
// If the sort option specified in the URL is unrecognized, we just use it as-is
|
|
592
|
+
const urlSortParam = new URL(window.location.href).searchParams.get('sort');
|
|
593
|
+
const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
|
|
594
|
+
// If the sort direction is still null at this point, then we assume ascending
|
|
595
|
+
// (i.e., it was unrecognized and had no directional flag)
|
|
596
|
+
if (!this.sortDirection)
|
|
597
|
+
this.sortDirection = 'asc';
|
|
598
|
+
if (!sortField)
|
|
599
|
+
return null;
|
|
600
|
+
return { field: sortField, direction: this.sortDirection };
|
|
601
|
+
}
|
|
602
|
+
displayModeChanged(e) {
|
|
603
|
+
var _a;
|
|
604
|
+
this.displayMode = e.detail.displayMode;
|
|
605
|
+
if (this.displayMode) {
|
|
606
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
607
|
+
category: this.searchContext,
|
|
608
|
+
action: analyticsActions.displayMode,
|
|
609
|
+
label: this.displayMode,
|
|
610
|
+
});
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
/**
|
|
614
|
+
* Returns a query clause identifying the currently selected title filter,
|
|
615
|
+
* e.g., `firstTitle:X`.
|
|
616
|
+
*/
|
|
617
|
+
get titleQuery() {
|
|
618
|
+
return this.selectedTitleFilter
|
|
619
|
+
? `firstTitle:${this.selectedTitleFilter}`
|
|
620
|
+
: undefined;
|
|
621
|
+
}
|
|
622
|
+
/**
|
|
623
|
+
* Returns a query clause identifying the currently selected creator filter,
|
|
624
|
+
* e.g., `firstCreator:X`.
|
|
625
|
+
*/
|
|
626
|
+
get creatorQuery() {
|
|
627
|
+
return this.selectedCreatorFilter
|
|
628
|
+
? `firstCreator:${this.selectedCreatorFilter}`
|
|
629
|
+
: undefined;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Send Analytics when sorting by title's first letter
|
|
633
|
+
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
634
|
+
*/
|
|
635
|
+
sendFilterByTitleAnalytics(prevSelectedLetter) {
|
|
636
|
+
var _a;
|
|
637
|
+
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
638
|
+
return;
|
|
639
|
+
}
|
|
640
|
+
const cleared = prevSelectedLetter && !this.selectedTitleFilter;
|
|
641
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
642
|
+
category: this.searchContext,
|
|
643
|
+
action: analyticsActions.filterByTitle,
|
|
644
|
+
label: cleared
|
|
645
|
+
? `clear-${prevSelectedLetter}`
|
|
646
|
+
: `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
/**
|
|
650
|
+
* Send Analytics when filtering by creator's first letter
|
|
651
|
+
* labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
|
|
652
|
+
*/
|
|
653
|
+
sendFilterByCreatorAnalytics(prevSelectedLetter) {
|
|
654
|
+
var _a;
|
|
655
|
+
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
|
|
659
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
660
|
+
category: this.searchContext,
|
|
661
|
+
action: analyticsActions.filterByCreator,
|
|
662
|
+
label: cleared
|
|
663
|
+
? `clear-${prevSelectedLetter}`
|
|
664
|
+
: `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
/**
|
|
668
|
+
* Handler for changes to which letter is selected in the title alphabet bar.
|
|
669
|
+
*/
|
|
670
|
+
titleLetterSelected(e) {
|
|
671
|
+
this.selectedCreatorFilter = null;
|
|
672
|
+
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Handler for changes to which letter is selected in the creator alphabet bar.
|
|
676
|
+
*/
|
|
677
|
+
creatorLetterSelected(e) {
|
|
678
|
+
this.selectedTitleFilter = null;
|
|
679
|
+
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
680
|
+
}
|
|
681
|
+
/**
|
|
682
|
+
* The full template for how the facets should be structured in mobile view,
|
|
683
|
+
* including the collapsible container (with header) and the facets themselves.
|
|
684
|
+
*/
|
|
685
|
+
get mobileFacetsTemplate() {
|
|
686
|
+
const toggleFacetsVisible = (e) => {
|
|
687
|
+
var _a;
|
|
688
|
+
this.isResizeToMobile = false;
|
|
689
|
+
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
690
|
+
const target = e.target;
|
|
691
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
692
|
+
category: this.searchContext,
|
|
693
|
+
action: analyticsActions.mobileFacetsToggled,
|
|
694
|
+
label: target.open ? 'open' : 'closed',
|
|
695
|
+
});
|
|
696
|
+
};
|
|
690
697
|
return html `
|
|
691
698
|
<details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
|
|
692
699
|
<summary>
|
|
@@ -696,19 +703,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
696
703
|
</summary>
|
|
697
704
|
${this.facetsTemplate}
|
|
698
705
|
</details>
|
|
699
|
-
`;
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* The template for the facets component alone, without any surrounding wrappers.
|
|
703
|
-
*/
|
|
704
|
-
get facetsTemplate() {
|
|
705
|
-
if (this.suppressFacets) {
|
|
706
|
+
`;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* The template for the facets component alone, without any surrounding wrappers.
|
|
710
|
+
*/
|
|
711
|
+
get facetsTemplate() {
|
|
712
|
+
if (this.suppressFacets) {
|
|
706
713
|
return html `
|
|
707
714
|
<p class="facets-message">
|
|
708
715
|
${msg('Facets are temporarily unavailable.')}
|
|
709
716
|
</p>
|
|
710
|
-
`;
|
|
711
|
-
}
|
|
717
|
+
`;
|
|
718
|
+
}
|
|
712
719
|
return html `
|
|
713
720
|
<collection-facets
|
|
714
721
|
@facetsChanged=${this.facetsChanged}
|
|
@@ -722,7 +729,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
722
729
|
.resizeObserver=${this.resizeObserver}
|
|
723
730
|
.searchType=${this.searchType}
|
|
724
731
|
.aggregations=${this.dataSource.aggregations}
|
|
725
|
-
.fullYearsHistogramAggregation=${this.dataSource
|
|
732
|
+
.fullYearsHistogramAggregation=${this.dataSource
|
|
726
733
|
.yearHistogramAggregation}
|
|
727
734
|
.minSelectedDate=${this.minSelectedDate}
|
|
728
735
|
.maxSelectedDate=${this.maxSelectedDate}
|
|
@@ -743,41 +750,41 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
743
750
|
.analyticsHandler=${this.analyticsHandler}
|
|
744
751
|
>
|
|
745
752
|
</collection-facets>
|
|
746
|
-
`;
|
|
747
|
-
}
|
|
748
|
-
/**
|
|
749
|
-
* The HTML template for the "Clear all filters" button, or `nothing` if no
|
|
750
|
-
* filters are currently active.
|
|
751
|
-
*
|
|
752
|
-
* @param mobile Whether to style/shorten the button for mobile view
|
|
753
|
-
*/
|
|
754
|
-
clearFiltersBtnTemplate(mobile) {
|
|
755
|
-
if (!this.hasActiveFilters)
|
|
756
|
-
return nothing;
|
|
757
|
-
const buttonClasses = classMap({
|
|
758
|
-
'clear-filters-btn': true,
|
|
759
|
-
mobile,
|
|
760
|
-
});
|
|
761
|
-
const buttonText = mobile ? 'Clear all' : 'Clear all filters';
|
|
753
|
+
`;
|
|
754
|
+
}
|
|
755
|
+
/**
|
|
756
|
+
* The HTML template for the "Clear all filters" button, or `nothing` if no
|
|
757
|
+
* filters are currently active.
|
|
758
|
+
*
|
|
759
|
+
* @param mobile Whether to style/shorten the button for mobile view
|
|
760
|
+
*/
|
|
761
|
+
clearFiltersBtnTemplate(mobile) {
|
|
762
|
+
if (!this.hasActiveFilters)
|
|
763
|
+
return nothing;
|
|
764
|
+
const buttonClasses = classMap({
|
|
765
|
+
'clear-filters-btn': true,
|
|
766
|
+
mobile,
|
|
767
|
+
});
|
|
768
|
+
const buttonText = mobile ? 'Clear all' : 'Clear all filters';
|
|
762
769
|
return html `
|
|
763
770
|
<div class="clear-filters-btn-row">
|
|
764
|
-
${mobile
|
|
765
|
-
? html `<span class="clear-filters-btn-separator"> </span>`
|
|
771
|
+
${mobile
|
|
772
|
+
? html `<span class="clear-filters-btn-separator"> </span>`
|
|
766
773
|
: nothing}
|
|
767
774
|
<button class=${buttonClasses} @click=${this.clearFilters}>
|
|
768
775
|
${buttonText}
|
|
769
776
|
</button>
|
|
770
777
|
</div>
|
|
771
|
-
`;
|
|
772
|
-
}
|
|
773
|
-
get loadingTemplate() {
|
|
778
|
+
`;
|
|
779
|
+
}
|
|
780
|
+
get loadingTemplate() {
|
|
774
781
|
return html `
|
|
775
782
|
<div class="loading-cover">
|
|
776
783
|
<circular-activity-indicator></circular-activity-indicator>
|
|
777
784
|
</div>
|
|
778
|
-
`;
|
|
779
|
-
}
|
|
780
|
-
get listHeaderTemplate() {
|
|
785
|
+
`;
|
|
786
|
+
}
|
|
787
|
+
get listHeaderTemplate() {
|
|
781
788
|
return html `
|
|
782
789
|
<div id="list-header">
|
|
783
790
|
<tile-dispatcher
|
|
@@ -790,601 +797,605 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
790
797
|
>
|
|
791
798
|
</tile-dispatcher>
|
|
792
799
|
</div>
|
|
793
|
-
`;
|
|
794
|
-
}
|
|
795
|
-
histogramDateRangeUpdated(e) {
|
|
796
|
-
var _a;
|
|
797
|
-
const { minDate, maxDate } = e.detail;
|
|
798
|
-
[this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
|
|
799
|
-
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
800
|
-
category: this.searchContext,
|
|
801
|
-
action: analyticsActions.histogramChanged,
|
|
802
|
-
label: this.dateRangeQueryClause,
|
|
803
|
-
});
|
|
804
|
-
}
|
|
805
|
-
get dateRangeQueryClause() {
|
|
806
|
-
if (!this.minSelectedDate || !this.maxSelectedDate) {
|
|
807
|
-
return undefined;
|
|
808
|
-
}
|
|
809
|
-
return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
|
|
810
|
-
}
|
|
811
|
-
/**
|
|
812
|
-
* Emits an event indicating a change in whether the manage mode is shown.
|
|
813
|
-
*/
|
|
814
|
-
emitManageModeChangedEvent() {
|
|
815
|
-
this.dispatchEvent(new CustomEvent('manageModeChanged', {
|
|
816
|
-
detail: this.isManageView,
|
|
817
|
-
}));
|
|
818
|
-
}
|
|
819
|
-
async installDataSourceAndQueryState(dataSource, queryState) {
|
|
820
|
-
var _a, _b;
|
|
821
|
-
log('Installing data source & query state in CB:', dataSource, queryState);
|
|
822
|
-
if (this.dataSource)
|
|
823
|
-
this.removeController(this.dataSource);
|
|
824
|
-
this.dataSource = dataSource;
|
|
825
|
-
this.addController(this.dataSource);
|
|
826
|
-
this.baseQuery = queryState.baseQuery;
|
|
827
|
-
this.profileElement = queryState.profileElement;
|
|
828
|
-
this.searchType = queryState.searchType;
|
|
829
|
-
this.selectedFacets =
|
|
830
|
-
(_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
|
|
831
|
-
this.minSelectedDate = queryState.minSelectedDate;
|
|
832
|
-
this.maxSelectedDate = queryState.maxSelectedDate;
|
|
833
|
-
this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
|
|
834
|
-
this.sortDirection = queryState.sortDirection;
|
|
835
|
-
this.selectedTitleFilter = queryState.selectedTitleFilter;
|
|
836
|
-
this.selectedCreatorFilter = queryState.selectedCreatorFilter;
|
|
837
|
-
// We set this flag during the update to prevent the URL state persistence
|
|
838
|
-
// from creating an unwanted extra history entry.
|
|
839
|
-
this.dataSourceInstallInProgress = true;
|
|
840
|
-
this.requestUpdate();
|
|
841
|
-
await this.updateComplete;
|
|
842
|
-
this.dataSourceInstallInProgress = false;
|
|
843
|
-
if (!this.searchResultsLoading) {
|
|
844
|
-
this.setTotalResultCount(this.dataSource.totalResults);
|
|
845
|
-
this.setTileCount(this.dataSource.size);
|
|
846
|
-
}
|
|
847
|
-
this.refreshVisibleResults();
|
|
848
|
-
}
|
|
849
|
-
firstUpdated() {
|
|
850
|
-
this.restoreState();
|
|
851
|
-
}
|
|
852
|
-
updated(changed) {
|
|
853
|
-
var _a, _b;
|
|
854
|
-
if (changed.has('placeholderType') && this.placeholderType === null) {
|
|
855
|
-
if (!this.leftColIntersectionObserver) {
|
|
856
|
-
this.setupLeftColumnScrollListeners();
|
|
857
|
-
}
|
|
858
|
-
if (!this.facetsIntersectionObserver) {
|
|
859
|
-
this.setupFacetsScrollListeners();
|
|
860
|
-
}
|
|
861
|
-
this.updateLeftColumnHeight();
|
|
862
|
-
}
|
|
863
|
-
if (changed.has('displayMode') ||
|
|
864
|
-
changed.has('baseNavigationUrl') ||
|
|
865
|
-
changed.has('baseImageUrl') ||
|
|
866
|
-
changed.has('loggedIn')) {
|
|
867
|
-
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
868
|
-
}
|
|
869
|
-
if (changed.has('baseQuery') ||
|
|
870
|
-
changed.has('searchType') ||
|
|
871
|
-
changed.has('withinCollection')) {
|
|
872
|
-
// Unless this query/search type update is from the initial page load or the
|
|
873
|
-
// result of hitting the back button,
|
|
874
|
-
// we need to clear any existing filters since they may no longer be valid for
|
|
875
|
-
// the new set of search results.
|
|
876
|
-
if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
|
|
877
|
-
// Ordinarily, we leave the sort param unchanged between searches.
|
|
878
|
-
// However, if we are changing the target collection itself, we want the sort cleared too,
|
|
879
|
-
// since different collections may have different sorting options available.
|
|
880
|
-
const shouldClearSort = changed.has('withinCollection') &&
|
|
881
|
-
!changed.has('selectedSort') &&
|
|
882
|
-
!changed.has('sortDirection');
|
|
883
|
-
// Otherwise, only clear filters that haven't been simultaneously applied in this update
|
|
884
|
-
this.clearFilters({
|
|
885
|
-
sort: shouldClearSort,
|
|
886
|
-
facets: !changed.has('selectedFacets'),
|
|
887
|
-
dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
|
|
888
|
-
letterFilters: !(changed.has('selectedTitleFilter') ||
|
|
889
|
-
changed.has('selectedCreatorFilter')),
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
if (changed.has('profileElement')) {
|
|
894
|
-
this.applyDefaultProfileSort();
|
|
895
|
-
}
|
|
896
|
-
if (changed.has('baseQuery')) {
|
|
897
|
-
this.emitBaseQueryChanged();
|
|
898
|
-
}
|
|
899
|
-
if (changed.has('searchType')) {
|
|
900
|
-
this.emitSearchTypeChanged();
|
|
901
|
-
}
|
|
902
|
-
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
903
|
-
this.persistState();
|
|
904
|
-
}
|
|
905
|
-
if (changed.has('baseQuery') ||
|
|
906
|
-
changed.has('minSelectedDate') ||
|
|
907
|
-
changed.has('maxSelectedDate') ||
|
|
908
|
-
changed.has('selectedFacets') ||
|
|
909
|
-
changed.has('searchService') ||
|
|
910
|
-
changed.has('withinCollection') ||
|
|
911
|
-
changed.has('withinProfile') ||
|
|
912
|
-
changed.has('profileElement')) {
|
|
913
|
-
this.dataSource.refreshLetterCounts();
|
|
914
|
-
}
|
|
915
|
-
if (changed.has('selectedSort') || changed.has('sortDirection')) {
|
|
916
|
-
const prevSortDirection = changed.get('sortDirection');
|
|
917
|
-
this.sendSortByAnalytics(prevSortDirection);
|
|
918
|
-
this.selectedSortChanged();
|
|
919
|
-
}
|
|
920
|
-
if (changed.has('selectedTitleFilter')) {
|
|
921
|
-
this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
|
|
922
|
-
}
|
|
923
|
-
if (changed.has('selectedCreatorFilter')) {
|
|
924
|
-
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
changed.has('
|
|
932
|
-
changed.has('
|
|
933
|
-
changed.has('
|
|
934
|
-
changed.has('
|
|
935
|
-
changed.has('
|
|
936
|
-
changed.has('
|
|
937
|
-
changed.has('
|
|
938
|
-
changed.has('
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
this.
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
this.
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
(
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
*
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
const
|
|
1095
|
-
if (
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
const
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
*
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
//
|
|
1122
|
-
if (!this.
|
|
1123
|
-
|
|
1124
|
-
return;
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
this.
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
if (this.
|
|
1140
|
-
this.
|
|
1141
|
-
this.
|
|
1142
|
-
}
|
|
1143
|
-
if (
|
|
1144
|
-
this.
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
this.
|
|
1166
|
-
}
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
this.
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
this.
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
this.
|
|
1181
|
-
this.
|
|
1182
|
-
this.
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
*
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
//
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
//
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
this.
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
800
|
+
`;
|
|
801
|
+
}
|
|
802
|
+
histogramDateRangeUpdated(e) {
|
|
803
|
+
var _a;
|
|
804
|
+
const { minDate, maxDate } = e.detail;
|
|
805
|
+
[this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
|
|
806
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
807
|
+
category: this.searchContext,
|
|
808
|
+
action: analyticsActions.histogramChanged,
|
|
809
|
+
label: this.dateRangeQueryClause,
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
get dateRangeQueryClause() {
|
|
813
|
+
if (!this.minSelectedDate || !this.maxSelectedDate) {
|
|
814
|
+
return undefined;
|
|
815
|
+
}
|
|
816
|
+
return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
|
|
817
|
+
}
|
|
818
|
+
/**
|
|
819
|
+
* Emits an event indicating a change in whether the manage mode is shown.
|
|
820
|
+
*/
|
|
821
|
+
emitManageModeChangedEvent() {
|
|
822
|
+
this.dispatchEvent(new CustomEvent('manageModeChanged', {
|
|
823
|
+
detail: this.isManageView,
|
|
824
|
+
}));
|
|
825
|
+
}
|
|
826
|
+
async installDataSourceAndQueryState(dataSource, queryState) {
|
|
827
|
+
var _a, _b;
|
|
828
|
+
log('Installing data source & query state in CB:', dataSource, queryState);
|
|
829
|
+
if (this.dataSource)
|
|
830
|
+
this.removeController(this.dataSource);
|
|
831
|
+
this.dataSource = dataSource;
|
|
832
|
+
this.addController(this.dataSource);
|
|
833
|
+
this.baseQuery = queryState.baseQuery;
|
|
834
|
+
this.profileElement = queryState.profileElement;
|
|
835
|
+
this.searchType = queryState.searchType;
|
|
836
|
+
this.selectedFacets =
|
|
837
|
+
(_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
|
|
838
|
+
this.minSelectedDate = queryState.minSelectedDate;
|
|
839
|
+
this.maxSelectedDate = queryState.maxSelectedDate;
|
|
840
|
+
this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
|
|
841
|
+
this.sortDirection = queryState.sortDirection;
|
|
842
|
+
this.selectedTitleFilter = queryState.selectedTitleFilter;
|
|
843
|
+
this.selectedCreatorFilter = queryState.selectedCreatorFilter;
|
|
844
|
+
// We set this flag during the update to prevent the URL state persistence
|
|
845
|
+
// from creating an unwanted extra history entry.
|
|
846
|
+
this.dataSourceInstallInProgress = true;
|
|
847
|
+
this.requestUpdate();
|
|
848
|
+
await this.updateComplete;
|
|
849
|
+
this.dataSourceInstallInProgress = false;
|
|
850
|
+
if (!this.searchResultsLoading) {
|
|
851
|
+
this.setTotalResultCount(this.dataSource.totalResults);
|
|
852
|
+
this.setTileCount(this.dataSource.size);
|
|
853
|
+
}
|
|
854
|
+
this.refreshVisibleResults();
|
|
855
|
+
}
|
|
856
|
+
firstUpdated() {
|
|
857
|
+
this.restoreState();
|
|
858
|
+
}
|
|
859
|
+
updated(changed) {
|
|
860
|
+
var _a, _b;
|
|
861
|
+
if (changed.has('placeholderType') && this.placeholderType === null) {
|
|
862
|
+
if (!this.leftColIntersectionObserver) {
|
|
863
|
+
this.setupLeftColumnScrollListeners();
|
|
864
|
+
}
|
|
865
|
+
if (!this.facetsIntersectionObserver) {
|
|
866
|
+
this.setupFacetsScrollListeners();
|
|
867
|
+
}
|
|
868
|
+
this.updateLeftColumnHeight();
|
|
869
|
+
}
|
|
870
|
+
if (changed.has('displayMode') ||
|
|
871
|
+
changed.has('baseNavigationUrl') ||
|
|
872
|
+
changed.has('baseImageUrl') ||
|
|
873
|
+
changed.has('loggedIn')) {
|
|
874
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
875
|
+
}
|
|
876
|
+
if (changed.has('baseQuery') ||
|
|
877
|
+
changed.has('searchType') ||
|
|
878
|
+
changed.has('withinCollection')) {
|
|
879
|
+
// Unless this query/search type update is from the initial page load or the
|
|
880
|
+
// result of hitting the back button,
|
|
881
|
+
// we need to clear any existing filters since they may no longer be valid for
|
|
882
|
+
// the new set of search results.
|
|
883
|
+
if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
|
|
884
|
+
// Ordinarily, we leave the sort param unchanged between searches.
|
|
885
|
+
// However, if we are changing the target collection itself, we want the sort cleared too,
|
|
886
|
+
// since different collections may have different sorting options available.
|
|
887
|
+
const shouldClearSort = changed.has('withinCollection') &&
|
|
888
|
+
!changed.has('selectedSort') &&
|
|
889
|
+
!changed.has('sortDirection');
|
|
890
|
+
// Otherwise, only clear filters that haven't been simultaneously applied in this update
|
|
891
|
+
this.clearFilters({
|
|
892
|
+
sort: shouldClearSort,
|
|
893
|
+
facets: !changed.has('selectedFacets'),
|
|
894
|
+
dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
|
|
895
|
+
letterFilters: !(changed.has('selectedTitleFilter') ||
|
|
896
|
+
changed.has('selectedCreatorFilter')),
|
|
897
|
+
});
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
if (changed.has('profileElement')) {
|
|
901
|
+
this.applyDefaultProfileSort();
|
|
902
|
+
}
|
|
903
|
+
if (changed.has('baseQuery')) {
|
|
904
|
+
this.emitBaseQueryChanged();
|
|
905
|
+
}
|
|
906
|
+
if (changed.has('searchType')) {
|
|
907
|
+
this.emitSearchTypeChanged();
|
|
908
|
+
}
|
|
909
|
+
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
910
|
+
this.persistState();
|
|
911
|
+
}
|
|
912
|
+
if (changed.has('baseQuery') ||
|
|
913
|
+
changed.has('minSelectedDate') ||
|
|
914
|
+
changed.has('maxSelectedDate') ||
|
|
915
|
+
changed.has('selectedFacets') ||
|
|
916
|
+
changed.has('searchService') ||
|
|
917
|
+
changed.has('withinCollection') ||
|
|
918
|
+
changed.has('withinProfile') ||
|
|
919
|
+
changed.has('profileElement')) {
|
|
920
|
+
this.dataSource.refreshLetterCounts();
|
|
921
|
+
}
|
|
922
|
+
if (changed.has('selectedSort') || changed.has('sortDirection')) {
|
|
923
|
+
const prevSortDirection = changed.get('sortDirection');
|
|
924
|
+
this.sendSortByAnalytics(prevSortDirection);
|
|
925
|
+
this.selectedSortChanged();
|
|
926
|
+
}
|
|
927
|
+
if (changed.has('selectedTitleFilter')) {
|
|
928
|
+
this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
|
|
929
|
+
}
|
|
930
|
+
if (changed.has('selectedCreatorFilter')) {
|
|
931
|
+
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
932
|
+
}
|
|
933
|
+
// Facets are always visible in the desktop view.
|
|
934
|
+
// But in the mobile view, their visibility state can be toggled by the user.
|
|
935
|
+
// In either case, inform the data source so that it can determine whether/when to fetch facets.
|
|
936
|
+
this.dataSource.handleFacetVisibilityChange(!this.mobileView || this.mobileFacetsVisible);
|
|
937
|
+
if (changed.has('baseQuery') ||
|
|
938
|
+
changed.has('searchType') ||
|
|
939
|
+
changed.has('selectedTitleFilter') ||
|
|
940
|
+
changed.has('selectedCreatorFilter') ||
|
|
941
|
+
changed.has('minSelectedDate') ||
|
|
942
|
+
changed.has('maxSelectedDate') ||
|
|
943
|
+
changed.has('selectedSort') ||
|
|
944
|
+
changed.has('sortDirection') ||
|
|
945
|
+
changed.has('selectedFacets') ||
|
|
946
|
+
changed.has('searchService') ||
|
|
947
|
+
changed.has('withinCollection') ||
|
|
948
|
+
changed.has('withinProfile') ||
|
|
949
|
+
changed.has('profileElement')) {
|
|
950
|
+
this.handleQueryChange();
|
|
951
|
+
}
|
|
952
|
+
if (changed.has('searchResultsLoading')) {
|
|
953
|
+
this.emitSearchResultsLoadingChanged();
|
|
954
|
+
}
|
|
955
|
+
if (changed.has('facetsLoading') &&
|
|
956
|
+
this.facetsLoading &&
|
|
957
|
+
this.collectionFacets) {
|
|
958
|
+
this.collectionFacets.moreLinksVisible =
|
|
959
|
+
this.searchType !== SearchType.FULLTEXT;
|
|
960
|
+
}
|
|
961
|
+
if (changed.has('pagesToRender')) {
|
|
962
|
+
if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
|
|
963
|
+
this.infiniteScroller.itemCount = this.estimatedTileCount;
|
|
964
|
+
}
|
|
965
|
+
}
|
|
966
|
+
if (changed.has('isManageView')) {
|
|
967
|
+
if (this.isManageView)
|
|
968
|
+
this.displayMode = 'grid';
|
|
969
|
+
(_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.refreshAllVisibleCells();
|
|
970
|
+
this.emitManageModeChangedEvent();
|
|
971
|
+
}
|
|
972
|
+
if (changed.has('resizeObserver')) {
|
|
973
|
+
const oldObserver = changed.get('resizeObserver');
|
|
974
|
+
if (oldObserver)
|
|
975
|
+
this.disconnectResizeObserver(oldObserver);
|
|
976
|
+
this.setupResizeObserver();
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
connectedCallback() {
|
|
980
|
+
var _a;
|
|
981
|
+
(_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
982
|
+
this.setupStateRestorationObserver();
|
|
983
|
+
this.setupResizeObserver();
|
|
984
|
+
}
|
|
985
|
+
disconnectedCallback() {
|
|
986
|
+
var _a, _b;
|
|
987
|
+
if (this.resizeObserver) {
|
|
988
|
+
this.disconnectResizeObserver(this.resizeObserver);
|
|
989
|
+
}
|
|
990
|
+
if (this.boundNavigationHandler) {
|
|
991
|
+
window.removeEventListener('popstate', this.boundNavigationHandler);
|
|
992
|
+
}
|
|
993
|
+
(_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
994
|
+
(_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
|
995
|
+
window.removeEventListener('resize', this.updateLeftColumnHeight);
|
|
996
|
+
}
|
|
997
|
+
handleResize(entry) {
|
|
998
|
+
const previousView = this.mobileView;
|
|
999
|
+
if (entry.target === this.contentContainer) {
|
|
1000
|
+
this.contentWidth = entry.contentRect.width;
|
|
1001
|
+
this.mobileView =
|
|
1002
|
+
this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
|
|
1003
|
+
// If changing from desktop to mobile disable transition
|
|
1004
|
+
if (this.mobileView && !previousView) {
|
|
1005
|
+
this.isResizeToMobile = true;
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
// Ensure the facet sidebar remains sized correctly
|
|
1009
|
+
this.updateLeftColumnHeight();
|
|
1010
|
+
}
|
|
1011
|
+
/**
|
|
1012
|
+
* Sets up listeners for events that may require updating the left column height.
|
|
1013
|
+
*/
|
|
1014
|
+
setupLeftColumnScrollListeners() {
|
|
1015
|
+
var _a;
|
|
1016
|
+
// We observe intersections between the left column's scroll sentinel and
|
|
1017
|
+
// the viewport, so that we can ensure the left column is always sized to
|
|
1018
|
+
// match the _available_ viewport height. This should generally be more
|
|
1019
|
+
// performant than listening to scroll events on the page or column.
|
|
1020
|
+
const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
|
|
1021
|
+
if (leftColumnSentinel) {
|
|
1022
|
+
this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
|
|
1023
|
+
threshold: [...Array(101).keys()].map(n => n / 100), // Threshold every 1%
|
|
1024
|
+
});
|
|
1025
|
+
this.leftColIntersectionObserver.observe(leftColumnSentinel);
|
|
1026
|
+
}
|
|
1027
|
+
// We also listen for window resize events, as they are not always captured
|
|
1028
|
+
// by the resize observer and can affect the desired height of the left column.
|
|
1029
|
+
window.addEventListener('resize', this.updateLeftColumnHeight);
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
|
|
1033
|
+
* Note this uses a separate IntersectionObserver from the left column, because we
|
|
1034
|
+
* don't need granular intersection thresholds for this.
|
|
1035
|
+
*/
|
|
1036
|
+
setupFacetsScrollListeners() {
|
|
1037
|
+
var _a;
|
|
1038
|
+
const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
|
|
1039
|
+
if (facetsSentinel) {
|
|
1040
|
+
this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
|
|
1041
|
+
this.facetsIntersectionObserver.observe(facetsSentinel);
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
emitBaseQueryChanged() {
|
|
1045
|
+
this.dispatchEvent(new CustomEvent('baseQueryChanged', {
|
|
1046
|
+
detail: {
|
|
1047
|
+
baseQuery: this.baseQuery,
|
|
1048
|
+
},
|
|
1049
|
+
}));
|
|
1050
|
+
}
|
|
1051
|
+
emitSearchTypeChanged() {
|
|
1052
|
+
this.dispatchEvent(new CustomEvent('searchTypeChanged', {
|
|
1053
|
+
detail: this.searchType,
|
|
1054
|
+
}));
|
|
1055
|
+
}
|
|
1056
|
+
emitQueryStateChanged() {
|
|
1057
|
+
this.dispatchEvent(new CustomEvent('queryStateChanged', {
|
|
1058
|
+
detail: {
|
|
1059
|
+
baseQuery: this.baseQuery,
|
|
1060
|
+
withinCollection: this.withinCollection,
|
|
1061
|
+
withinProfile: this.withinProfile,
|
|
1062
|
+
profileElement: this.profileElement,
|
|
1063
|
+
searchType: this.searchType,
|
|
1064
|
+
selectedFacets: this.selectedFacets,
|
|
1065
|
+
minSelectedDate: this.minSelectedDate,
|
|
1066
|
+
maxSelectedDate: this.maxSelectedDate,
|
|
1067
|
+
selectedSort: this.selectedSort,
|
|
1068
|
+
sortDirection: this.sortDirection,
|
|
1069
|
+
selectedTitleFilter: this.selectedTitleFilter,
|
|
1070
|
+
selectedCreatorFilter: this.selectedCreatorFilter,
|
|
1071
|
+
},
|
|
1072
|
+
}));
|
|
1073
|
+
}
|
|
1074
|
+
emitEmptyResults() {
|
|
1075
|
+
this.dispatchEvent(new Event('emptyResults'));
|
|
1076
|
+
}
|
|
1077
|
+
disconnectResizeObserver(resizeObserver) {
|
|
1078
|
+
resizeObserver.removeObserver({
|
|
1079
|
+
target: this.contentContainer,
|
|
1080
|
+
handler: this,
|
|
1081
|
+
});
|
|
1082
|
+
}
|
|
1083
|
+
setupResizeObserver() {
|
|
1084
|
+
if (!this.resizeObserver || !this.contentContainer)
|
|
1085
|
+
return;
|
|
1086
|
+
this.resizeObserver.addObserver({
|
|
1087
|
+
target: this.contentContainer,
|
|
1088
|
+
handler: this,
|
|
1089
|
+
});
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* When the visible cells change from the infinite scroller, we want to emit
|
|
1093
|
+
* which page is currently visible so the consumer can update its UI or the URL
|
|
1094
|
+
*
|
|
1095
|
+
* @param e
|
|
1096
|
+
* @returns
|
|
1097
|
+
*/
|
|
1098
|
+
visibleCellsChanged(e) {
|
|
1099
|
+
if (this.isScrollingToCell)
|
|
1100
|
+
return;
|
|
1101
|
+
const { visibleCellIndices } = e.detail;
|
|
1102
|
+
if (visibleCellIndices.length === 0)
|
|
1103
|
+
return;
|
|
1104
|
+
const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
|
|
1105
|
+
const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
|
|
1106
|
+
if (this.currentPage !== lastVisibleCellPage) {
|
|
1107
|
+
this.currentPage = lastVisibleCellPage;
|
|
1108
|
+
}
|
|
1109
|
+
const event = new CustomEvent('visiblePageChanged', {
|
|
1110
|
+
detail: {
|
|
1111
|
+
pageNumber: lastVisibleCellPage,
|
|
1112
|
+
},
|
|
1113
|
+
});
|
|
1114
|
+
this.dispatchEvent(event);
|
|
1115
|
+
}
|
|
1116
|
+
/**
|
|
1117
|
+
* A Promise which, after each query change, resolves once the fetches for the initial
|
|
1118
|
+
* search have completed. Waits for *both* the hits and aggregations fetches to finish.
|
|
1119
|
+
*
|
|
1120
|
+
* Ensure you await this component's `updateComplete` promise before awaiting this
|
|
1121
|
+
* one, to ensure you do not await an obsolete promise from the previous update.
|
|
1122
|
+
*/
|
|
1123
|
+
get initialSearchComplete() {
|
|
1124
|
+
return this.dataSource.initialSearchComplete;
|
|
1125
|
+
}
|
|
1126
|
+
async handleQueryChange() {
|
|
1127
|
+
var _a;
|
|
1128
|
+
// only reset if the query has actually changed
|
|
1129
|
+
if (!this.searchService ||
|
|
1130
|
+
this.dataSource.pageFetchQueryKey === this.previousQueryKey)
|
|
1131
|
+
return;
|
|
1132
|
+
// If the new state prevents us from updating the search results, don't reset
|
|
1133
|
+
if (!this.dataSource.canPerformSearch &&
|
|
1134
|
+
!(this.clearResultsOnEmptyQuery && this.baseQuery === ''))
|
|
1135
|
+
return;
|
|
1136
|
+
this.previousQueryKey = this.dataSource.pageFetchQueryKey;
|
|
1137
|
+
// this.emitQueryStateChanged();
|
|
1138
|
+
this.tileModelOffset = 0;
|
|
1139
|
+
this.totalResults = undefined;
|
|
1140
|
+
this.pagesToRender =
|
|
1141
|
+
this.initialPageNumber === 1
|
|
1142
|
+
? 2 // First two pages are batched into one request when starting from page 1
|
|
1143
|
+
: this.initialPageNumber;
|
|
1144
|
+
// Reset the infinite scroller's item count, so that it
|
|
1145
|
+
// shows tile placeholders until the new query's results load in
|
|
1146
|
+
if (this.infiniteScroller) {
|
|
1147
|
+
this.infiniteScroller.itemCount = this.estimatedTileCount;
|
|
1148
|
+
this.infiniteScroller.reload();
|
|
1149
|
+
}
|
|
1150
|
+
if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
|
|
1151
|
+
this.defaultSortField = SortField.relevance;
|
|
1152
|
+
this.defaultSortDirection = null;
|
|
1153
|
+
}
|
|
1154
|
+
if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
|
|
1155
|
+
this.scrollToPage(this.initialPageNumber);
|
|
1156
|
+
}
|
|
1157
|
+
this.initialQueryChangeHappened = true;
|
|
1158
|
+
// if the query changed as part of a window.history pop event, we don't want to
|
|
1159
|
+
// persist the state because it overwrites the forward history
|
|
1160
|
+
if (!this.historyPopOccurred) {
|
|
1161
|
+
this.persistState();
|
|
1162
|
+
}
|
|
1163
|
+
this.historyPopOccurred = false;
|
|
1164
|
+
// Fire the initial page and facets requests
|
|
1165
|
+
// await this.dataSource.handleQueryChange();
|
|
1166
|
+
}
|
|
1167
|
+
setupStateRestorationObserver() {
|
|
1168
|
+
if (!this.boundNavigationHandler) {
|
|
1169
|
+
this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
|
|
1170
|
+
}
|
|
1171
|
+
// when the user navigates back, we want to update the UI to match the URL
|
|
1172
|
+
window.addEventListener('popstate', this.boundNavigationHandler);
|
|
1173
|
+
}
|
|
1174
|
+
historyNavigationHandler() {
|
|
1175
|
+
this.historyPopOccurred = true;
|
|
1176
|
+
this.restoreState();
|
|
1177
|
+
}
|
|
1178
|
+
restoreState() {
|
|
1179
|
+
var _a, _b, _c, _d, _e;
|
|
1180
|
+
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
1181
|
+
this.displayMode = restorationState.displayMode;
|
|
1182
|
+
if (restorationState.searchType != null)
|
|
1183
|
+
this.searchType = restorationState.searchType;
|
|
1184
|
+
this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
|
|
1185
|
+
this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
|
|
1186
|
+
this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
|
|
1187
|
+
this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
|
|
1188
|
+
this.selectedFacets = restorationState.selectedFacets;
|
|
1189
|
+
if (!this.suppressURLQuery)
|
|
1190
|
+
this.baseQuery = restorationState.baseQuery;
|
|
1191
|
+
this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
|
|
1192
|
+
this.minSelectedDate = restorationState.minSelectedDate;
|
|
1193
|
+
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
1194
|
+
if (this.currentPage > 1) {
|
|
1195
|
+
this.goToPage(this.currentPage);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
persistState() {
|
|
1199
|
+
var _a, _b, _c, _d;
|
|
1200
|
+
const restorationState = {
|
|
1201
|
+
displayMode: this.displayMode,
|
|
1202
|
+
searchType: this.searchType,
|
|
1203
|
+
selectedSort: this.selectedSort,
|
|
1204
|
+
sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
|
|
1205
|
+
selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
|
|
1206
|
+
baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
|
|
1207
|
+
currentPage: this.currentPage,
|
|
1208
|
+
titleQuery: this.titleQuery,
|
|
1209
|
+
creatorQuery: this.creatorQuery,
|
|
1210
|
+
minSelectedDate: this.minSelectedDate,
|
|
1211
|
+
maxSelectedDate: this.maxSelectedDate,
|
|
1212
|
+
selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
|
|
1213
|
+
selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
|
|
1214
|
+
};
|
|
1215
|
+
this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
|
|
1216
|
+
}
|
|
1217
|
+
emitSearchResultsLoadingChanged() {
|
|
1218
|
+
this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
|
|
1219
|
+
detail: {
|
|
1220
|
+
loading: this.searchResultsLoading,
|
|
1221
|
+
},
|
|
1222
|
+
}));
|
|
1223
|
+
}
|
|
1224
|
+
facetsChanged(e) {
|
|
1225
|
+
this.selectedFacets = e.detail;
|
|
1226
|
+
}
|
|
1227
|
+
facetClickHandler({ detail: { facetType, bucket, negative }, }) {
|
|
1228
|
+
var _a;
|
|
1229
|
+
let action;
|
|
1230
|
+
if (negative) {
|
|
1231
|
+
action =
|
|
1232
|
+
bucket.state !== 'none'
|
|
1233
|
+
? analyticsActions.facetNegativeSelected
|
|
1234
|
+
: analyticsActions.facetNegativeDeselected;
|
|
1235
|
+
}
|
|
1236
|
+
else {
|
|
1237
|
+
action =
|
|
1238
|
+
bucket.state !== 'none'
|
|
1239
|
+
? analyticsActions.facetSelected
|
|
1240
|
+
: analyticsActions.facetDeselected;
|
|
1241
|
+
}
|
|
1242
|
+
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
1243
|
+
category: this.searchContext,
|
|
1244
|
+
action,
|
|
1245
|
+
label: facetType,
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
scrollToPage(pageNumber) {
|
|
1249
|
+
return new Promise(resolve => {
|
|
1250
|
+
const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
|
|
1251
|
+
// without this setTimeout, Safari just pauses until the `fetchPage` is complete
|
|
1252
|
+
// then scrolls to the cell
|
|
1253
|
+
setTimeout(() => {
|
|
1254
|
+
var _a;
|
|
1255
|
+
this.isScrollingToCell = true;
|
|
1256
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
|
|
1257
|
+
// This timeout is to give the scroll animation time to finish
|
|
1258
|
+
// then updating the infinite scroller once we're done scrolling
|
|
1259
|
+
// There's no scroll animation completion callback so we're
|
|
1260
|
+
// giving it 0.5s to finish.
|
|
1261
|
+
setTimeout(() => {
|
|
1262
|
+
var _a;
|
|
1263
|
+
this.isScrollingToCell = false;
|
|
1264
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
|
|
1265
|
+
resolve();
|
|
1266
|
+
}, 500);
|
|
1267
|
+
}, 0);
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
/**
|
|
1271
|
+
* Whether sorting by relevance makes sense for the current state.
|
|
1272
|
+
* Currently equivalent to having a non-empty query.
|
|
1273
|
+
*/
|
|
1274
|
+
get isRelevanceSortAvailable() {
|
|
1275
|
+
var _a;
|
|
1276
|
+
return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Sets the total number of tiles displayed in the infinite scroller.
|
|
1280
|
+
*/
|
|
1281
|
+
setTileCount(count) {
|
|
1282
|
+
if (this.infiniteScroller) {
|
|
1283
|
+
this.infiniteScroller.itemCount = count;
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
/**
|
|
1287
|
+
* Applies any default sort option for the current collection, by checking
|
|
1288
|
+
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
1289
|
+
* descending by:
|
|
1290
|
+
* - Date Favorited for fav-* collections
|
|
1291
|
+
* - Weekly views for all other collections
|
|
1292
|
+
*/
|
|
1293
|
+
applyDefaultCollectionSort(collectionInfo) {
|
|
1294
|
+
var _a, _b, _c;
|
|
1295
|
+
if (this.baseQuery) {
|
|
1296
|
+
// If there's a query set, then we default to relevance sorting regardless of
|
|
1297
|
+
// the collection metadata-specified sort.
|
|
1298
|
+
this.defaultSortField = SortField.relevance;
|
|
1299
|
+
this.defaultSortDirection = null;
|
|
1300
|
+
return;
|
|
1301
|
+
}
|
|
1302
|
+
// Favorite collections sort on Date Favorited by default.
|
|
1303
|
+
// Other collections fall back to sorting on weekly views.
|
|
1304
|
+
const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
|
|
1305
|
+
? '-favoritedate'
|
|
1306
|
+
: '-week';
|
|
1307
|
+
// The collection metadata may override the default sorting with something else
|
|
1308
|
+
const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
|
|
1309
|
+
// Prefer the metadata-specified sort if one exists
|
|
1310
|
+
const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
|
|
1311
|
+
// Account for both -field and field:dir formats
|
|
1312
|
+
let [field, dir] = defaultSortToApply.split(':');
|
|
1313
|
+
if (field.startsWith('-')) {
|
|
1314
|
+
field = field.slice(1);
|
|
1315
|
+
dir = 'desc';
|
|
1316
|
+
}
|
|
1317
|
+
else if (!['asc', 'desc'].includes(dir)) {
|
|
1318
|
+
dir = 'asc';
|
|
1319
|
+
}
|
|
1320
|
+
const sortOption = sortOptionFromAPIString(field);
|
|
1321
|
+
const sortField = sortOption.field;
|
|
1322
|
+
if (sortField && sortField !== SortField.default) {
|
|
1323
|
+
this.defaultSortField = sortField;
|
|
1324
|
+
this.defaultSortDirection = dir;
|
|
1325
|
+
this.defaultSortParam = {
|
|
1326
|
+
field: this.defaultSortField,
|
|
1327
|
+
direction: this.defaultSortDirection,
|
|
1328
|
+
};
|
|
1329
|
+
}
|
|
1330
|
+
}
|
|
1331
|
+
/**
|
|
1332
|
+
* Applies the default sort option for the current profile element
|
|
1333
|
+
*/
|
|
1334
|
+
applyDefaultProfileSort() {
|
|
1335
|
+
if (this.profileElement) {
|
|
1336
|
+
const defaultSortField = defaultProfileElementSorts[this.profileElement];
|
|
1337
|
+
this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
|
|
1338
|
+
}
|
|
1339
|
+
else {
|
|
1340
|
+
this.defaultSortField = SortField.weeklyview;
|
|
1341
|
+
}
|
|
1342
|
+
this.defaultSortDirection = 'desc';
|
|
1343
|
+
this.defaultSortParam = {
|
|
1344
|
+
field: this.defaultSortField,
|
|
1345
|
+
direction: this.defaultSortDirection,
|
|
1346
|
+
};
|
|
1347
|
+
}
|
|
1348
|
+
/**
|
|
1349
|
+
* This is useful for determining whether we need to reload the scroller.
|
|
1350
|
+
*
|
|
1351
|
+
* When the fetch completes, we need to reload the scroller if the cells for that
|
|
1352
|
+
* page are visible, but if the page is not currenlty visible, we don't need to reload
|
|
1353
|
+
*/
|
|
1354
|
+
get currentVisiblePageNumbers() {
|
|
1355
|
+
var _a, _b;
|
|
1356
|
+
const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
|
|
1357
|
+
const visiblePages = new Set();
|
|
1358
|
+
visibleCells.forEach(cellIndex => {
|
|
1359
|
+
const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
|
|
1360
|
+
visiblePages.add(visiblePage);
|
|
1361
|
+
});
|
|
1362
|
+
return Array.from(visiblePages);
|
|
1363
|
+
}
|
|
1364
|
+
/**
|
|
1365
|
+
* Refreshes all visible result cells in the infinite scroller.
|
|
1366
|
+
*/
|
|
1367
|
+
refreshVisibleResults() {
|
|
1368
|
+
var _a;
|
|
1369
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
|
|
1370
|
+
}
|
|
1371
|
+
/**
|
|
1372
|
+
* Callback when a result is selected
|
|
1373
|
+
*/
|
|
1374
|
+
resultSelected(event) {
|
|
1375
|
+
var _a, _b, _c;
|
|
1376
|
+
if (this.isManageView) {
|
|
1377
|
+
// Checked/unchecked state change -- rerender to ensure it propagates
|
|
1378
|
+
// this.mapDataSource(model => ({ ...model }));
|
|
1379
|
+
const cellIndex = this.dataSource.indexOf(event.detail);
|
|
1380
|
+
if (cellIndex >= 0)
|
|
1381
|
+
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
|
|
1382
|
+
this.requestUpdate();
|
|
1383
|
+
}
|
|
1384
|
+
(_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
|
|
1385
|
+
category: this.searchContext,
|
|
1386
|
+
action: analyticsActions.resultSelected,
|
|
1387
|
+
label: event.detail.mediatype,
|
|
1388
|
+
});
|
|
1389
|
+
(_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
|
|
1390
|
+
category: this.searchContext,
|
|
1391
|
+
action: analyticsActions.resultSelected,
|
|
1392
|
+
label: `page-${this.currentPage}`,
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
cellForIndex(index) {
|
|
1396
|
+
const model = this.tileModelAtCellIndex(index);
|
|
1397
|
+
if (!model)
|
|
1398
|
+
return undefined;
|
|
1388
1399
|
return html `
|
|
1389
1400
|
<tile-dispatcher
|
|
1390
1401
|
.collectionPagePath=${this.collectionPagePath}
|
|
@@ -1404,21 +1415,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1404
1415
|
@resultSelected=${(e) => this.resultSelected(e)}
|
|
1405
1416
|
>
|
|
1406
1417
|
</tile-dispatcher>
|
|
1407
|
-
`;
|
|
1408
|
-
}
|
|
1409
|
-
/**
|
|
1410
|
-
* When the user scrolls near to the bottom of the page, fetch the next page
|
|
1411
|
-
* increase the number of pages to render and start fetching data for the new page
|
|
1412
|
-
*/
|
|
1413
|
-
scrollThresholdReached() {
|
|
1414
|
-
if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
|
|
1415
|
-
this.pagesToRender += 1;
|
|
1416
|
-
this.dataSource.fetchPage(this.pagesToRender);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
static get styles() {
|
|
1420
|
-
return [
|
|
1421
|
-
srOnlyStyle,
|
|
1418
|
+
`;
|
|
1419
|
+
}
|
|
1420
|
+
/**
|
|
1421
|
+
* When the user scrolls near to the bottom of the page, fetch the next page
|
|
1422
|
+
* increase the number of pages to render and start fetching data for the new page
|
|
1423
|
+
*/
|
|
1424
|
+
scrollThresholdReached() {
|
|
1425
|
+
if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
|
|
1426
|
+
this.pagesToRender += 1;
|
|
1427
|
+
this.dataSource.fetchPage(this.pagesToRender);
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
static get styles() {
|
|
1431
|
+
return [
|
|
1432
|
+
srOnlyStyle,
|
|
1422
1433
|
css `
|
|
1423
1434
|
:host {
|
|
1424
1435
|
display: block;
|
|
@@ -1796,183 +1807,186 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1796
1807
|
infinite-scroller.hidden {
|
|
1797
1808
|
display: none;
|
|
1798
1809
|
}
|
|
1799
|
-
`,
|
|
1800
|
-
];
|
|
1801
|
-
}
|
|
1802
|
-
};
|
|
1803
|
-
__decorate([
|
|
1804
|
-
property({ type: String })
|
|
1805
|
-
], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
|
|
1806
|
-
__decorate([
|
|
1807
|
-
property({ type: String })
|
|
1808
|
-
], CollectionBrowser.prototype, "baseImageUrl", void 0);
|
|
1809
|
-
__decorate([
|
|
1810
|
-
property({ type: Object })
|
|
1811
|
-
], CollectionBrowser.prototype, "searchService", void 0);
|
|
1812
|
-
__decorate([
|
|
1813
|
-
property({ type: String })
|
|
1814
|
-
], CollectionBrowser.prototype, "searchType", void 0);
|
|
1815
|
-
__decorate([
|
|
1816
|
-
property({ type: String })
|
|
1817
|
-
], CollectionBrowser.prototype, "withinCollection", void 0);
|
|
1818
|
-
__decorate([
|
|
1819
|
-
property({ type: String })
|
|
1820
|
-
], CollectionBrowser.prototype, "withinProfile", void 0);
|
|
1821
|
-
__decorate([
|
|
1822
|
-
property({ type: String })
|
|
1823
|
-
], CollectionBrowser.prototype, "profileElement", void 0);
|
|
1824
|
-
__decorate([
|
|
1825
|
-
property({ type: String })
|
|
1826
|
-
], CollectionBrowser.prototype, "baseQuery", void 0);
|
|
1827
|
-
__decorate([
|
|
1828
|
-
property({ type: String })
|
|
1829
|
-
], CollectionBrowser.prototype, "displayMode", void 0);
|
|
1830
|
-
__decorate([
|
|
1831
|
-
property({ type: Object })
|
|
1832
|
-
], CollectionBrowser.prototype, "defaultSortParam", void 0);
|
|
1833
|
-
__decorate([
|
|
1834
|
-
property({ type: String })
|
|
1835
|
-
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
1836
|
-
__decorate([
|
|
1837
|
-
property({ type: String })
|
|
1838
|
-
], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
|
|
1839
|
-
__decorate([
|
|
1840
|
-
property({ type: String })
|
|
1841
|
-
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1842
|
-
__decorate([
|
|
1843
|
-
property({ type: String })
|
|
1844
|
-
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1845
|
-
__decorate([
|
|
1846
|
-
property({ type: Number })
|
|
1847
|
-
], CollectionBrowser.prototype, "pageSize", void 0);
|
|
1848
|
-
__decorate([
|
|
1849
|
-
property({ type: Number })
|
|
1850
|
-
], CollectionBrowser.prototype, "currentPage", void 0);
|
|
1851
|
-
__decorate([
|
|
1852
|
-
property({ type: String })
|
|
1853
|
-
], CollectionBrowser.prototype, "minSelectedDate", void 0);
|
|
1854
|
-
__decorate([
|
|
1855
|
-
property({ type: String })
|
|
1856
|
-
], CollectionBrowser.prototype, "maxSelectedDate", void 0);
|
|
1857
|
-
__decorate([
|
|
1858
|
-
property({ type: Object })
|
|
1859
|
-
], CollectionBrowser.prototype, "selectedFacets", void 0);
|
|
1860
|
-
__decorate([
|
|
1861
|
-
property({ type: Boolean })
|
|
1862
|
-
], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
|
|
1863
|
-
__decorate([
|
|
1864
|
-
property({ type: Boolean })
|
|
1865
|
-
], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
|
|
1866
|
-
__decorate([
|
|
1867
|
-
property({ type: Boolean })
|
|
1868
|
-
], CollectionBrowser.prototype, "suppressResultCount", void 0);
|
|
1869
|
-
__decorate([
|
|
1870
|
-
property({ type: Boolean })
|
|
1871
|
-
], CollectionBrowser.prototype, "suppressResultTiles", void 0);
|
|
1872
|
-
__decorate([
|
|
1873
|
-
property({ type: Boolean })
|
|
1874
|
-
], CollectionBrowser.prototype, "suppressURLQuery", void 0);
|
|
1875
|
-
__decorate([
|
|
1876
|
-
property({ type: Boolean })
|
|
1877
|
-
], CollectionBrowser.prototype, "suppressFacets", void 0);
|
|
1878
|
-
__decorate([
|
|
1879
|
-
property({ type: Boolean })
|
|
1880
|
-
], CollectionBrowser.prototype, "suppressSortBar", void 0);
|
|
1881
|
-
__decorate([
|
|
1882
|
-
property({ type: Boolean })
|
|
1883
|
-
], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
|
|
1884
|
-
__decorate([
|
|
1885
|
-
property({ type: Boolean })
|
|
1886
|
-
], CollectionBrowser.prototype, "
|
|
1887
|
-
__decorate([
|
|
1888
|
-
property({ type:
|
|
1889
|
-
], CollectionBrowser.prototype, "
|
|
1890
|
-
__decorate([
|
|
1891
|
-
property({ type: String
|
|
1892
|
-
], CollectionBrowser.prototype, "
|
|
1893
|
-
__decorate([
|
|
1894
|
-
property({ type: String })
|
|
1895
|
-
], CollectionBrowser.prototype, "
|
|
1896
|
-
__decorate([
|
|
1897
|
-
property({ type:
|
|
1898
|
-
], CollectionBrowser.prototype, "
|
|
1899
|
-
__decorate([
|
|
1900
|
-
property({ type:
|
|
1901
|
-
], CollectionBrowser.prototype, "
|
|
1902
|
-
__decorate([
|
|
1903
|
-
property({ type:
|
|
1904
|
-
], CollectionBrowser.prototype, "
|
|
1905
|
-
__decorate([
|
|
1906
|
-
property({ type:
|
|
1907
|
-
], CollectionBrowser.prototype, "
|
|
1908
|
-
__decorate([
|
|
1909
|
-
property({ type: Object })
|
|
1910
|
-
], CollectionBrowser.prototype, "
|
|
1911
|
-
__decorate([
|
|
1912
|
-
property({ type: Object })
|
|
1913
|
-
], CollectionBrowser.prototype, "
|
|
1914
|
-
__decorate([
|
|
1915
|
-
property({ type: Object })
|
|
1916
|
-
], CollectionBrowser.prototype, "
|
|
1917
|
-
__decorate([
|
|
1918
|
-
property({ type:
|
|
1919
|
-
], CollectionBrowser.prototype, "
|
|
1920
|
-
__decorate([
|
|
1921
|
-
property({ type:
|
|
1922
|
-
], CollectionBrowser.prototype, "
|
|
1923
|
-
__decorate([
|
|
1924
|
-
property({ type:
|
|
1925
|
-
], CollectionBrowser.prototype, "
|
|
1926
|
-
__decorate([
|
|
1927
|
-
property({ type:
|
|
1928
|
-
], CollectionBrowser.prototype, "
|
|
1929
|
-
__decorate([
|
|
1930
|
-
|
|
1931
|
-
], CollectionBrowser.prototype, "
|
|
1932
|
-
__decorate([
|
|
1933
|
-
state()
|
|
1934
|
-
], CollectionBrowser.prototype, "
|
|
1935
|
-
__decorate([
|
|
1936
|
-
state()
|
|
1937
|
-
], CollectionBrowser.prototype, "
|
|
1938
|
-
__decorate([
|
|
1939
|
-
state()
|
|
1940
|
-
], CollectionBrowser.prototype, "
|
|
1941
|
-
__decorate([
|
|
1942
|
-
state()
|
|
1943
|
-
], CollectionBrowser.prototype, "
|
|
1944
|
-
__decorate([
|
|
1945
|
-
state()
|
|
1946
|
-
], CollectionBrowser.prototype, "
|
|
1947
|
-
__decorate([
|
|
1948
|
-
state()
|
|
1949
|
-
], CollectionBrowser.prototype, "
|
|
1950
|
-
__decorate([
|
|
1951
|
-
state()
|
|
1952
|
-
], CollectionBrowser.prototype, "
|
|
1953
|
-
__decorate([
|
|
1954
|
-
state()
|
|
1955
|
-
], CollectionBrowser.prototype, "
|
|
1956
|
-
__decorate([
|
|
1957
|
-
state()
|
|
1958
|
-
], CollectionBrowser.prototype, "
|
|
1959
|
-
__decorate([
|
|
1960
|
-
|
|
1961
|
-
], CollectionBrowser.prototype, "
|
|
1962
|
-
__decorate([
|
|
1963
|
-
query('#
|
|
1964
|
-
], CollectionBrowser.prototype, "
|
|
1965
|
-
__decorate([
|
|
1966
|
-
query('
|
|
1967
|
-
], CollectionBrowser.prototype, "
|
|
1968
|
-
__decorate([
|
|
1969
|
-
|
|
1970
|
-
], CollectionBrowser.prototype, "
|
|
1971
|
-
__decorate([
|
|
1972
|
-
|
|
1973
|
-
], CollectionBrowser.prototype, "
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
], CollectionBrowser);
|
|
1977
|
-
|
|
1810
|
+
`,
|
|
1811
|
+
];
|
|
1812
|
+
}
|
|
1813
|
+
};
|
|
1814
|
+
__decorate([
|
|
1815
|
+
property({ type: String })
|
|
1816
|
+
], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
|
|
1817
|
+
__decorate([
|
|
1818
|
+
property({ type: String })
|
|
1819
|
+
], CollectionBrowser.prototype, "baseImageUrl", void 0);
|
|
1820
|
+
__decorate([
|
|
1821
|
+
property({ type: Object })
|
|
1822
|
+
], CollectionBrowser.prototype, "searchService", void 0);
|
|
1823
|
+
__decorate([
|
|
1824
|
+
property({ type: String })
|
|
1825
|
+
], CollectionBrowser.prototype, "searchType", void 0);
|
|
1826
|
+
__decorate([
|
|
1827
|
+
property({ type: String })
|
|
1828
|
+
], CollectionBrowser.prototype, "withinCollection", void 0);
|
|
1829
|
+
__decorate([
|
|
1830
|
+
property({ type: String })
|
|
1831
|
+
], CollectionBrowser.prototype, "withinProfile", void 0);
|
|
1832
|
+
__decorate([
|
|
1833
|
+
property({ type: String })
|
|
1834
|
+
], CollectionBrowser.prototype, "profileElement", void 0);
|
|
1835
|
+
__decorate([
|
|
1836
|
+
property({ type: String })
|
|
1837
|
+
], CollectionBrowser.prototype, "baseQuery", void 0);
|
|
1838
|
+
__decorate([
|
|
1839
|
+
property({ type: String })
|
|
1840
|
+
], CollectionBrowser.prototype, "displayMode", void 0);
|
|
1841
|
+
__decorate([
|
|
1842
|
+
property({ type: Object })
|
|
1843
|
+
], CollectionBrowser.prototype, "defaultSortParam", void 0);
|
|
1844
|
+
__decorate([
|
|
1845
|
+
property({ type: String })
|
|
1846
|
+
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
1847
|
+
__decorate([
|
|
1848
|
+
property({ type: String })
|
|
1849
|
+
], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
|
|
1850
|
+
__decorate([
|
|
1851
|
+
property({ type: String })
|
|
1852
|
+
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1853
|
+
__decorate([
|
|
1854
|
+
property({ type: String })
|
|
1855
|
+
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1856
|
+
__decorate([
|
|
1857
|
+
property({ type: Number })
|
|
1858
|
+
], CollectionBrowser.prototype, "pageSize", void 0);
|
|
1859
|
+
__decorate([
|
|
1860
|
+
property({ type: Number })
|
|
1861
|
+
], CollectionBrowser.prototype, "currentPage", void 0);
|
|
1862
|
+
__decorate([
|
|
1863
|
+
property({ type: String })
|
|
1864
|
+
], CollectionBrowser.prototype, "minSelectedDate", void 0);
|
|
1865
|
+
__decorate([
|
|
1866
|
+
property({ type: String })
|
|
1867
|
+
], CollectionBrowser.prototype, "maxSelectedDate", void 0);
|
|
1868
|
+
__decorate([
|
|
1869
|
+
property({ type: Object })
|
|
1870
|
+
], CollectionBrowser.prototype, "selectedFacets", void 0);
|
|
1871
|
+
__decorate([
|
|
1872
|
+
property({ type: Boolean })
|
|
1873
|
+
], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
|
|
1874
|
+
__decorate([
|
|
1875
|
+
property({ type: Boolean })
|
|
1876
|
+
], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
|
|
1877
|
+
__decorate([
|
|
1878
|
+
property({ type: Boolean })
|
|
1879
|
+
], CollectionBrowser.prototype, "suppressResultCount", void 0);
|
|
1880
|
+
__decorate([
|
|
1881
|
+
property({ type: Boolean })
|
|
1882
|
+
], CollectionBrowser.prototype, "suppressResultTiles", void 0);
|
|
1883
|
+
__decorate([
|
|
1884
|
+
property({ type: Boolean })
|
|
1885
|
+
], CollectionBrowser.prototype, "suppressURLQuery", void 0);
|
|
1886
|
+
__decorate([
|
|
1887
|
+
property({ type: Boolean })
|
|
1888
|
+
], CollectionBrowser.prototype, "suppressFacets", void 0);
|
|
1889
|
+
__decorate([
|
|
1890
|
+
property({ type: Boolean })
|
|
1891
|
+
], CollectionBrowser.prototype, "suppressSortBar", void 0);
|
|
1892
|
+
__decorate([
|
|
1893
|
+
property({ type: Boolean })
|
|
1894
|
+
], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
|
|
1895
|
+
__decorate([
|
|
1896
|
+
property({ type: Boolean })
|
|
1897
|
+
], CollectionBrowser.prototype, "lazyLoadFacets", void 0);
|
|
1898
|
+
__decorate([
|
|
1899
|
+
property({ type: Boolean })
|
|
1900
|
+
], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
|
|
1901
|
+
__decorate([
|
|
1902
|
+
property({ type: String })
|
|
1903
|
+
], CollectionBrowser.prototype, "collectionPagePath", void 0);
|
|
1904
|
+
__decorate([
|
|
1905
|
+
property({ type: String, reflect: true })
|
|
1906
|
+
], CollectionBrowser.prototype, "searchContext", void 0);
|
|
1907
|
+
__decorate([
|
|
1908
|
+
property({ type: String })
|
|
1909
|
+
], CollectionBrowser.prototype, "pageContext", void 0);
|
|
1910
|
+
__decorate([
|
|
1911
|
+
property({ type: Object })
|
|
1912
|
+
], CollectionBrowser.prototype, "restorationStateHandler", void 0);
|
|
1913
|
+
__decorate([
|
|
1914
|
+
property({ type: Number })
|
|
1915
|
+
], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
|
|
1916
|
+
__decorate([
|
|
1917
|
+
property({ type: Boolean })
|
|
1918
|
+
], CollectionBrowser.prototype, "loggedIn", void 0);
|
|
1919
|
+
__decorate([
|
|
1920
|
+
property({ type: Object })
|
|
1921
|
+
], CollectionBrowser.prototype, "resizeObserver", void 0);
|
|
1922
|
+
__decorate([
|
|
1923
|
+
property({ type: Object })
|
|
1924
|
+
], CollectionBrowser.prototype, "modalManager", void 0);
|
|
1925
|
+
__decorate([
|
|
1926
|
+
property({ type: Object })
|
|
1927
|
+
], CollectionBrowser.prototype, "featureFeedbackService", void 0);
|
|
1928
|
+
__decorate([
|
|
1929
|
+
property({ type: Object })
|
|
1930
|
+
], CollectionBrowser.prototype, "recaptchaManager", void 0);
|
|
1931
|
+
__decorate([
|
|
1932
|
+
property({ type: Boolean })
|
|
1933
|
+
], CollectionBrowser.prototype, "isManageView", void 0);
|
|
1934
|
+
__decorate([
|
|
1935
|
+
property({ type: String })
|
|
1936
|
+
], CollectionBrowser.prototype, "manageViewLabel", void 0);
|
|
1937
|
+
__decorate([
|
|
1938
|
+
property({ type: Boolean })
|
|
1939
|
+
], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
|
|
1940
|
+
__decorate([
|
|
1941
|
+
property({ type: Object })
|
|
1942
|
+
], CollectionBrowser.prototype, "dataSource", void 0);
|
|
1943
|
+
__decorate([
|
|
1944
|
+
state()
|
|
1945
|
+
], CollectionBrowser.prototype, "pagesToRender", void 0);
|
|
1946
|
+
__decorate([
|
|
1947
|
+
state()
|
|
1948
|
+
], CollectionBrowser.prototype, "searchResultsLoading", void 0);
|
|
1949
|
+
__decorate([
|
|
1950
|
+
state()
|
|
1951
|
+
], CollectionBrowser.prototype, "facetsLoading", void 0);
|
|
1952
|
+
__decorate([
|
|
1953
|
+
state()
|
|
1954
|
+
], CollectionBrowser.prototype, "totalResults", void 0);
|
|
1955
|
+
__decorate([
|
|
1956
|
+
state()
|
|
1957
|
+
], CollectionBrowser.prototype, "mobileView", void 0);
|
|
1958
|
+
__decorate([
|
|
1959
|
+
state()
|
|
1960
|
+
], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
|
|
1961
|
+
__decorate([
|
|
1962
|
+
state()
|
|
1963
|
+
], CollectionBrowser.prototype, "contentWidth", void 0);
|
|
1964
|
+
__decorate([
|
|
1965
|
+
state()
|
|
1966
|
+
], CollectionBrowser.prototype, "defaultSortField", void 0);
|
|
1967
|
+
__decorate([
|
|
1968
|
+
state()
|
|
1969
|
+
], CollectionBrowser.prototype, "defaultSortDirection", void 0);
|
|
1970
|
+
__decorate([
|
|
1971
|
+
state()
|
|
1972
|
+
], CollectionBrowser.prototype, "placeholderType", void 0);
|
|
1973
|
+
__decorate([
|
|
1974
|
+
query('#content-container')
|
|
1975
|
+
], CollectionBrowser.prototype, "contentContainer", void 0);
|
|
1976
|
+
__decorate([
|
|
1977
|
+
query('#left-column')
|
|
1978
|
+
], CollectionBrowser.prototype, "leftColumn", void 0);
|
|
1979
|
+
__decorate([
|
|
1980
|
+
query('collection-facets')
|
|
1981
|
+
], CollectionBrowser.prototype, "collectionFacets", void 0);
|
|
1982
|
+
__decorate([
|
|
1983
|
+
property({ type: Object, attribute: false })
|
|
1984
|
+
], CollectionBrowser.prototype, "analyticsHandler", void 0);
|
|
1985
|
+
__decorate([
|
|
1986
|
+
query('infinite-scroller')
|
|
1987
|
+
], CollectionBrowser.prototype, "infiniteScroller", void 0);
|
|
1988
|
+
CollectionBrowser = __decorate([
|
|
1989
|
+
customElement('collection-browser')
|
|
1990
|
+
], CollectionBrowser);
|
|
1991
|
+
export { CollectionBrowser };
|
|
1978
1992
|
//# sourceMappingURL=collection-browser.js.map
|