@internetarchive/collection-browser 2.12.1-alpha-webdev5427.7 → 2.12.2-alpha-webdev7587.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.
Files changed (63) hide show
  1. package/dist/src/app-root.d.ts +0 -1
  2. package/dist/src/app-root.js +2 -48
  3. package/dist/src/app-root.js.map +1 -1
  4. package/dist/src/collection-browser.js +4 -13
  5. package/dist/src/collection-browser.js.map +1 -1
  6. package/dist/src/collection-facets/facet-row.js +1 -7
  7. package/dist/src/collection-facets/facet-row.js.map +1 -1
  8. package/dist/src/collection-facets/more-facets-content.d.ts +0 -1
  9. package/dist/src/collection-facets/more-facets-content.js +4 -19
  10. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  11. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +3 -4
  12. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  13. package/dist/src/collection-facets.d.ts +1 -3
  14. package/dist/src/collection-facets.js +7 -37
  15. package/dist/src/collection-facets.js.map +1 -1
  16. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +1 -1
  17. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  18. package/dist/src/data-source/collection-browser-data-source.js +17 -19
  19. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  20. package/dist/src/expanded-date-picker.d.ts +0 -1
  21. package/dist/src/expanded-date-picker.js +1 -7
  22. package/dist/src/expanded-date-picker.js.map +1 -1
  23. package/dist/src/models.d.ts +5 -22
  24. package/dist/src/models.js +3 -64
  25. package/dist/src/models.js.map +1 -1
  26. package/dist/src/restoration-state-handler.js +3 -8
  27. package/dist/src/restoration-state-handler.js.map +1 -1
  28. package/dist/src/utils/facet-utils.js +2 -8
  29. package/dist/src/utils/facet-utils.js.map +1 -1
  30. package/dist/src/utils/local-date-from-utc.js +1 -1
  31. package/dist/src/utils/local-date-from-utc.js.map +1 -1
  32. package/dist/test/collection-facets.test.js +0 -27
  33. package/dist/test/collection-facets.test.js.map +1 -1
  34. package/dist/test/restoration-state-handler.test.js +10 -17
  35. package/dist/test/restoration-state-handler.test.js.map +1 -1
  36. package/dist/test/tiles/grid/item-tile.test.js +1 -1
  37. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  38. package/dist/test/tiles/list/tile-list-compact.test.js +1 -1
  39. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  40. package/dist/test/tiles/list/tile-list.test.js +3 -3
  41. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  42. package/dist/test/utils/local-date-from-utc.test.js +4 -4
  43. package/dist/test/utils/local-date-from-utc.test.js.map +1 -1
  44. package/package.json +4 -4
  45. package/src/app-root.ts +2 -49
  46. package/src/collection-browser.ts +3 -16
  47. package/src/collection-facets/facet-row.ts +1 -8
  48. package/src/collection-facets/more-facets-content.ts +5 -21
  49. package/src/collection-facets/smart-facets/smart-facet-bar.ts +2 -2
  50. package/src/collection-facets.ts +8 -37
  51. package/src/data-source/collection-browser-data-source-interface.ts +1 -1
  52. package/src/data-source/collection-browser-data-source.ts +20 -30
  53. package/src/expanded-date-picker.ts +1 -5
  54. package/src/models.ts +10 -82
  55. package/src/restoration-state-handler.ts +1 -8
  56. package/src/utils/facet-utils.ts +3 -5
  57. package/src/utils/local-date-from-utc.ts +1 -1
  58. package/test/collection-facets.test.ts +0 -33
  59. package/test/restoration-state-handler.test.ts +10 -10
  60. package/test/tiles/grid/item-tile.test.ts +1 -1
  61. package/test/tiles/list/tile-list-compact.test.ts +1 -1
  62. package/test/tiles/list/tile-list.test.ts +3 -3
  63. package/test/utils/local-date-from-utc.test.ts +4 -4
@@ -43,8 +43,6 @@ import {
43
43
  SORT_OPTIONS,
44
44
  defaultProfileElementSorts,
45
45
  FacetLoadStrategy,
46
- defaultFacetDisplayOrder,
47
- tvFacetDisplayOrder,
48
46
  } from './models';
49
47
  import {
50
48
  RestorationStateHandlerInterface,
@@ -1102,16 +1100,10 @@ export class CollectionBrowser
1102
1100
  `;
1103
1101
  }
1104
1102
 
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
-
1113
1103
  const facets = html`
1114
1104
  <collection-facets
1105
+ @facetsChanged=${this.facetsChanged}
1106
+ @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
1115
1107
  .collectionPagePath=${this.collectionPagePath}
1116
1108
  .parentCollections=${this.dataSource.parentCollections}
1117
1109
  .pageSpecifierParams=${this.dataSource.pageSpecifierParams}
@@ -1130,21 +1122,16 @@ export class CollectionBrowser
1130
1122
  .collectionTitles=${this.dataSource.collectionTitles}
1131
1123
  .showHistogramDatePicker=${this.showHistogramDatePicker}
1132
1124
  .allowExpandingDatePicker=${!this.mobileView}
1133
- .allowDatePickerMonths=${shouldUseTvInterface}
1134
1125
  .contentWidth=${this.contentWidth}
1135
1126
  .query=${this.baseQuery}
1136
1127
  .filterMap=${this.dataSource.filterMap}
1137
1128
  .isManageView=${this.isManageView}
1138
1129
  .modalManager=${this.modalManager}
1139
- .analyticsHandler=${this.analyticsHandler}
1140
- .facetDisplayOrder=${facetDisplayOrder}
1141
- .isTvSearch=${shouldUseTvInterface}
1142
1130
  ?collapsableFacets=${this.mobileView}
1143
1131
  ?facetsLoading=${this.facetsLoading}
1144
1132
  ?fullYearAggregationLoading=${this.facetsLoading}
1145
1133
  @facetClick=${this.facetClickHandler}
1146
- @facetsChanged=${this.facetsChanged}
1147
- @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
1134
+ .analyticsHandler=${this.analyticsHandler}
1148
1135
  >
1149
1136
  </collection-facets>
1150
1137
  `;
@@ -56,15 +56,11 @@ export class FacetRow extends LitElement {
56
56
  const showOnlyCheckboxId = `${facetType}:${bucket.key}-show-only`;
57
57
  const negativeCheckboxId = `${facetType}:${bucket.key}-negative`;
58
58
 
59
- const extraNoteSpan = bucket.extraNote
60
- ? html`<span class="facet-note">${bucket.extraNote}</span>`
61
- : nothing;
62
-
63
59
  // For collections, we render the collection title as a link.
64
60
  // For other facet types, we just have a static value to use.
65
61
  const bucketTextDisplay =
66
62
  facetType !== 'collection'
67
- ? html`${bucket.displayText ?? bucket.key} ${extraNoteSpan}`
63
+ ? html`${bucket.displayText ?? bucket.key}`
68
64
  : html`<a href="/details/${bucket.key}">
69
65
  ${this.collectionTitles?.get(bucket.key) ?? bucket.key}
70
66
  </a> `;
@@ -230,9 +226,6 @@ export class FacetRow extends LitElement {
230
226
  display: inline-block;
231
227
  flex: 1 1 0%;
232
228
  }
233
- .facet-note {
234
- color: #bbb;
235
- }
236
229
  .facet-count {
237
230
  text-align: right;
238
231
  }
@@ -32,7 +32,6 @@ import {
32
32
  defaultFacetSort,
33
33
  getDefaultSelectedFacets,
34
34
  FacetEventDetails,
35
- tvChannelFacetLabels,
36
35
  } from '../models';
37
36
  import type {
38
37
  CollectionTitles,
@@ -61,7 +60,7 @@ export class MoreFacetsContent extends LitElement {
61
60
 
62
61
  @property({ type: Object }) filterMap?: FilterMap;
63
62
 
64
- @property({ type: Number }) searchType?: SearchType;
63
+ @property({ type: String }) searchType?: SearchType;
65
64
 
66
65
  @property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
67
66
 
@@ -84,11 +83,9 @@ export class MoreFacetsContent extends LitElement {
84
83
  */
85
84
  @property({ type: Object }) selectedFacets?: SelectedFacets;
86
85
 
87
- @property({ type: Number }) sortedBy: AggregationSortType =
86
+ @property({ type: String }) sortedBy: AggregationSortType =
88
87
  AggregationSortType.COUNT;
89
88
 
90
- @property({ type: Boolean }) isTvSearch = false;
91
-
92
89
  @property({ type: Object }) modalManager?: ModalManagerInterface;
93
90
 
94
91
  @property({ type: Object }) searchService?: SearchServiceInterface;
@@ -112,8 +109,7 @@ export class MoreFacetsContent extends LitElement {
112
109
  * eventually merged into the existing `selectedFacets` when the patron applies
113
110
  * their changes, or discarded if they cancel/close the dialog.
114
111
  */
115
- @state() private unappliedFacetChanges: SelectedFacets =
116
- getDefaultSelectedFacets();
112
+ @state() private unappliedFacetChanges = getDefaultSelectedFacets();
117
113
 
118
114
  /**
119
115
  * Which page of facets we are showing.
@@ -276,25 +272,13 @@ export class MoreFacetsContent extends LitElement {
276
272
  // Apply any unapplied selections that appear on this page
277
273
  const unappliedBuckets = this.unappliedFacetChanges[this.facetKey];
278
274
  for (const [index, bucket] of bucketsWithCount.entries()) {
279
- const unappliedBucket = unappliedBuckets?.[bucket.key];
275
+ const unappliedBucket = unappliedBuckets[bucket.key];
280
276
  if (unappliedBucket) {
281
277
  bucketsWithCount[index] = { ...unappliedBucket };
282
278
  }
283
279
  }
284
-
285
- // For TV creator facets, uppercase the display text
286
- if (this.facetKey === 'creator' && this.isTvSearch) {
287
- bucketsWithCount.forEach(b => {
288
- b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
289
-
290
- const channelLabel = tvChannelFacetLabels[b.displayText];
291
- if (channelLabel && channelLabel !== b.displayText) {
292
- b.extraNote = `(${channelLabel})`;
293
- }
294
- });
295
- }
296
-
297
280
  facetGroup.buckets = bucketsWithCount;
281
+
298
282
  return facetGroup;
299
283
  }
300
284
 
@@ -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
  }
@@ -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 type {
15
15
  Aggregation,
16
16
  AggregationSortType,
17
17
  Bucket,
@@ -36,7 +36,7 @@ import {
36
36
  SelectedFacets,
37
37
  FacetGroup,
38
38
  FacetBucket,
39
- defaultFacetDisplayOrder,
39
+ facetDisplayOrder,
40
40
  facetTitles,
41
41
  lendingFacetDisplayNames,
42
42
  lendingFacetKeysVisibility,
@@ -44,7 +44,6 @@ import {
44
44
  suppressedCollections,
45
45
  defaultFacetSort,
46
46
  FacetEventDetails,
47
- tvChannelFacetLabels,
48
47
  } from './models';
49
48
  import type {
50
49
  CollectionTitles,
@@ -69,7 +68,7 @@ import {
69
68
  export class CollectionFacets extends LitElement {
70
69
  @property({ type: Object }) searchService?: SearchServiceInterface;
71
70
 
72
- @property({ type: Number }) searchType?: SearchType;
71
+ @property({ type: String }) searchType?: SearchType;
73
72
 
74
73
  @property({ type: Object }) aggregations?: Record<string, Aggregation>;
75
74
 
@@ -109,11 +108,6 @@ export class CollectionFacets extends LitElement {
109
108
 
110
109
  @property({ type: Boolean }) isManageView = false;
111
110
 
112
- @property({ type: Boolean }) isTvSearch = false;
113
-
114
- @property({ type: Array }) facetDisplayOrder: FacetOption[] =
115
- defaultFacetDisplayOrder;
116
-
117
111
  @property({ type: Object, attribute: false })
118
112
  modalManager?: ModalManagerInterface;
119
113
 
@@ -140,9 +134,6 @@ export class CollectionFacets extends LitElement {
140
134
  creator: false,
141
135
  collection: false,
142
136
  year: false,
143
- program: false,
144
- person: false,
145
- sponsor: false,
146
137
  };
147
138
 
148
139
  /**
@@ -236,7 +227,6 @@ export class CollectionFacets extends LitElement {
236
227
  const minDate = fullYearsHistogramAggregation?.first_bucket_key;
237
228
  const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
238
229
  const buckets = fullYearsHistogramAggregation?.buckets as number[];
239
- const dateFormat = this.isTvSearch ? 'YYYY-MM' : 'YYYY';
240
230
 
241
231
  // Because the modal manager does not clear its DOM content after being closed,
242
232
  // it may try to render the exact same date picker template when it is reopened.
@@ -261,7 +251,6 @@ export class CollectionFacets extends LitElement {
261
251
  .maxDate=${maxDate}
262
252
  .minSelectedDate=${this.minSelectedDate}
263
253
  .maxSelectedDate=${this.maxSelectedDate}
264
- .dateFormat=${dateFormat}
265
254
  .buckets=${buckets}
266
255
  .modalManager=${this.modalManager}
267
256
  .analyticsHandler=${this.analyticsHandler}
@@ -275,7 +264,7 @@ export class CollectionFacets extends LitElement {
275
264
  headerColor: '#194880',
276
265
  showHeaderLogo: false,
277
266
  closeOnBackdropClick: true, // TODO: want to fire analytics
278
- title: html`${msg('Select a date range')}`,
267
+ title: html`Select a date range`,
279
268
  });
280
269
 
281
270
  this.modalManager?.classList.add('expanded-date-picker');
@@ -330,18 +319,15 @@ export class CollectionFacets extends LitElement {
330
319
  const { fullYearsHistogramAggregation } = this;
331
320
  const minDate = fullYearsHistogramAggregation?.first_bucket_key;
332
321
  const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
333
- const dateFormat = this.isTvSearch ? 'YYYY-MM' : 'YYYY';
334
322
  return this.fullYearAggregationLoading
335
323
  ? html`<div class="histogram-loading-indicator">&hellip;</div>` // Ellipsis block
336
324
  : html`
337
325
  <histogram-date-range
338
- class=${this.isTvSearch ? 'wide-inputs' : nothing}
339
326
  .minDate=${minDate}
340
327
  .maxDate=${maxDate}
341
328
  .minSelectedDate=${this.minSelectedDate ?? minDate}
342
329
  .maxSelectedDate=${this.maxSelectedDate ?? maxDate}
343
330
  .updateDelay=${100}
344
- .dateFormat=${dateFormat}
345
331
  missingDataMessage="..."
346
332
  .width=${this.collapsableFacets && this.contentWidth
347
333
  ? this.contentWidth
@@ -377,7 +363,7 @@ export class CollectionFacets extends LitElement {
377
363
  private get mergedFacets(): FacetGroup[] {
378
364
  const facetGroups: FacetGroup[] = [];
379
365
 
380
- this.facetDisplayOrder.forEach(facetKey => {
366
+ facetDisplayOrder.forEach(facetKey => {
381
367
  const selectedFacetGroup = this.selectedFacetGroups.find(
382
368
  group => group.key === facetKey,
383
369
  );
@@ -439,7 +425,7 @@ export class CollectionFacets extends LitElement {
439
425
  }
440
426
 
441
427
  // Sort the FacetBuckets so that selected and hidden buckets come before the rest
442
- sortBucketsBySelectionState(bucketsWithCount, defaultFacetSort[facetKey]);
428
+ sortBucketsBySelectionState(bucketsWithCount);
443
429
 
444
430
  // For mediatype facets, ensure the collection bucket is always shown if present
445
431
  if (facetKey === 'mediatype') {
@@ -462,18 +448,6 @@ export class CollectionFacets extends LitElement {
462
448
  }
463
449
  }
464
450
 
465
- // For TV creator facets, uppercase the display text
466
- if (facetKey === 'creator' && this.isTvSearch) {
467
- bucketsWithCount.forEach(b => {
468
- b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
469
-
470
- const channelLabel = tvChannelFacetLabels[b.displayText];
471
- if (channelLabel && channelLabel !== b.displayText) {
472
- b.extraNote = `(${channelLabel})`;
473
- }
474
- });
475
- }
476
-
477
451
  // slice off how many items we want to show in page facet area
478
452
  facetGroup.buckets = bucketsWithCount.slice(0, allowedFacetCount);
479
453
 
@@ -705,7 +679,6 @@ export class CollectionFacets extends LitElement {
705
679
  .collectionTitles=${this.collectionTitles}
706
680
  .selectedFacets=${this.selectedFacets}
707
681
  .sortedBy=${sortedBy}
708
- .isTvSearch=${this.isTvSearch}
709
682
  @facetsChanged=${(e: CustomEvent) => {
710
683
  const event = new CustomEvent<SelectedFacets>('facetsChanged', {
711
684
  detail: e.detail,
@@ -847,6 +820,8 @@ export class CollectionFacets extends LitElement {
847
820
 
848
821
  h3 {
849
822
  font-size: 1.4rem;
823
+ font-weight: 200
824
+ padding-bottom: 3px;
850
825
  margin: 0;
851
826
  }
852
827
 
@@ -883,10 +858,6 @@ export class CollectionFacets extends LitElement {
883
858
  height: 15px;
884
859
  cursor: pointer;
885
860
  }
886
-
887
- histogram-date-range.wide-inputs {
888
- --histogramDateRangeInputWidth: 4.8rem;
889
- }
890
861
  `,
891
862
  ];
892
863
  }
@@ -156,7 +156,7 @@ export interface CollectionBrowserDataSourceInterface
156
156
  reset(): void;
157
157
 
158
158
  /**
159
- * Resets the data source to its pages.
159
+ * Resets the data source's result pages, keeping other state intact.
160
160
  */
161
161
  resetPages(): void;
162
162
 
@@ -258,8 +258,10 @@ export class CollectionBrowserDataSource
258
258
  if (Object.keys(this.pages).length < this.host.maxPagesToManage) {
259
259
  this.pages = {};
260
260
 
261
- // Invalidate any fetches in progress
262
- this.fetchesInProgress.clear();
261
+ // Invalidate any page fetches in progress (keep facet fetches)
262
+ this.fetchesInProgress.forEach(key => {
263
+ if (!key.startsWith('facets-')) this.fetchesInProgress.delete(key);
264
+ });
263
265
  this.requestHostUpdate();
264
266
  }
265
267
  }
@@ -676,7 +678,7 @@ export class CollectionBrowserDataSource
676
678
  get facetFetchQueryKey(): string {
677
679
  const profileKey = `pf;${this.host.withinProfile}--pe;${this.host.profileElement}`;
678
680
  const pageTarget = this.host.withinCollection ?? profileKey;
679
- return `fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
681
+ return `facets-fq:${this.fullQuery}-pt:${pageTarget}-st:${this.host.searchType}`;
680
682
  }
681
683
 
682
684
  /**
@@ -687,39 +689,27 @@ export class CollectionBrowserDataSource
687
689
  get filterMap(): FilterMap {
688
690
  const builder = new FilterMapBuilder();
689
691
 
690
- const {
691
- minSelectedDate,
692
- maxSelectedDate,
693
- selectedFacets,
694
- selectedTitleFilter,
695
- selectedCreatorFilter,
696
- } = this.host;
697
-
698
- // Add the date range, if applicable.
699
- // If the min/max are just years, filter on `year` alone. If months/days are included, use `date` instead.
700
- const dateRangeField =
701
- minSelectedDate?.includes('-') || maxSelectedDate?.includes('-')
702
- ? 'date'
703
- : 'year';
704
-
705
- if (minSelectedDate) {
692
+ // Add the date range, if applicable
693
+ if (this.host.minSelectedDate) {
706
694
  builder.addFilter(
707
- dateRangeField,
708
- minSelectedDate,
695
+ 'year',
696
+ this.host.minSelectedDate,
709
697
  FilterConstraint.GREATER_OR_EQUAL,
710
698
  );
711
699
  }
712
- if (maxSelectedDate) {
700
+ if (this.host.maxSelectedDate) {
713
701
  builder.addFilter(
714
- dateRangeField,
715
- maxSelectedDate,
702
+ 'year',
703
+ this.host.maxSelectedDate,
716
704
  FilterConstraint.LESS_OR_EQUAL,
717
705
  );
718
706
  }
719
707
 
720
708
  // Add any selected facets
721
- if (selectedFacets) {
722
- for (const [facetName, facetValues] of Object.entries(selectedFacets)) {
709
+ if (this.host.selectedFacets) {
710
+ for (const [facetName, facetValues] of Object.entries(
711
+ this.host.selectedFacets,
712
+ )) {
723
713
  const { name, values } = this.prepareFacetForFetch(
724
714
  facetName,
725
715
  facetValues,
@@ -740,17 +730,17 @@ export class CollectionBrowserDataSource
740
730
  }
741
731
 
742
732
  // Add any letter filters
743
- if (selectedTitleFilter) {
733
+ if (this.host.selectedTitleFilter) {
744
734
  builder.addFilter(
745
735
  'firstTitle',
746
- selectedTitleFilter,
736
+ this.host.selectedTitleFilter,
747
737
  FilterConstraint.INCLUDE,
748
738
  );
749
739
  }
750
- if (selectedCreatorFilter) {
740
+ if (this.host.selectedCreatorFilter) {
751
741
  builder.addFilter(
752
742
  'firstCreator',
753
- selectedCreatorFilter,
743
+ this.host.selectedCreatorFilter,
754
744
  FilterConstraint.INCLUDE,
755
745
  );
756
746
  }
@@ -1,6 +1,5 @@
1
1
  import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { msg } from '@lit/localize';
4
3
  import type { ModalManagerInterface } from '@internetarchive/modal-manager';
5
4
  import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
6
5
  import {
@@ -20,8 +19,6 @@ export class ExpandedDatePicker extends LitElement {
20
19
 
21
20
  @property({ type: Array }) buckets?: number[];
22
21
 
23
- @property({ type: String }) dateFormat: string = 'YYYY';
24
-
25
22
  @property({ type: Object, attribute: false })
26
23
  modalManager?: ModalManagerInterface;
27
24
 
@@ -37,7 +34,6 @@ export class ExpandedDatePicker extends LitElement {
37
34
  .maxDate=${this.maxDate}
38
35
  .minSelectedDate=${this.minSelectedDate ?? this.minDate}
39
36
  .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
40
- .dateFormat=${this.dateFormat}
41
37
  .updateDelay=${0}
42
38
  updateWhileFocused
43
39
  missingDataMessage="..."
@@ -51,7 +47,7 @@ export class ExpandedDatePicker extends LitElement {
51
47
  slot="inputs-right-side"
52
48
  @click=${this.applyBtnClicked}
53
49
  >
54
- ${msg('Apply date range')}
50
+ Apply date range
55
51
  </button>
56
52
  </histogram-date-range>
57
53
  </div>
package/src/models.ts CHANGED
@@ -530,24 +530,18 @@ export type FacetOption =
530
530
  | 'language'
531
531
  | 'creator'
532
532
  | 'collection'
533
- | 'year'
534
- // TV-specific facet options:
535
- | 'program'
536
- | 'person'
537
- | 'sponsor';
533
+ | 'year';
538
534
 
539
535
  export type SelectedFacetState = 'selected' | 'hidden';
540
536
 
541
537
  export type FacetState = SelectedFacetState | 'none';
542
538
 
543
539
  export interface FacetBucket {
540
+ // for some facets, we augment the key with a display value
541
+ displayText?: string;
544
542
  key: string;
545
543
  count: number;
546
544
  state: FacetState;
547
- // for some facets, we augment the key with a display value
548
- displayText?: string;
549
- // for TV channel facets, we add a parenthesized secondary name
550
- extraNote?: string;
551
545
  }
552
546
 
553
547
  export interface FacetGroup {
@@ -577,11 +571,12 @@ export type FacetEventDetails = {
577
571
 
578
572
  export type FacetValue = string;
579
573
 
580
- export type SelectedFacets = Partial<
581
- Record<FacetOption, Record<FacetValue, FacetBucket>>
574
+ export type SelectedFacets = Record<
575
+ FacetOption,
576
+ Record<FacetValue, FacetBucket>
582
577
  >;
583
578
 
584
- export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
579
+ export const getDefaultSelectedFacets = (): SelectedFacets => ({
585
580
  subject: {},
586
581
  lending: {},
587
582
  mediatype: {},
@@ -589,15 +584,9 @@ export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
589
584
  creator: {},
590
585
  collection: {},
591
586
  year: {},
592
- program: {},
593
- person: {},
594
- sponsor: {},
595
587
  });
596
588
 
597
- /**
598
- * Facet display order when presenting results for all search types *except* TV (see below).
599
- */
600
- export const defaultFacetDisplayOrder: FacetOption[] = [
589
+ export const facetDisplayOrder: FacetOption[] = [
601
590
  'mediatype',
602
591
  // 'lending', Commenting this out removes the lending facet from the sidebar for now
603
592
  'year',
@@ -607,23 +596,6 @@ export const defaultFacetDisplayOrder: FacetOption[] = [
607
596
  'language',
608
597
  ];
609
598
 
610
- /**
611
- * Specialized facet ordering when displaying TV search results
612
- */
613
- export const tvFacetDisplayOrder: FacetOption[] = [
614
- 'program',
615
- 'creator',
616
- 'year',
617
- 'subject',
618
- 'collection',
619
- 'person',
620
- 'sponsor',
621
- 'language',
622
- ];
623
-
624
- /**
625
- * Human-readable titles for each facet group.
626
- */
627
599
  export const facetTitles: Record<FacetOption, string> = {
628
600
  subject: 'Subject',
629
601
  lending: 'Availability',
@@ -632,9 +604,6 @@ export const facetTitles: Record<FacetOption, string> = {
632
604
  creator: 'Creator',
633
605
  collection: 'Collection',
634
606
  year: 'Year',
635
- program: 'Program',
636
- person: 'Person',
637
- sponsor: 'Sponsor',
638
607
  };
639
608
 
640
609
  /**
@@ -647,10 +616,7 @@ export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
647
616
  language: AggregationSortType.COUNT,
648
617
  creator: AggregationSortType.COUNT,
649
618
  collection: AggregationSortType.COUNT,
650
- year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default
651
- program: AggregationSortType.COUNT,
652
- person: AggregationSortType.COUNT,
653
- sponsor: AggregationSortType.COUNT,
619
+ year: AggregationSortType.NUMERIC,
654
620
  };
655
621
 
656
622
  /**
@@ -664,47 +630,9 @@ export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
664
630
  language: AggregationSortType.ALPHABETICAL,
665
631
  creator: AggregationSortType.ALPHABETICAL,
666
632
  collection: AggregationSortType.ALPHABETICAL,
667
- year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)
668
- program: AggregationSortType.ALPHABETICAL,
669
- person: AggregationSortType.ALPHABETICAL,
670
- sponsor: AggregationSortType.ALPHABETICAL,
633
+ year: AggregationSortType.NUMERIC,
671
634
  };
672
635
 
673
- /**
674
- * Extra parenthesized labels to show next to certain TV channel facets
675
- *
676
- * TODO this is temporary for testing
677
- */
678
- export const tvChannelFacetLabels: Record<string, string> = Object.fromEntries(
679
- // prettier-ignore
680
- Object.entries({
681
- 'Al Jazeera' : ['ALJAZAM', 'ALJAZ'],
682
- 'Bloomberg' : ['BLOOMBERG'],
683
- 'BBC' : ['BBC', 'BBC1', 'BBC2'],
684
- 'BBC America' : ['BBCAMERICA'],
685
- 'BBC News' : ['BBCNEWS'],
686
- 'GB News' : ['GBN'],
687
- 'BET' : ['BETW'],
688
- 'CNBC' : ['CNBC'],
689
- 'CNN' : ['CNNW', 'CNN'],
690
- 'Comedy Central' : ['COM', 'COMW'],
691
- 'CSPAN' : ['CSPAN', 'CSPAN2', 'CSPAN3'],
692
- 'Current' : ['CURRENT'],
693
- 'Deutsche Welle' : ['DW'],
694
- 'France 24' : ['FRANCE24'],
695
- 'FOX Business' : ['FBC'],
696
- 'FOX News' : ['FOXNEWSW', 'FOXNEWS'],
697
- 'LINKTV' : ['LINKTV'],
698
- 'MSNBC' : ['MSNBCW', 'MSNBC'],
699
- 'NHK World' : ['NHK'],
700
- 'RT' : ['RT'],
701
- 'Sky News' : ['SKY'],
702
- }).reduce(
703
- (acc, [label, channels]) => acc.concat(channels.map(ch => [ch, label])),
704
- [] as [string, string][],
705
- ),
706
- );
707
-
708
636
  export type LendingFacetKey =
709
637
  | 'is_lendable'
710
638
  | 'is_borrowable'
@@ -185,16 +185,10 @@ export class RestorationStateHandler
185
185
  }
186
186
  }
187
187
 
188
- const dateField =
189
- state.minSelectedDate?.includes('-') ||
190
- state.maxSelectedDate?.includes('-')
191
- ? 'date'
192
- : 'year';
193
-
194
188
  if (state.minSelectedDate && state.maxSelectedDate) {
195
189
  newParams.append(
196
190
  'and[]',
197
- `${dateField}:[${state.minSelectedDate} TO ${state.maxSelectedDate}]`,
191
+ `year:[${state.minSelectedDate} TO ${state.maxSelectedDate}]`,
198
192
  );
199
193
  }
200
194
 
@@ -343,7 +337,6 @@ export class RestorationStateHandler
343
337
  }
344
338
 
345
339
  switch (field) {
346
- case 'date':
347
340
  case 'year': {
348
341
  const [minDate, maxDate] = value.split(' TO ');
349
342
  // we have two potential ways of filtering by date:
@@ -62,7 +62,7 @@ export function updateSelectedFacetBucket(
62
62
  omitNoneState = false,
63
63
  ): SelectedFacets {
64
64
  const defaultedSelectedFacets = selectedFacets ?? getDefaultSelectedFacets();
65
- const newFacets: SelectedFacets = {
65
+ const newFacets = {
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,7 +93,6 @@ export function cloneSelectedFacets(
93
93
  ): SelectedFacets {
94
94
  const cloneResult = getDefaultSelectedFacets();
95
95
  forEachFacetBucket(selectedFacets, (facetType, bucketKey, bucket) => {
96
- if (!cloneResult[facetType]) cloneResult[facetType] = {};
97
96
  cloneResult[facetType][bucketKey] = bucket;
98
97
  });
99
98
  return cloneResult;
@@ -125,14 +124,13 @@ export function mergeSelectedFacets(
125
124
  ): SelectedFacets {
126
125
  const mergeResult = cloneSelectedFacets(destination);
127
126
  forEachFacetBucket(source, (facetType, bucketKey, bucket) => {
128
- if (!mergeResult[facetType]) mergeResult[facetType] = {};
129
127
  mergeResult[facetType][bucketKey] = bucket;
130
128
  });
131
129
 
132
130
  // Normalize any 'none' states on the result (from either source or destination)
133
131
  forEachFacetBucket(mergeResult, (facetType, bucketKey, bucket) => {
134
132
  if (bucket.state === 'none') {
135
- delete mergeResult[facetType]?.[bucketKey];
133
+ delete mergeResult[facetType][bucketKey];
136
134
  }
137
135
  });
138
136