@internetarchive/collection-browser 2.12.0 → 2.12.1-alpha-webdev5427.1
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/app-root.d.ts +1 -0
- package/dist/src/app-root.js +48 -2
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.js +9 -1
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +3 -3
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +4 -3
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets.d.ts +3 -1
- package/dist/src/collection-facets.js +22 -4
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/models.d.ts +14 -4
- package/dist/src/models.js +34 -3
- package/dist/src/models.js.map +1 -1
- package/dist/src/utils/facet-utils.js +8 -2
- package/dist/src/utils/facet-utils.js.map +1 -1
- package/dist/test/collection-facets.test.js +27 -0
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/restoration-state-handler.test.js +17 -10
- package/dist/test/restoration-state-handler.test.js.map +1 -1
- package/package.json +1 -1
- package/src/app-root.ts +49 -2
- package/src/collection-browser.ts +12 -0
- package/src/collection-facets/more-facets-content.ts +5 -4
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +2 -2
- package/src/collection-facets.ts +20 -5
- package/src/models.ts +43 -8
- package/src/utils/facet-utils.ts +5 -3
- package/test/collection-facets.test.ts +33 -0
- package/test/restoration-state-handler.test.ts +10 -10
package/src/app-root.ts
CHANGED
|
@@ -169,6 +169,17 @@ export class AppRoot extends LitElement {
|
|
|
169
169
|
|
|
170
170
|
<div id="search-types">
|
|
171
171
|
Search type:
|
|
172
|
+
<span class="search-type">
|
|
173
|
+
<input
|
|
174
|
+
type="radio"
|
|
175
|
+
id="default-search"
|
|
176
|
+
name="search-type"
|
|
177
|
+
value="default"
|
|
178
|
+
.checked=${this.searchType === SearchType.DEFAULT}
|
|
179
|
+
@click=${this.searchTypeSelected}
|
|
180
|
+
/>
|
|
181
|
+
<label for="default-search">Default</label>
|
|
182
|
+
</span>
|
|
172
183
|
<span class="search-type">
|
|
173
184
|
<input
|
|
174
185
|
type="radio"
|
|
@@ -191,6 +202,28 @@ export class AppRoot extends LitElement {
|
|
|
191
202
|
/>
|
|
192
203
|
<label for="fulltext-search">Full text</label>
|
|
193
204
|
</span>
|
|
205
|
+
<span class="search-type">
|
|
206
|
+
<input
|
|
207
|
+
type="radio"
|
|
208
|
+
id="tv-search"
|
|
209
|
+
name="search-type"
|
|
210
|
+
value="tv"
|
|
211
|
+
.checked=${this.searchType === SearchType.TV}
|
|
212
|
+
@click=${this.searchTypeSelected}
|
|
213
|
+
/>
|
|
214
|
+
<label for="tv-search">TV</label>
|
|
215
|
+
</span>
|
|
216
|
+
<span class="search-type">
|
|
217
|
+
<input
|
|
218
|
+
type="radio"
|
|
219
|
+
id="radio-search"
|
|
220
|
+
name="search-type"
|
|
221
|
+
value="radio"
|
|
222
|
+
.checked=${this.searchType === SearchType.RADIO}
|
|
223
|
+
@click=${this.searchTypeSelected}
|
|
224
|
+
/>
|
|
225
|
+
<label for="radio-search">Radio</label>
|
|
226
|
+
</span>
|
|
194
227
|
</div>
|
|
195
228
|
|
|
196
229
|
<div id="toggle-controls">
|
|
@@ -529,8 +562,22 @@ export class AppRoot extends LitElement {
|
|
|
529
562
|
/** Handler for user input selecting a search type */
|
|
530
563
|
private searchTypeSelected(e: Event) {
|
|
531
564
|
const target = e.target as HTMLInputElement;
|
|
532
|
-
this.searchType =
|
|
533
|
-
|
|
565
|
+
this.searchType = this.searchTypeFromSelectedOption(target.value);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
private searchTypeFromSelectedOption(option: string): SearchType {
|
|
569
|
+
switch (option) {
|
|
570
|
+
case 'metadata':
|
|
571
|
+
return SearchType.METADATA;
|
|
572
|
+
case 'fulltext':
|
|
573
|
+
return SearchType.FULLTEXT;
|
|
574
|
+
case 'tv':
|
|
575
|
+
return SearchType.TV;
|
|
576
|
+
case 'radio':
|
|
577
|
+
return SearchType.RADIO;
|
|
578
|
+
default:
|
|
579
|
+
return SearchType.DEFAULT;
|
|
580
|
+
}
|
|
534
581
|
}
|
|
535
582
|
|
|
536
583
|
private loginChanged(e: Event) {
|
|
@@ -43,6 +43,8 @@ import {
|
|
|
43
43
|
SORT_OPTIONS,
|
|
44
44
|
defaultProfileElementSorts,
|
|
45
45
|
FacetLoadStrategy,
|
|
46
|
+
defaultFacetDisplayOrder,
|
|
47
|
+
tvFacetDisplayOrder,
|
|
46
48
|
} from './models';
|
|
47
49
|
import {
|
|
48
50
|
RestorationStateHandlerInterface,
|
|
@@ -1100,6 +1102,14 @@ export class CollectionBrowser
|
|
|
1100
1102
|
`;
|
|
1101
1103
|
}
|
|
1102
1104
|
|
|
1105
|
+
// We switch to TV facet ordering & date picker if we are in a TV collection or showing TV search results
|
|
1106
|
+
const shouldUseTvInterface =
|
|
1107
|
+
this.isTVCollection ||
|
|
1108
|
+
(!this.withinCollection && this.searchType === SearchType.TV);
|
|
1109
|
+
const facetDisplayOrder = shouldUseTvInterface
|
|
1110
|
+
? tvFacetDisplayOrder
|
|
1111
|
+
: defaultFacetDisplayOrder;
|
|
1112
|
+
|
|
1103
1113
|
const facets = html`
|
|
1104
1114
|
<collection-facets
|
|
1105
1115
|
@facetsChanged=${this.facetsChanged}
|
|
@@ -1122,11 +1132,13 @@ export class CollectionBrowser
|
|
|
1122
1132
|
.collectionTitles=${this.dataSource.collectionTitles}
|
|
1123
1133
|
.showHistogramDatePicker=${this.showHistogramDatePicker}
|
|
1124
1134
|
.allowExpandingDatePicker=${!this.mobileView}
|
|
1135
|
+
.allowDatePickerMonths=${shouldUseTvInterface}
|
|
1125
1136
|
.contentWidth=${this.contentWidth}
|
|
1126
1137
|
.query=${this.baseQuery}
|
|
1127
1138
|
.filterMap=${this.dataSource.filterMap}
|
|
1128
1139
|
.isManageView=${this.isManageView}
|
|
1129
1140
|
.modalManager=${this.modalManager}
|
|
1141
|
+
.facetDisplayOrder=${facetDisplayOrder}
|
|
1130
1142
|
?collapsableFacets=${this.mobileView}
|
|
1131
1143
|
?facetsLoading=${this.facetsLoading}
|
|
1132
1144
|
?fullYearAggregationLoading=${this.facetsLoading}
|
|
@@ -60,7 +60,7 @@ export class MoreFacetsContent extends LitElement {
|
|
|
60
60
|
|
|
61
61
|
@property({ type: Object }) filterMap?: FilterMap;
|
|
62
62
|
|
|
63
|
-
@property({ type:
|
|
63
|
+
@property({ type: Number }) searchType?: SearchType;
|
|
64
64
|
|
|
65
65
|
@property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
|
|
66
66
|
|
|
@@ -83,7 +83,7 @@ export class MoreFacetsContent extends LitElement {
|
|
|
83
83
|
*/
|
|
84
84
|
@property({ type: Object }) selectedFacets?: SelectedFacets;
|
|
85
85
|
|
|
86
|
-
@property({ type:
|
|
86
|
+
@property({ type: Number }) sortedBy: AggregationSortType =
|
|
87
87
|
AggregationSortType.COUNT;
|
|
88
88
|
|
|
89
89
|
@property({ type: Object }) modalManager?: ModalManagerInterface;
|
|
@@ -109,7 +109,8 @@ export class MoreFacetsContent extends LitElement {
|
|
|
109
109
|
* eventually merged into the existing `selectedFacets` when the patron applies
|
|
110
110
|
* their changes, or discarded if they cancel/close the dialog.
|
|
111
111
|
*/
|
|
112
|
-
@state() private unappliedFacetChanges =
|
|
112
|
+
@state() private unappliedFacetChanges: SelectedFacets =
|
|
113
|
+
getDefaultSelectedFacets();
|
|
113
114
|
|
|
114
115
|
/**
|
|
115
116
|
* Which page of facets we are showing.
|
|
@@ -272,7 +273,7 @@ export class MoreFacetsContent extends LitElement {
|
|
|
272
273
|
// Apply any unapplied selections that appear on this page
|
|
273
274
|
const unappliedBuckets = this.unappliedFacetChanges[this.facetKey];
|
|
274
275
|
for (const [index, bucket] of bucketsWithCount.entries()) {
|
|
275
|
-
const unappliedBucket = unappliedBuckets[bucket.key];
|
|
276
|
+
const unappliedBucket = unappliedBuckets?.[bucket.key];
|
|
276
277
|
if (unappliedBucket) {
|
|
277
278
|
bucketsWithCount[index] = { ...unappliedBucket };
|
|
278
279
|
}
|
|
@@ -202,7 +202,7 @@ export class SmartFacetBar extends LitElement {
|
|
|
202
202
|
if (
|
|
203
203
|
key === 'mediatype' &&
|
|
204
204
|
this.selectedFacets &&
|
|
205
|
-
Object.values(this.selectedFacets.mediatype).some(
|
|
205
|
+
Object.values(this.selectedFacets.mediatype ?? {}).some(
|
|
206
206
|
bucket => bucket.state !== 'none',
|
|
207
207
|
)
|
|
208
208
|
) {
|
|
@@ -213,7 +213,7 @@ export class SmartFacetBar extends LitElement {
|
|
|
213
213
|
const buckets = agg.buckets as Bucket[];
|
|
214
214
|
|
|
215
215
|
const unusedBuckets = buckets.filter(b => {
|
|
216
|
-
const selectedFacetBucket = this.selectedFacets?.[facetType][b.key];
|
|
216
|
+
const selectedFacetBucket = this.selectedFacets?.[facetType]?.[b.key];
|
|
217
217
|
if (selectedFacetBucket && selectedFacetBucket.state !== 'none') {
|
|
218
218
|
return false;
|
|
219
219
|
}
|
package/src/collection-facets.ts
CHANGED
|
@@ -11,7 +11,7 @@ import { map } from 'lit/directives/map.js';
|
|
|
11
11
|
import { ref } from 'lit/directives/ref.js';
|
|
12
12
|
import { msg } from '@lit/localize';
|
|
13
13
|
import { classMap } from 'lit/directives/class-map.js';
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
15
|
Aggregation,
|
|
16
16
|
AggregationSortType,
|
|
17
17
|
Bucket,
|
|
@@ -36,7 +36,7 @@ import {
|
|
|
36
36
|
SelectedFacets,
|
|
37
37
|
FacetGroup,
|
|
38
38
|
FacetBucket,
|
|
39
|
-
|
|
39
|
+
defaultFacetDisplayOrder,
|
|
40
40
|
facetTitles,
|
|
41
41
|
lendingFacetDisplayNames,
|
|
42
42
|
lendingFacetKeysVisibility,
|
|
@@ -68,7 +68,7 @@ import {
|
|
|
68
68
|
export class CollectionFacets extends LitElement {
|
|
69
69
|
@property({ type: Object }) searchService?: SearchServiceInterface;
|
|
70
70
|
|
|
71
|
-
@property({ type:
|
|
71
|
+
@property({ type: Number }) searchType?: SearchType;
|
|
72
72
|
|
|
73
73
|
@property({ type: Object }) aggregations?: Record<string, Aggregation>;
|
|
74
74
|
|
|
@@ -94,6 +94,8 @@ export class CollectionFacets extends LitElement {
|
|
|
94
94
|
|
|
95
95
|
@property({ type: Boolean }) allowExpandingDatePicker = false;
|
|
96
96
|
|
|
97
|
+
@property({ type: Boolean }) allowDatePickerMonths = false;
|
|
98
|
+
|
|
97
99
|
@property({ type: String }) query?: string;
|
|
98
100
|
|
|
99
101
|
@property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
|
|
@@ -108,6 +110,9 @@ export class CollectionFacets extends LitElement {
|
|
|
108
110
|
|
|
109
111
|
@property({ type: Boolean }) isManageView = false;
|
|
110
112
|
|
|
113
|
+
@property({ type: Array }) facetDisplayOrder: FacetOption[] =
|
|
114
|
+
defaultFacetDisplayOrder;
|
|
115
|
+
|
|
111
116
|
@property({ type: Object, attribute: false })
|
|
112
117
|
modalManager?: ModalManagerInterface;
|
|
113
118
|
|
|
@@ -134,6 +139,9 @@ export class CollectionFacets extends LitElement {
|
|
|
134
139
|
creator: false,
|
|
135
140
|
collection: false,
|
|
136
141
|
year: false,
|
|
142
|
+
program: false,
|
|
143
|
+
person: false,
|
|
144
|
+
sponsor: false,
|
|
137
145
|
};
|
|
138
146
|
|
|
139
147
|
/**
|
|
@@ -319,15 +327,18 @@ export class CollectionFacets extends LitElement {
|
|
|
319
327
|
const { fullYearsHistogramAggregation } = this;
|
|
320
328
|
const minDate = fullYearsHistogramAggregation?.first_bucket_key;
|
|
321
329
|
const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
|
|
330
|
+
const dateFormat = this.allowDatePickerMonths ? 'YYYY-MM' : 'YYYY';
|
|
322
331
|
return this.fullYearAggregationLoading
|
|
323
332
|
? html`<div class="histogram-loading-indicator">…</div>` // Ellipsis block
|
|
324
333
|
: html`
|
|
325
334
|
<histogram-date-range
|
|
335
|
+
class=${this.allowDatePickerMonths ? 'wide-inputs' : nothing}
|
|
326
336
|
.minDate=${minDate}
|
|
327
337
|
.maxDate=${maxDate}
|
|
328
338
|
.minSelectedDate=${this.minSelectedDate ?? minDate}
|
|
329
339
|
.maxSelectedDate=${this.maxSelectedDate ?? maxDate}
|
|
330
340
|
.updateDelay=${100}
|
|
341
|
+
.dateFormat=${dateFormat}
|
|
331
342
|
missingDataMessage="..."
|
|
332
343
|
.width=${this.collapsableFacets && this.contentWidth
|
|
333
344
|
? this.contentWidth
|
|
@@ -363,7 +374,7 @@ export class CollectionFacets extends LitElement {
|
|
|
363
374
|
private get mergedFacets(): FacetGroup[] {
|
|
364
375
|
const facetGroups: FacetGroup[] = [];
|
|
365
376
|
|
|
366
|
-
facetDisplayOrder.forEach(facetKey => {
|
|
377
|
+
this.facetDisplayOrder.forEach(facetKey => {
|
|
367
378
|
const selectedFacetGroup = this.selectedFacetGroups.find(
|
|
368
379
|
group => group.key === facetKey,
|
|
369
380
|
);
|
|
@@ -820,7 +831,7 @@ export class CollectionFacets extends LitElement {
|
|
|
820
831
|
|
|
821
832
|
h3 {
|
|
822
833
|
font-size: 1.4rem;
|
|
823
|
-
font-weight: 200
|
|
834
|
+
font-weight: 200;
|
|
824
835
|
padding-bottom: 3px;
|
|
825
836
|
margin: 0;
|
|
826
837
|
}
|
|
@@ -858,6 +869,10 @@ export class CollectionFacets extends LitElement {
|
|
|
858
869
|
height: 15px;
|
|
859
870
|
cursor: pointer;
|
|
860
871
|
}
|
|
872
|
+
|
|
873
|
+
histogram-date-range.wide-inputs {
|
|
874
|
+
--histogramDateRangeInputWidth: 4.8rem;
|
|
875
|
+
}
|
|
861
876
|
`,
|
|
862
877
|
];
|
|
863
878
|
}
|
package/src/models.ts
CHANGED
|
@@ -530,7 +530,11 @@ export type FacetOption =
|
|
|
530
530
|
| 'language'
|
|
531
531
|
| 'creator'
|
|
532
532
|
| 'collection'
|
|
533
|
-
| 'year'
|
|
533
|
+
| 'year'
|
|
534
|
+
// TV-specific facet options:
|
|
535
|
+
| 'program'
|
|
536
|
+
| 'person'
|
|
537
|
+
| 'sponsor';
|
|
534
538
|
|
|
535
539
|
export type SelectedFacetState = 'selected' | 'hidden';
|
|
536
540
|
|
|
@@ -571,12 +575,11 @@ export type FacetEventDetails = {
|
|
|
571
575
|
|
|
572
576
|
export type FacetValue = string;
|
|
573
577
|
|
|
574
|
-
export type SelectedFacets =
|
|
575
|
-
FacetOption,
|
|
576
|
-
Record<FacetValue, FacetBucket>
|
|
578
|
+
export type SelectedFacets = Partial<
|
|
579
|
+
Record<FacetOption, Record<FacetValue, FacetBucket>>
|
|
577
580
|
>;
|
|
578
581
|
|
|
579
|
-
export const getDefaultSelectedFacets = (): SelectedFacets => ({
|
|
582
|
+
export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
|
|
580
583
|
subject: {},
|
|
581
584
|
lending: {},
|
|
582
585
|
mediatype: {},
|
|
@@ -584,9 +587,15 @@ export const getDefaultSelectedFacets = (): SelectedFacets => ({
|
|
|
584
587
|
creator: {},
|
|
585
588
|
collection: {},
|
|
586
589
|
year: {},
|
|
590
|
+
program: {},
|
|
591
|
+
person: {},
|
|
592
|
+
sponsor: {},
|
|
587
593
|
});
|
|
588
594
|
|
|
589
|
-
|
|
595
|
+
/**
|
|
596
|
+
* Facet display order when presenting results for all search types *except* TV (see below).
|
|
597
|
+
*/
|
|
598
|
+
export const defaultFacetDisplayOrder: FacetOption[] = [
|
|
590
599
|
'mediatype',
|
|
591
600
|
// 'lending', Commenting this out removes the lending facet from the sidebar for now
|
|
592
601
|
'year',
|
|
@@ -596,6 +605,23 @@ export const facetDisplayOrder: FacetOption[] = [
|
|
|
596
605
|
'language',
|
|
597
606
|
];
|
|
598
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Specialized facet ordering when displaying TV search results
|
|
610
|
+
*/
|
|
611
|
+
export const tvFacetDisplayOrder: FacetOption[] = [
|
|
612
|
+
'program',
|
|
613
|
+
'creator',
|
|
614
|
+
'year',
|
|
615
|
+
'subject',
|
|
616
|
+
'collection',
|
|
617
|
+
'person',
|
|
618
|
+
'sponsor',
|
|
619
|
+
'language',
|
|
620
|
+
];
|
|
621
|
+
|
|
622
|
+
/**
|
|
623
|
+
* Human-readable titles for each facet group.
|
|
624
|
+
*/
|
|
599
625
|
export const facetTitles: Record<FacetOption, string> = {
|
|
600
626
|
subject: 'Subject',
|
|
601
627
|
lending: 'Availability',
|
|
@@ -604,6 +630,9 @@ export const facetTitles: Record<FacetOption, string> = {
|
|
|
604
630
|
creator: 'Creator',
|
|
605
631
|
collection: 'Collection',
|
|
606
632
|
year: 'Year',
|
|
633
|
+
program: 'Program',
|
|
634
|
+
person: 'Person',
|
|
635
|
+
sponsor: 'Sponsor',
|
|
607
636
|
};
|
|
608
637
|
|
|
609
638
|
/**
|
|
@@ -616,7 +645,10 @@ export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
616
645
|
language: AggregationSortType.COUNT,
|
|
617
646
|
creator: AggregationSortType.COUNT,
|
|
618
647
|
collection: AggregationSortType.COUNT,
|
|
619
|
-
year: AggregationSortType.NUMERIC,
|
|
648
|
+
year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default
|
|
649
|
+
program: AggregationSortType.COUNT,
|
|
650
|
+
person: AggregationSortType.COUNT,
|
|
651
|
+
sponsor: AggregationSortType.COUNT,
|
|
620
652
|
};
|
|
621
653
|
|
|
622
654
|
/**
|
|
@@ -630,7 +662,10 @@ export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
|
|
|
630
662
|
language: AggregationSortType.ALPHABETICAL,
|
|
631
663
|
creator: AggregationSortType.ALPHABETICAL,
|
|
632
664
|
collection: AggregationSortType.ALPHABETICAL,
|
|
633
|
-
year: AggregationSortType.NUMERIC,
|
|
665
|
+
year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)
|
|
666
|
+
program: AggregationSortType.ALPHABETICAL,
|
|
667
|
+
person: AggregationSortType.ALPHABETICAL,
|
|
668
|
+
sponsor: AggregationSortType.ALPHABETICAL,
|
|
634
669
|
};
|
|
635
670
|
|
|
636
671
|
export type LendingFacetKey =
|
package/src/utils/facet-utils.ts
CHANGED
|
@@ -62,7 +62,7 @@ export function updateSelectedFacetBucket(
|
|
|
62
62
|
omitNoneState = false,
|
|
63
63
|
): SelectedFacets {
|
|
64
64
|
const defaultedSelectedFacets = selectedFacets ?? getDefaultSelectedFacets();
|
|
65
|
-
const newFacets = {
|
|
65
|
+
const newFacets: SelectedFacets = {
|
|
66
66
|
...defaultedSelectedFacets,
|
|
67
67
|
[facetType]: {
|
|
68
68
|
...defaultedSelectedFacets[facetType],
|
|
@@ -71,7 +71,7 @@ export function updateSelectedFacetBucket(
|
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
if (omitNoneState && bucket.state === 'none') {
|
|
74
|
-
delete newFacets[facetType][bucket.key];
|
|
74
|
+
delete newFacets[facetType]?.[bucket.key];
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return newFacets;
|
|
@@ -93,6 +93,7 @@ export function cloneSelectedFacets(
|
|
|
93
93
|
): SelectedFacets {
|
|
94
94
|
const cloneResult = getDefaultSelectedFacets();
|
|
95
95
|
forEachFacetBucket(selectedFacets, (facetType, bucketKey, bucket) => {
|
|
96
|
+
if (!cloneResult[facetType]) cloneResult[facetType] = {};
|
|
96
97
|
cloneResult[facetType][bucketKey] = bucket;
|
|
97
98
|
});
|
|
98
99
|
return cloneResult;
|
|
@@ -124,13 +125,14 @@ export function mergeSelectedFacets(
|
|
|
124
125
|
): SelectedFacets {
|
|
125
126
|
const mergeResult = cloneSelectedFacets(destination);
|
|
126
127
|
forEachFacetBucket(source, (facetType, bucketKey, bucket) => {
|
|
128
|
+
if (!mergeResult[facetType]) mergeResult[facetType] = {};
|
|
127
129
|
mergeResult[facetType][bucketKey] = bucket;
|
|
128
130
|
});
|
|
129
131
|
|
|
130
132
|
// Normalize any 'none' states on the result (from either source or destination)
|
|
131
133
|
forEachFacetBucket(mergeResult, (facetType, bucketKey, bucket) => {
|
|
132
134
|
if (bucket.state === 'none') {
|
|
133
|
-
delete mergeResult[facetType][bucketKey];
|
|
135
|
+
delete mergeResult[facetType]?.[bucketKey];
|
|
134
136
|
}
|
|
135
137
|
});
|
|
136
138
|
|
|
@@ -629,6 +629,39 @@ describe('Collection Facets', () => {
|
|
|
629
629
|
expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
|
|
630
630
|
});
|
|
631
631
|
|
|
632
|
+
it('uses specified facet display order', async () => {
|
|
633
|
+
const el = await fixture<CollectionFacets>(
|
|
634
|
+
html`<collection-facets
|
|
635
|
+
.facetDisplayOrder=${['language', 'creator'] as FacetOption[]}
|
|
636
|
+
></collection-facets>`,
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
const aggs: Record<string, Aggregation> = {
|
|
640
|
+
mediatype: new Aggregation({
|
|
641
|
+
buckets: [{ key: 'texts', doc_count: 5 }],
|
|
642
|
+
}),
|
|
643
|
+
collection: new Aggregation({
|
|
644
|
+
buckets: [{ key: 'foo', doc_count: 10 }],
|
|
645
|
+
}),
|
|
646
|
+
creator: new Aggregation({
|
|
647
|
+
buckets: [{ key: 'bar', doc_count: 15 }],
|
|
648
|
+
}),
|
|
649
|
+
language: new Aggregation({
|
|
650
|
+
buckets: [{ key: 'baz', doc_count: 20 }],
|
|
651
|
+
}),
|
|
652
|
+
};
|
|
653
|
+
|
|
654
|
+
el.aggregations = aggs;
|
|
655
|
+
await el.updateComplete;
|
|
656
|
+
|
|
657
|
+
const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
|
|
658
|
+
|
|
659
|
+
// The only two facet groups should be Language and Creator (in that order)
|
|
660
|
+
expect(facetHeaders?.length).to.equal(2);
|
|
661
|
+
expect(facetHeaders?.[0].textContent).to.contain('Language');
|
|
662
|
+
expect(facetHeaders?.[1].textContent).to.contain('Creator');
|
|
663
|
+
});
|
|
664
|
+
|
|
632
665
|
describe('More Facets', () => {
|
|
633
666
|
it('Does not render < allowedFacetCount', async () => {
|
|
634
667
|
const el = await fixture<CollectionFacets>(
|
|
@@ -100,7 +100,7 @@ describe('Restoration state handler', () => {
|
|
|
100
100
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
101
101
|
|
|
102
102
|
const restorationState = handler.getRestorationState();
|
|
103
|
-
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
103
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
104
104
|
'selected',
|
|
105
105
|
);
|
|
106
106
|
});
|
|
@@ -160,7 +160,7 @@ describe('Restoration state handler', () => {
|
|
|
160
160
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
161
161
|
|
|
162
162
|
const restorationState = handler.getRestorationState();
|
|
163
|
-
expect(restorationState.selectedFacets.subject
|
|
163
|
+
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
164
164
|
'selected',
|
|
165
165
|
);
|
|
166
166
|
});
|
|
@@ -173,7 +173,7 @@ describe('Restoration state handler', () => {
|
|
|
173
173
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
174
174
|
|
|
175
175
|
const restorationState = handler.getRestorationState();
|
|
176
|
-
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
176
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
177
177
|
'hidden',
|
|
178
178
|
);
|
|
179
179
|
});
|
|
@@ -188,17 +188,17 @@ describe('Restoration state handler', () => {
|
|
|
188
188
|
|
|
189
189
|
const restorationState = handler.getRestorationState();
|
|
190
190
|
|
|
191
|
-
expect(restorationState.selectedFacets.collection
|
|
191
|
+
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
192
192
|
'selected',
|
|
193
193
|
);
|
|
194
|
-
expect(restorationState.selectedFacets.collection
|
|
194
|
+
expect(restorationState.selectedFacets.collection?.bar.state).to.equal(
|
|
195
195
|
'selected',
|
|
196
196
|
);
|
|
197
197
|
|
|
198
|
-
expect(restorationState.selectedFacets.collection
|
|
198
|
+
expect(restorationState.selectedFacets.collection?.baz.state).to.equal(
|
|
199
199
|
'hidden',
|
|
200
200
|
);
|
|
201
|
-
expect(restorationState.selectedFacets.collection
|
|
201
|
+
expect(restorationState.selectedFacets.collection?.boop.state).to.equal(
|
|
202
202
|
'hidden',
|
|
203
203
|
);
|
|
204
204
|
});
|
|
@@ -211,7 +211,7 @@ describe('Restoration state handler', () => {
|
|
|
211
211
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
212
212
|
|
|
213
213
|
const restorationState = handler.getRestorationState();
|
|
214
|
-
expect(restorationState.selectedFacets.collection
|
|
214
|
+
expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
|
|
215
215
|
'hidden',
|
|
216
216
|
);
|
|
217
217
|
});
|
|
@@ -224,7 +224,7 @@ describe('Restoration state handler', () => {
|
|
|
224
224
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
225
225
|
|
|
226
226
|
const restorationState = handler.getRestorationState();
|
|
227
|
-
expect(restorationState.selectedFacets.subject
|
|
227
|
+
expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
|
|
228
228
|
'selected',
|
|
229
229
|
);
|
|
230
230
|
});
|
|
@@ -237,7 +237,7 @@ describe('Restoration state handler', () => {
|
|
|
237
237
|
window.history.replaceState({ path: url.href }, '', url.href);
|
|
238
238
|
|
|
239
239
|
const restorationState = handler.getRestorationState();
|
|
240
|
-
expect(restorationState.selectedFacets.year['2018'].state).to.equal(
|
|
240
|
+
expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
|
|
241
241
|
'hidden',
|
|
242
242
|
);
|
|
243
243
|
});
|