@internetarchive/collection-browser 1.7.1-alpha.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/collection-browser.js +18 -11
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +1 -0
- package/dist/src/collection-facets/more-facets-content.js +9 -2
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets.d.ts +1 -0
- package/dist/src/collection-facets.js +4 -0
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/models.d.ts +48 -35
- package/dist/src/models.js +139 -78
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +9 -2
- package/dist/src/restoration-state-handler.js +61 -32
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +2 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js +30 -25
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +25 -0
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +53 -1
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +3 -3
- package/src/collection-browser.ts +16 -8
- package/src/collection-facets/more-facets-content.ts +9 -2
- package/src/collection-facets.ts +3 -0
- package/src/models.ts +193 -109
- package/src/restoration-state-handler.ts +66 -40
- package/src/sort-filter-bar/sort-filter-bar.ts +34 -27
- package/test/collection-facets/more-facets-content.test.ts +35 -0
- package/test/restoration-state-handler.test.ts +68 -1
|
@@ -11,7 +11,7 @@ import './sort-filter-bar/sort-filter-bar';
|
|
|
11
11
|
import './collection-facets';
|
|
12
12
|
import './circular-activity-indicator';
|
|
13
13
|
import './sort-filter-bar/sort-filter-bar';
|
|
14
|
-
import { SortField,
|
|
14
|
+
import { SortField, getDefaultSelectedFacets, prefixFilterAggregationKeys, sortOptionFromAPIString, SORT_OPTIONS, } from './models';
|
|
15
15
|
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
16
16
|
import chevronIcon from './assets/img/icons/chevron';
|
|
17
17
|
import './empty-placeholder';
|
|
@@ -442,13 +442,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
selectedSortChanged() {
|
|
445
|
-
|
|
445
|
+
var _a;
|
|
446
|
+
const sortOption = SORT_OPTIONS[this.selectedSort];
|
|
447
|
+
if (!sortOption.handledBySearchService) {
|
|
446
448
|
this.sortParam = null;
|
|
447
449
|
return;
|
|
448
450
|
}
|
|
449
|
-
|
|
451
|
+
// If the sort option specified in the URL is unrecognized, we just use it as-is
|
|
452
|
+
const urlSortParam = new URL(window.location.href).searchParams.get('sort');
|
|
453
|
+
const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
|
|
454
|
+
// If the sort direction is still null at this point, then we assume ascending
|
|
455
|
+
// (i.e., it was unrecognized and had no directional flag)
|
|
450
456
|
if (!this.sortDirection)
|
|
451
|
-
this.sortDirection = '
|
|
457
|
+
this.sortDirection = 'asc';
|
|
452
458
|
if (!sortField)
|
|
453
459
|
return;
|
|
454
460
|
this.sortParam = { field: sortField, direction: this.sortDirection };
|
|
@@ -567,6 +573,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
567
573
|
@facetsChanged=${this.facetsChanged}
|
|
568
574
|
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
569
575
|
.collectionPagePath=${this.collectionPagePath}
|
|
576
|
+
.withinCollection=${this.withinCollection}
|
|
570
577
|
.searchService=${this.searchService}
|
|
571
578
|
.featureFeedbackService=${this.featureFeedbackService}
|
|
572
579
|
.recaptchaManager=${this.recaptchaManager}
|
|
@@ -952,22 +959,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
952
959
|
}
|
|
953
960
|
}
|
|
954
961
|
persistState() {
|
|
955
|
-
var _a, _b, _c, _d
|
|
962
|
+
var _a, _b, _c, _d;
|
|
956
963
|
const restorationState = {
|
|
957
964
|
displayMode: this.displayMode,
|
|
958
965
|
searchType: this.searchType,
|
|
959
|
-
sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
|
|
960
966
|
selectedSort: this.selectedSort,
|
|
961
|
-
sortDirection: (
|
|
962
|
-
selectedFacets: (
|
|
967
|
+
sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
|
|
968
|
+
selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
|
|
963
969
|
baseQuery: this.baseQuery,
|
|
964
970
|
currentPage: this.currentPage,
|
|
965
971
|
titleQuery: this.titleQuery,
|
|
966
972
|
creatorQuery: this.creatorQuery,
|
|
967
973
|
minSelectedDate: this.minSelectedDate,
|
|
968
974
|
maxSelectedDate: this.maxSelectedDate,
|
|
969
|
-
selectedTitleFilter: (
|
|
970
|
-
selectedCreatorFilter: (
|
|
975
|
+
selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
|
|
976
|
+
selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
|
|
971
977
|
};
|
|
972
978
|
this.restorationStateHandler.persistState(restorationState);
|
|
973
979
|
}
|
|
@@ -1428,7 +1434,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1428
1434
|
else if (!['asc', 'desc'].includes(dir)) {
|
|
1429
1435
|
dir = 'asc';
|
|
1430
1436
|
}
|
|
1431
|
-
const
|
|
1437
|
+
const sortOption = sortOptionFromAPIString(field);
|
|
1438
|
+
const sortField = sortOption.field;
|
|
1432
1439
|
if (sortField && sortField !== SortField.default) {
|
|
1433
1440
|
this.defaultSortField = sortField;
|
|
1434
1441
|
this.defaultSortDirection = dir;
|