@internetarchive/collection-browser 4.1.1-alpha-webdev8185.1 → 4.1.2-alpha1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +1 -1
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/collection-browser.d.ts +18 -9
- package/dist/src/collection-browser.js +81 -20
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +3 -2
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +3 -5
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/models.d.ts +2 -27
- package/dist/src/models.js +0 -36
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +9 -3
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +2 -2
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-browser.test.js +17 -15
- package/dist/test/collection-browser.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/index.ts +0 -5
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +120 -120
- package/renovate.json +6 -6
- package/src/collection-browser.ts +100 -27
- package/src/data-source/collection-browser-data-source.ts +3 -2
- package/src/data-source/collection-browser-query-state.ts +3 -12
- package/src/models.ts +4 -53
- package/src/restoration-state-handler.ts +7 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +4 -3
- package/test/collection-browser.test.ts +17 -15
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -52
package/README.md
CHANGED
|
@@ -1,84 +1,84 @@
|
|
|
1
|
-
 [](https://codecov.io/gh/internetarchive/iaux-collection-browser)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
# Internet Archive Collection Browser
|
|
5
|
-
|
|
6
|
-
This is the main collection browser for the Internet Archive website.
|
|
7
|
-
|
|
8
|
-
[Review app URL](https://internetarchive.github.io/iaux-collection-browser/main)
|
|
9
|
-
## Usage
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import '@internetarchive/collection-browser';
|
|
13
|
-
|
|
14
|
-
<collection-browser>
|
|
15
|
-
</collection-browser>
|
|
16
|
-
```
|
|
17
|
-
|
|
18
|
-
## Local Demo with `web-dev-server`
|
|
19
|
-
```bash
|
|
20
|
-
yarn install
|
|
21
|
-
yarn start
|
|
22
|
-
```
|
|
23
|
-
To run a local development server that serves the basic demo located in `index.html`
|
|
24
|
-
|
|
25
|
-
## Testing with Web Test Runner
|
|
26
|
-
To run the suite of Web Test Runner tests, run
|
|
27
|
-
```bash
|
|
28
|
-
yarn run test
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
To run the tests in watch mode (for <abbr title="test driven development">TDD</abbr>, for example), run
|
|
32
|
-
|
|
33
|
-
```bash
|
|
34
|
-
yarn run test:watch
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## Linting with ESLint, Prettier, and Types
|
|
38
|
-
To scan the project for linting errors, run
|
|
39
|
-
```bash
|
|
40
|
-
yarn run lint
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
You can lint with ESLint and Prettier individually as well
|
|
44
|
-
```bash
|
|
45
|
-
yarn run lint:eslint
|
|
46
|
-
```
|
|
47
|
-
```bash
|
|
48
|
-
yarn run lint:prettier
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
To automatically fix many linting errors, run
|
|
52
|
-
```bash
|
|
53
|
-
yarn run format
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
You can format using ESLint and Prettier individually as well
|
|
57
|
-
```bash
|
|
58
|
-
yarn run format:eslint
|
|
59
|
-
```
|
|
60
|
-
```bash
|
|
61
|
-
yarn run format:prettier
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
## Tooling configs
|
|
65
|
-
|
|
66
|
-
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
67
|
-
|
|
68
|
-
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
69
|
-
|
|
70
|
-
## Manual Deploy using `gh-pages`
|
|
71
|
-
|
|
72
|
-
Live demo app from current main branch: [https://internetarchive.github.io/iaux-collection-browser](https://internetarchive.github.io/iaux-collection-browser)
|
|
73
|
-
|
|
74
|
-
```
|
|
75
|
-
yarn run deploy
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## Automatic Deploy of Demo App
|
|
79
|
-
|
|
80
|
-
When you create a Pull Request, if your code passes codecov unit tests, it will be always served live at base url / pull request number. For this demo app, you must create a Pull Request, nothing will be created from a simple branch.
|
|
81
|
-
|
|
82
|
-
This URL will be removed when the Pull Request is merged/closed.
|
|
83
|
-
|
|
1
|
+
 [](https://codecov.io/gh/internetarchive/iaux-collection-browser)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
# Internet Archive Collection Browser
|
|
5
|
+
|
|
6
|
+
This is the main collection browser for the Internet Archive website.
|
|
7
|
+
|
|
8
|
+
[Review app URL](https://internetarchive.github.io/iaux-collection-browser/main)
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
import '@internetarchive/collection-browser';
|
|
13
|
+
|
|
14
|
+
<collection-browser>
|
|
15
|
+
</collection-browser>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Local Demo with `web-dev-server`
|
|
19
|
+
```bash
|
|
20
|
+
yarn install
|
|
21
|
+
yarn start
|
|
22
|
+
```
|
|
23
|
+
To run a local development server that serves the basic demo located in `index.html`
|
|
24
|
+
|
|
25
|
+
## Testing with Web Test Runner
|
|
26
|
+
To run the suite of Web Test Runner tests, run
|
|
27
|
+
```bash
|
|
28
|
+
yarn run test
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
To run the tests in watch mode (for <abbr title="test driven development">TDD</abbr>, for example), run
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
yarn run test:watch
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Linting with ESLint, Prettier, and Types
|
|
38
|
+
To scan the project for linting errors, run
|
|
39
|
+
```bash
|
|
40
|
+
yarn run lint
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
You can lint with ESLint and Prettier individually as well
|
|
44
|
+
```bash
|
|
45
|
+
yarn run lint:eslint
|
|
46
|
+
```
|
|
47
|
+
```bash
|
|
48
|
+
yarn run lint:prettier
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
To automatically fix many linting errors, run
|
|
52
|
+
```bash
|
|
53
|
+
yarn run format
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
You can format using ESLint and Prettier individually as well
|
|
57
|
+
```bash
|
|
58
|
+
yarn run format:eslint
|
|
59
|
+
```
|
|
60
|
+
```bash
|
|
61
|
+
yarn run format:prettier
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Tooling configs
|
|
65
|
+
|
|
66
|
+
For most of the tools, the configuration is in the `package.json` to reduce the amount of files in your project.
|
|
67
|
+
|
|
68
|
+
If you customize the configuration a lot, you can consider moving them to individual files.
|
|
69
|
+
|
|
70
|
+
## Manual Deploy using `gh-pages`
|
|
71
|
+
|
|
72
|
+
Live demo app from current main branch: [https://internetarchive.github.io/iaux-collection-browser](https://internetarchive.github.io/iaux-collection-browser)
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
yarn run deploy
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Automatic Deploy of Demo App
|
|
79
|
+
|
|
80
|
+
When you create a Pull Request, if your code passes codecov unit tests, it will be always served live at base url / pull request number. For this demo app, you must create a Pull Request, nothing will be created from a simple branch.
|
|
81
|
+
|
|
82
|
+
This URL will be removed when the Pull Request is merged/closed.
|
|
83
|
+
|
|
84
84
|
Example: `https://internetarchive.github.io/iaux-collection-browser/pr/<pr-number>`
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { CollectionBrowserDataSource } from './src/data-source/collection-browse
|
|
|
3
3
|
export { CollectionBrowserDataSourceInterface } from './src/data-source/collection-browser-data-source-interface';
|
|
4
4
|
export { CollectionBrowserQueryState } from './src/data-source/collection-browser-query-state';
|
|
5
5
|
export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
|
|
6
|
-
export { CollectionDisplayMode, SortField,
|
|
6
|
+
export { CollectionDisplayMode, SortField, TileModel, FacetOption, SelectedFacets, getDefaultSelectedFacets, } from './src/models';
|
|
7
7
|
export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
|
|
8
8
|
export { CollectionTile } from './src/tiles/grid/collection-tile';
|
|
9
9
|
export { AccountTile } from './src/tiles/grid/account-tile';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CollectionBrowser } from './src/collection-browser';
|
|
2
2
|
export { CollectionBrowserDataSource } from './src/data-source/collection-browser-data-source';
|
|
3
3
|
export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
|
|
4
|
-
export { SortField, TileModel, getDefaultSelectedFacets,
|
|
4
|
+
export { SortField, TileModel, getDefaultSelectedFacets, } from './src/models';
|
|
5
5
|
export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
|
|
6
6
|
export { CollectionTile } from './src/tiles/grid/collection-tile';
|
|
7
7
|
export { AccountTile } from './src/tiles/grid/account-tile';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAEL,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAEL,SAAS,EACT,SAAS,EAGT,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,cAAc,uDAAuD,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["export { CollectionBrowser } from './src/collection-browser';\nexport { CollectionBrowserDataSource } from './src/data-source/collection-browser-data-source';\nexport { CollectionBrowserDataSourceInterface } from './src/data-source/collection-browser-data-source-interface';\nexport { CollectionBrowserQueryState } from './src/data-source/collection-browser-query-state';\nexport { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';\nexport {\n CollectionDisplayMode,\n SortField,\n TileModel,\n FacetOption,\n SelectedFacets,\n getDefaultSelectedFacets,\n} from './src/models';\nexport { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';\nexport { CollectionTile } from './src/tiles/grid/collection-tile';\nexport { AccountTile } from './src/tiles/grid/account-tile';\nexport { ItemTile } from './src/tiles/grid/item-tile';\nexport { TileList } from './src/tiles/list/tile-list';\nexport { TileListCompact } from './src/tiles/list/tile-list-compact';\nexport { TileDispatcher } from './src/tiles/tile-dispatcher';\nexport { LayoutType } from './src/tiles/models';\nexport {\n SmartQueryHeuristic,\n KeywordFacetMap,\n SmartFacet,\n} from './src/collection-facets/smart-facets/models';\nexport * from './src/collection-facets/smart-facets/heuristics/index';\nexport { SmartQueryHeuristicGroup } from './src/collection-facets/smart-facets/smart-facet-heuristics';\n"]}
|
|
@@ -7,7 +7,7 @@ import '@internetarchive/infinite-scroller';
|
|
|
7
7
|
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
8
8
|
import type { FeatureFeedbackServiceInterface } from '@internetarchive/feature-feedback';
|
|
9
9
|
import type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';
|
|
10
|
-
import { SelectedFacets, SortField,
|
|
10
|
+
import { SelectedFacets, SortField, CollectionBrowserContext, TileModel, CollectionDisplayMode, FacetEventDetails, FacetLoadStrategy } from './models';
|
|
11
11
|
import { RestorationStateHandlerInterface } from './restoration-state-handler';
|
|
12
12
|
import type { CollectionBrowserQueryState, CollectionBrowserSearchInterface } from './data-source/collection-browser-query-state';
|
|
13
13
|
import type { CollectionBrowserDataSourceInterface } from './data-source/collection-browser-data-source-interface';
|
|
@@ -61,7 +61,7 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
61
61
|
selectedTitleFilter: string | null;
|
|
62
62
|
selectedCreatorFilter: string | null;
|
|
63
63
|
sortDirection: SortDirection | null;
|
|
64
|
-
defaultSortField:
|
|
64
|
+
defaultSortField: Exclude<SortField, SortField.default>;
|
|
65
65
|
defaultSortDirection: SortDirection | null;
|
|
66
66
|
pageSize: number;
|
|
67
67
|
currentPage?: number;
|
|
@@ -587,13 +587,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
587
587
|
* an error from the backend.
|
|
588
588
|
*/
|
|
589
589
|
emitSearchError(): void;
|
|
590
|
-
/**
|
|
591
|
-
* Emits a `collectionExtraInfoLoaded` event when the data source has received
|
|
592
|
-
* collection metadata from the backend. This allows parent components to react
|
|
593
|
-
* to the metadata (e.g., to update their default sort based on the collection's
|
|
594
|
-
* `sort-by` metadata field).
|
|
595
|
-
*/
|
|
596
|
-
emitCollectionExtraInfoLoaded(collectionExtraInfo?: CollectionExtraInfo): void;
|
|
597
590
|
/**
|
|
598
591
|
* Emits a `queryStateChanged` event indicating that one or more of this component's
|
|
599
592
|
* properties have changed in a way that could affect the set of search results.
|
|
@@ -659,6 +652,22 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
659
652
|
* Sets the total number of tiles displayed in the infinite scroller.
|
|
660
653
|
*/
|
|
661
654
|
setTileCount(count: number): void;
|
|
655
|
+
/**
|
|
656
|
+
* Applies the default sort options for the TV search results page
|
|
657
|
+
*/
|
|
658
|
+
applyDefaultTVSearchSort(): void;
|
|
659
|
+
/**
|
|
660
|
+
* Applies any default sort option for the current collection, by checking
|
|
661
|
+
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
662
|
+
* descending by:
|
|
663
|
+
* - Date Favorited for fav-* collections
|
|
664
|
+
* - Weekly views for all other collections
|
|
665
|
+
*/
|
|
666
|
+
applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
|
|
667
|
+
/**
|
|
668
|
+
* Applies the default sort option for the current profile element
|
|
669
|
+
*/
|
|
670
|
+
applyDefaultProfileSort(): void;
|
|
662
671
|
/**
|
|
663
672
|
* This is useful for determining whether we need to reload the scroller.
|
|
664
673
|
*
|
|
@@ -5,7 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
5
5
|
import { msg } from '@lit/localize';
|
|
6
6
|
import { SearchType, } from '@internetarchive/search-service';
|
|
7
7
|
import '@internetarchive/infinite-scroller';
|
|
8
|
-
import { SortField, getDefaultSelectedFacets, SORT_OPTIONS, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
|
|
8
|
+
import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
|
|
9
9
|
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
10
10
|
import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
|
|
11
11
|
import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
|
|
@@ -373,6 +373,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
373
373
|
}
|
|
374
374
|
willUpdate(changed) {
|
|
375
375
|
this.setPlaceholderType();
|
|
376
|
+
if (changed.has('searchType') && this.searchType === SearchType.TV) {
|
|
377
|
+
this.applyDefaultTVSearchSort();
|
|
378
|
+
}
|
|
376
379
|
}
|
|
377
380
|
render() {
|
|
378
381
|
return html `
|
|
@@ -610,8 +613,10 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
610
613
|
// Determine the set of sortable fields that should be shown in the sort bar
|
|
611
614
|
let sortFieldAvailability = defaultSortAvailability;
|
|
612
615
|
// We adjust the available sort options for a couple of special cases...
|
|
613
|
-
if (this.withinCollection?.startsWith('fav-')
|
|
614
|
-
|
|
616
|
+
if (this.withinCollection?.startsWith('fav-') ||
|
|
617
|
+
this.profileElement === 'favorites') {
|
|
618
|
+
// When viewing a fav- collection or the favorites profile tab,
|
|
619
|
+
// we include the Date Favorited option as the default
|
|
615
620
|
sortFieldAvailability = favoritesSortAvailability;
|
|
616
621
|
}
|
|
617
622
|
else if (!this.withinCollection && this.searchType === SearchType.TV) {
|
|
@@ -1271,12 +1276,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1271
1276
|
this.maxSelectedDate = queryState.maxSelectedDate;
|
|
1272
1277
|
this.selectedSort = queryState.selectedSort ?? SortField.default;
|
|
1273
1278
|
this.sortDirection = queryState.sortDirection;
|
|
1274
|
-
if (queryState.defaultSortField) {
|
|
1275
|
-
this.defaultSortField = queryState.defaultSortField;
|
|
1276
|
-
}
|
|
1277
|
-
if (queryState.defaultSortDirection !== undefined) {
|
|
1278
|
-
this.defaultSortDirection = queryState.defaultSortDirection;
|
|
1279
|
-
}
|
|
1280
1279
|
this.selectedTitleFilter = queryState.selectedTitleFilter;
|
|
1281
1280
|
this.selectedCreatorFilter = queryState.selectedCreatorFilter;
|
|
1282
1281
|
this.pagesToRender = this.initialPageNumber;
|
|
@@ -1365,6 +1364,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1365
1364
|
});
|
|
1366
1365
|
}
|
|
1367
1366
|
}
|
|
1367
|
+
if (changed.has('profileElement')) {
|
|
1368
|
+
this.applyDefaultProfileSort();
|
|
1369
|
+
}
|
|
1370
|
+
if (changed.has('withinCollection') && this.withinCollection) {
|
|
1371
|
+
// Set a sensible default collection sort while we load results, which we will later
|
|
1372
|
+
// adjust based on any sort-by metadata once the response arrives.
|
|
1373
|
+
if (!this.baseQuery) {
|
|
1374
|
+
this.defaultSortField = this.withinCollection.startsWith('fav-')
|
|
1375
|
+
? SortField.datefavorited
|
|
1376
|
+
: SortField.weeklyview;
|
|
1377
|
+
this.defaultSortDirection = 'desc';
|
|
1378
|
+
}
|
|
1379
|
+
}
|
|
1368
1380
|
if (changed.has('baseQuery')) {
|
|
1369
1381
|
this.emitBaseQueryChanged();
|
|
1370
1382
|
}
|
|
@@ -1579,17 +1591,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1579
1591
|
detail: this.dataSource.queryErrorMessage,
|
|
1580
1592
|
}));
|
|
1581
1593
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Emits a `collectionExtraInfoLoaded` event when the data source has received
|
|
1584
|
-
* collection metadata from the backend. This allows parent components to react
|
|
1585
|
-
* to the metadata (e.g., to update their default sort based on the collection's
|
|
1586
|
-
* `sort-by` metadata field).
|
|
1587
|
-
*/
|
|
1588
|
-
emitCollectionExtraInfoLoaded(collectionExtraInfo) {
|
|
1589
|
-
this.dispatchEvent(new CustomEvent('collectionExtraInfoLoaded', {
|
|
1590
|
-
detail: collectionExtraInfo,
|
|
1591
|
-
}));
|
|
1592
|
-
}
|
|
1593
1594
|
/**
|
|
1594
1595
|
* Emits a `queryStateChanged` event indicating that one or more of this component's
|
|
1595
1596
|
* properties have changed in a way that could affect the set of search results.
|
|
@@ -1843,6 +1844,66 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1843
1844
|
this.infiniteScroller.itemCount = count;
|
|
1844
1845
|
}
|
|
1845
1846
|
}
|
|
1847
|
+
/**
|
|
1848
|
+
* Applies the default sort options for the TV search results page
|
|
1849
|
+
*/
|
|
1850
|
+
applyDefaultTVSearchSort() {
|
|
1851
|
+
this.defaultSortField = SortField.datearchived;
|
|
1852
|
+
this.defaultSortDirection = 'desc';
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Applies any default sort option for the current collection, by checking
|
|
1856
|
+
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
1857
|
+
* descending by:
|
|
1858
|
+
* - Date Favorited for fav-* collections
|
|
1859
|
+
* - Weekly views for all other collections
|
|
1860
|
+
*/
|
|
1861
|
+
applyDefaultCollectionSort(collectionInfo) {
|
|
1862
|
+
if (this.baseQuery) {
|
|
1863
|
+
// If there's a query set, then we default to relevance sorting regardless of
|
|
1864
|
+
// the collection metadata-specified sort.
|
|
1865
|
+
this.defaultSortField = SortField.relevance;
|
|
1866
|
+
this.defaultSortDirection = null;
|
|
1867
|
+
return;
|
|
1868
|
+
}
|
|
1869
|
+
// Favorite collections sort on Date Favorited by default.
|
|
1870
|
+
// Other collections fall back to sorting on weekly views.
|
|
1871
|
+
const baseDefaultSort = collectionInfo?.public_metadata?.identifier?.startsWith('fav-')
|
|
1872
|
+
? '-favoritedate'
|
|
1873
|
+
: '-week';
|
|
1874
|
+
// The collection metadata may override the default sorting with something else
|
|
1875
|
+
const metadataSort = collectionInfo?.public_metadata?.['sort-by'];
|
|
1876
|
+
// Prefer the metadata-specified sort if one exists
|
|
1877
|
+
const defaultSortToApply = metadataSort ?? baseDefaultSort;
|
|
1878
|
+
// Account for both -field and field:dir formats
|
|
1879
|
+
let [field, dir] = defaultSortToApply.split(':');
|
|
1880
|
+
if (field.startsWith('-')) {
|
|
1881
|
+
field = field.slice(1);
|
|
1882
|
+
dir = 'desc';
|
|
1883
|
+
}
|
|
1884
|
+
else if (!['asc', 'desc'].includes(dir)) {
|
|
1885
|
+
dir = 'asc';
|
|
1886
|
+
}
|
|
1887
|
+
const sortOption = sortOptionFromAPIString(field);
|
|
1888
|
+
const sortField = sortOption.field;
|
|
1889
|
+
if (sortField && sortField !== SortField.default) {
|
|
1890
|
+
this.defaultSortField = sortField;
|
|
1891
|
+
this.defaultSortDirection = dir;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Applies the default sort option for the current profile element
|
|
1896
|
+
*/
|
|
1897
|
+
applyDefaultProfileSort() {
|
|
1898
|
+
if (this.profileElement) {
|
|
1899
|
+
const defaultSortField = defaultProfileElementSorts[this.profileElement];
|
|
1900
|
+
this.defaultSortField = defaultSortField ?? SortField.weeklyview;
|
|
1901
|
+
}
|
|
1902
|
+
else {
|
|
1903
|
+
this.defaultSortField = SortField.weeklyview;
|
|
1904
|
+
}
|
|
1905
|
+
this.defaultSortDirection = 'desc';
|
|
1906
|
+
}
|
|
1846
1907
|
/**
|
|
1847
1908
|
* This is useful for determining whether we need to reload the scroller.
|
|
1848
1909
|
*
|