@internetarchive/collection-browser 1.8.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 +17 -11
- package/dist/src/collection-browser.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/restoration-state-handler.test.js +53 -1
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +15 -8
- 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/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 };
|
|
@@ -953,22 +959,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
953
959
|
}
|
|
954
960
|
}
|
|
955
961
|
persistState() {
|
|
956
|
-
var _a, _b, _c, _d
|
|
962
|
+
var _a, _b, _c, _d;
|
|
957
963
|
const restorationState = {
|
|
958
964
|
displayMode: this.displayMode,
|
|
959
965
|
searchType: this.searchType,
|
|
960
|
-
sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
|
|
961
966
|
selectedSort: this.selectedSort,
|
|
962
|
-
sortDirection: (
|
|
963
|
-
selectedFacets: (
|
|
967
|
+
sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
|
|
968
|
+
selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
|
|
964
969
|
baseQuery: this.baseQuery,
|
|
965
970
|
currentPage: this.currentPage,
|
|
966
971
|
titleQuery: this.titleQuery,
|
|
967
972
|
creatorQuery: this.creatorQuery,
|
|
968
973
|
minSelectedDate: this.minSelectedDate,
|
|
969
974
|
maxSelectedDate: this.maxSelectedDate,
|
|
970
|
-
selectedTitleFilter: (
|
|
971
|
-
selectedCreatorFilter: (
|
|
975
|
+
selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
|
|
976
|
+
selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
|
|
972
977
|
};
|
|
973
978
|
this.restorationStateHandler.persistState(restorationState);
|
|
974
979
|
}
|
|
@@ -1429,7 +1434,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1429
1434
|
else if (!['asc', 'desc'].includes(dir)) {
|
|
1430
1435
|
dir = 'asc';
|
|
1431
1436
|
}
|
|
1432
|
-
const
|
|
1437
|
+
const sortOption = sortOptionFromAPIString(field);
|
|
1438
|
+
const sortField = sortOption.field;
|
|
1433
1439
|
if (sortField && sortField !== SortField.default) {
|
|
1434
1440
|
this.defaultSortField = sortField;
|
|
1435
1441
|
this.defaultSortDirection = dir;
|