@internetarchive/collection-browser 1.10.1-alpha.3 → 1.10.1-alpha.5
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 +0 -1
- package/dist/src/collection-browser.js +12 -14
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/restoration-state-handler.js +0 -4
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/test/collection-browser.test.js +148 -0
- package/dist/test/collection-browser.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +16 -15
- package/src/restoration-state-handler.ts +0 -4
- package/test/collection-browser.test.ts +176 -0
|
@@ -241,7 +241,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
241
241
|
private get listHeaderTemplate();
|
|
242
242
|
private histogramDateRangeUpdated;
|
|
243
243
|
private get dateRangeQueryClause();
|
|
244
|
-
private restoringInitialState;
|
|
245
244
|
firstUpdated(): void;
|
|
246
245
|
updated(changed: PropertyValues): void;
|
|
247
246
|
disconnectedCallback(): void;
|
|
@@ -90,7 +90,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
90
90
|
* for the previous/next page, we'll fetch the next/previous page to populate it
|
|
91
91
|
*/
|
|
92
92
|
this.dataSource = {};
|
|
93
|
-
this.restoringInitialState = false;
|
|
94
93
|
/**
|
|
95
94
|
* Updates the height of the left column according to its position on the page.
|
|
96
95
|
* Arrow function ensures proper `this` binding.
|
|
@@ -203,7 +202,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
203
202
|
* in the options object.
|
|
204
203
|
*/
|
|
205
204
|
clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
|
|
206
|
-
console.log('clearFilters', facets);
|
|
207
205
|
// Don't bother clearing facets if none are checked, so that we don't
|
|
208
206
|
// trigger unnecessary update cycles.
|
|
209
207
|
if (facets && this.hasCheckedFacets) {
|
|
@@ -669,12 +667,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
669
667
|
firstUpdated() {
|
|
670
668
|
this.setupStateRestorationObserver();
|
|
671
669
|
this.restoreState();
|
|
672
|
-
this.restoringInitialState = true;
|
|
673
670
|
}
|
|
674
671
|
updated(changed) {
|
|
675
672
|
var _a;
|
|
676
|
-
console.log('--- UPDATED ---');
|
|
677
|
-
[...changed.entries()].forEach(([k, v]) => console.log(k, ':', v, '->', this[k]));
|
|
678
673
|
if (changed.has('placeholderType') && this.placeholderType === null) {
|
|
679
674
|
if (!this.leftColIntersectionObserver) {
|
|
680
675
|
this.setupLeftColumnScrollListeners();
|
|
@@ -690,15 +685,23 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
690
685
|
changed.has('loggedIn')) {
|
|
691
686
|
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
692
687
|
}
|
|
693
|
-
if (changed.has('baseQuery') ||
|
|
688
|
+
if (changed.has('baseQuery') ||
|
|
689
|
+
changed.has('searchType') ||
|
|
690
|
+
changed.has('withinCollection')) {
|
|
694
691
|
// Unless this query/search type update is from the initial page load or the
|
|
695
692
|
// result of hitting the back button,
|
|
696
693
|
// we need to clear any existing filters since they may no longer be valid for
|
|
697
694
|
// the new set of search results.
|
|
698
|
-
if (!this.historyPopOccurred && this.initialQueryChangeHappened
|
|
699
|
-
//
|
|
700
|
-
|
|
695
|
+
if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
|
|
696
|
+
// Ordinarily, we leave the sort param unchanged between searches.
|
|
697
|
+
// However, if we are changing the target collection itself, we want the sort cleared too,
|
|
698
|
+
// since different collections may have different sorting options available.
|
|
699
|
+
const shouldClearSort = changed.has('withinCollection') &&
|
|
700
|
+
!changed.has('selectedSort') &&
|
|
701
|
+
!changed.has('sortDirection');
|
|
702
|
+
// Otherwise, only clear filters that haven't been simultaneously applied in this update
|
|
701
703
|
this.clearFilters({
|
|
704
|
+
sort: shouldClearSort,
|
|
702
705
|
facets: !changed.has('selectedFacets'),
|
|
703
706
|
dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
|
|
704
707
|
letterFilters: !(changed.has('selectedTitleFilter') ||
|
|
@@ -706,7 +709,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
706
709
|
});
|
|
707
710
|
}
|
|
708
711
|
}
|
|
709
|
-
this.restoringInitialState = false;
|
|
710
712
|
if (changed.has('baseQuery')) {
|
|
711
713
|
this.emitBaseQueryChanged();
|
|
712
714
|
}
|
|
@@ -735,9 +737,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
735
737
|
if (changed.has('selectedCreatorFilter')) {
|
|
736
738
|
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
737
739
|
}
|
|
738
|
-
if (changed.has('withinCollection')) {
|
|
739
|
-
this.clearFilters({ sort: true });
|
|
740
|
-
}
|
|
741
740
|
if (changed.has('baseQuery') ||
|
|
742
741
|
changed.has('searchType') ||
|
|
743
742
|
changed.has('selectedTitleFilter') ||
|
|
@@ -893,7 +892,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
893
892
|
}
|
|
894
893
|
async handleQueryChange() {
|
|
895
894
|
var _a;
|
|
896
|
-
console.log('handling query change');
|
|
897
895
|
// only reset if the query has actually changed
|
|
898
896
|
if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
|
|
899
897
|
return;
|