@internetarchive/collection-browser 0.4.3-alpha.1 → 0.4.3-alpha.2
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.d.ts +4 -4
- package/dist/src/collection-browser.js +28 -29
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/restoration-state-handler.js +13 -14
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +1 -0
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/utils/array-equals.d.ts +4 -0
- package/dist/src/utils/array-equals.js +11 -0
- package/dist/src/utils/array-equals.js.map +1 -0
- package/dist/test/collection-browser.test.js +7 -7
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/utils/array-equals.test.d.ts +1 -0
- package/dist/test/utils/array-equals.test.js +27 -0
- package/dist/test/utils/array-equals.test.js.map +1 -0
- package/package.json +1 -1
- package/src/collection-browser.ts +46 -31
- package/src/restoration-state-handler.ts +20 -13
- package/src/sort-filter-bar/sort-filter-bar.ts +1 -0
- package/src/utils/array-equals.ts +8 -0
- package/test/collection-browser.test.ts +7 -7
- package/test/utils/array-equals.test.ts +31 -0
|
@@ -21,11 +21,11 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
21
21
|
searchType: SearchType;
|
|
22
22
|
baseQuery?: string;
|
|
23
23
|
displayMode?: CollectionDisplayMode;
|
|
24
|
-
sortParam
|
|
24
|
+
sortParam?: SortParam;
|
|
25
|
+
sortDirection?: SortDirection;
|
|
25
26
|
selectedSort: SortField;
|
|
26
|
-
selectedTitleFilter
|
|
27
|
-
selectedCreatorFilter
|
|
28
|
-
sortDirection: SortDirection | null;
|
|
27
|
+
selectedTitleFilter?: string;
|
|
28
|
+
selectedCreatorFilter?: string;
|
|
29
29
|
pageSize: number;
|
|
30
30
|
resizeObserver?: SharedResizeObserverInterface;
|
|
31
31
|
titleQuery?: string;
|
|
@@ -22,11 +22,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
22
22
|
super(...arguments);
|
|
23
23
|
this.baseImageUrl = 'https://archive.org';
|
|
24
24
|
this.searchType = SearchType.METADATA;
|
|
25
|
-
this.sortParam = null;
|
|
26
25
|
this.selectedSort = SortField.relevance;
|
|
27
|
-
this.selectedTitleFilter = null;
|
|
28
|
-
this.selectedCreatorFilter = null;
|
|
29
|
-
this.sortDirection = null;
|
|
30
26
|
this.pageSize = 50;
|
|
31
27
|
this.showHistogramDatePicker = false;
|
|
32
28
|
/** describes where this component is being used */
|
|
@@ -137,19 +133,20 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
137
133
|
}
|
|
138
134
|
clearFilters() {
|
|
139
135
|
this.selectedFacets = defaultSelectedFacets;
|
|
140
|
-
this.sortParam =
|
|
141
|
-
this.
|
|
142
|
-
this.
|
|
136
|
+
this.sortParam = undefined;
|
|
137
|
+
this.sortDirection = undefined;
|
|
138
|
+
this.selectedTitleFilter = undefined;
|
|
139
|
+
this.selectedCreatorFilter = undefined;
|
|
143
140
|
this.titleQuery = undefined;
|
|
144
141
|
this.creatorQuery = undefined;
|
|
145
142
|
this.selectedSort = SortField.relevance;
|
|
146
|
-
this.sortDirection = null;
|
|
147
143
|
}
|
|
148
144
|
/**
|
|
149
145
|
* Manually requests to perform a search, which will only be executed if one of
|
|
150
146
|
* the query, the search type, or the sort has changed.
|
|
151
147
|
*/
|
|
152
148
|
requestSearch() {
|
|
149
|
+
console.log('handling query change by request');
|
|
153
150
|
this.handleQueryChange();
|
|
154
151
|
}
|
|
155
152
|
render() {
|
|
@@ -267,14 +264,17 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
267
264
|
});
|
|
268
265
|
}
|
|
269
266
|
selectedSortChanged() {
|
|
270
|
-
if (this.selectedSort === 'relevance'
|
|
271
|
-
this.sortParam =
|
|
267
|
+
if (this.selectedSort === 'relevance') {
|
|
268
|
+
this.sortParam = undefined;
|
|
272
269
|
return;
|
|
273
270
|
}
|
|
274
271
|
const sortField = SortFieldToMetadataField[this.selectedSort];
|
|
272
|
+
if (!this.sortDirection)
|
|
273
|
+
this.sortDirection = 'desc';
|
|
275
274
|
if (!sortField)
|
|
276
275
|
return;
|
|
277
276
|
this.sortParam = { field: sortField, direction: this.sortDirection };
|
|
277
|
+
this.requestUpdate();
|
|
278
278
|
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
279
279
|
this.updatePrefixFiltersForCurrentSort();
|
|
280
280
|
}
|
|
@@ -297,7 +297,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
297
297
|
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
|
-
const cleared = prevSelectedLetter && this.selectedTitleFilter
|
|
300
|
+
const cleared = prevSelectedLetter && !this.selectedTitleFilter;
|
|
301
301
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
302
302
|
category: this.searchContext,
|
|
303
303
|
action: analyticsActions.filterByTitle,
|
|
@@ -319,7 +319,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
319
319
|
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
const cleared = prevSelectedLetter && this.selectedCreatorFilter
|
|
322
|
+
const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
|
|
323
323
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
324
324
|
category: this.searchContext,
|
|
325
325
|
action: analyticsActions.filterByCreator,
|
|
@@ -334,11 +334,11 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
334
334
|
: undefined;
|
|
335
335
|
}
|
|
336
336
|
titleLetterSelected(e) {
|
|
337
|
-
this.selectedCreatorFilter =
|
|
337
|
+
this.selectedCreatorFilter = undefined;
|
|
338
338
|
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
339
339
|
}
|
|
340
340
|
creatorLetterSelected(e) {
|
|
341
|
-
this.selectedTitleFilter =
|
|
341
|
+
this.selectedTitleFilter = undefined;
|
|
342
342
|
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
343
343
|
}
|
|
344
344
|
get facetDataLoading() {
|
|
@@ -445,15 +445,15 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
445
445
|
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
446
446
|
}
|
|
447
447
|
if (changed.has('baseQuery')) {
|
|
448
|
-
console.log('base query changed', changed.get('baseQuery'));
|
|
448
|
+
console.log('base query changed', changed.get('baseQuery'), this.baseQuery);
|
|
449
449
|
this.emitBaseQueryChanged();
|
|
450
450
|
}
|
|
451
451
|
if (changed.has('searchType')) {
|
|
452
|
-
console.log('search type changed', changed.get('searchType'));
|
|
452
|
+
console.log('search type changed', changed.get('searchType'), this.searchType);
|
|
453
453
|
this.emitSearchTypeChanged();
|
|
454
454
|
}
|
|
455
455
|
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
456
|
-
console.log('current page or display mode changed', changed.get('currentPage'), changed.get('displayMode'));
|
|
456
|
+
console.log('current page or display mode changed', changed.get('currentPage'), this.currentPage, changed.get('displayMode'), this.displayMode);
|
|
457
457
|
this.persistState();
|
|
458
458
|
}
|
|
459
459
|
if (changed.has('baseQuery') ||
|
|
@@ -462,9 +462,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
462
462
|
changed.has('minSelectedDate') ||
|
|
463
463
|
changed.has('maxSelectedDate') ||
|
|
464
464
|
changed.has('sortParam') ||
|
|
465
|
-
changed.has('selectedFacets')
|
|
466
|
-
|
|
467
|
-
console.log('handling query change', changed);
|
|
465
|
+
changed.has('selectedFacets')) {
|
|
466
|
+
console.log('handling query change', changed, this.baseQuery, this.sortParam);
|
|
468
467
|
this.handleQueryChange();
|
|
469
468
|
}
|
|
470
469
|
if (changed.has('baseQuery') ||
|
|
@@ -613,21 +612,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
613
612
|
this.restoreState();
|
|
614
613
|
}
|
|
615
614
|
restoreState() {
|
|
616
|
-
var _a, _b
|
|
615
|
+
var _a, _b;
|
|
617
616
|
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
618
617
|
this.displayMode = restorationState.displayMode;
|
|
619
618
|
if (restorationState.searchType != null)
|
|
620
619
|
this.searchType = restorationState.searchType;
|
|
621
620
|
this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
|
|
622
|
-
this.sortDirection =
|
|
623
|
-
this.selectedTitleFilter =
|
|
624
|
-
this.selectedCreatorFilter =
|
|
621
|
+
this.sortDirection = restorationState.sortDirection;
|
|
622
|
+
this.selectedTitleFilter = restorationState.selectedTitleFilter;
|
|
623
|
+
this.selectedCreatorFilter = restorationState.selectedCreatorFilter;
|
|
625
624
|
this.selectedFacets = restorationState.selectedFacets;
|
|
626
625
|
this.baseQuery = restorationState.baseQuery;
|
|
627
626
|
this.titleQuery = restorationState.titleQuery;
|
|
628
627
|
this.creatorQuery = restorationState.creatorQuery;
|
|
629
|
-
this.sortParam =
|
|
630
|
-
this.currentPage = (
|
|
628
|
+
this.sortParam = restorationState.sortParam;
|
|
629
|
+
this.currentPage = (_b = restorationState.currentPage) !== null && _b !== void 0 ? _b : 1;
|
|
631
630
|
this.minSelectedDate = restorationState.minSelectedDate;
|
|
632
631
|
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
633
632
|
if (this.currentPage > 1) {
|
|
@@ -1495,6 +1494,9 @@ __decorate([
|
|
|
1495
1494
|
__decorate([
|
|
1496
1495
|
property({ type: Object })
|
|
1497
1496
|
], CollectionBrowser.prototype, "sortParam", void 0);
|
|
1497
|
+
__decorate([
|
|
1498
|
+
property({ type: String })
|
|
1499
|
+
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1498
1500
|
__decorate([
|
|
1499
1501
|
property({ type: String })
|
|
1500
1502
|
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
@@ -1504,9 +1506,6 @@ __decorate([
|
|
|
1504
1506
|
__decorate([
|
|
1505
1507
|
property({ type: String })
|
|
1506
1508
|
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1507
|
-
__decorate([
|
|
1508
|
-
property({ type: String })
|
|
1509
|
-
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1510
1509
|
__decorate([
|
|
1511
1510
|
property({ type: Number })
|
|
1512
1511
|
], CollectionBrowser.prototype, "pageSize", void 0);
|