@internetarchive/collection-browser 2.19.1-alpha-webdev7818.0 → 2.20.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/app-root.js +606 -605
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.js +26 -9
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
- package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
- package/dist/src/collection-facets.js +263 -263
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/expanded-date-picker.js +52 -52
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/models.d.ts +13 -0
- package/dist/src/models.js +41 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +79 -24
- package/dist/src/sort-filter-bar/sort-filter-bar.js +201 -119
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +139 -139
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +118 -118
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +289 -289
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +200 -200
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +157 -11
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/package.json +1 -1
- package/src/app-root.ts +1140 -1140
- package/src/collection-browser.ts +30 -8
- package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
- package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
- package/src/collection-facets.ts +990 -990
- package/src/expanded-date-picker.ts +191 -191
- package/src/models.ts +48 -0
- package/src/sort-filter-bar/sort-filter-bar.ts +220 -126
- package/src/tiles/grid/item-tile.ts +339 -339
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +129 -129
- package/src/tiles/list/tile-list.ts +688 -688
- package/src/tiles/tile-dispatcher.ts +486 -486
- package/test/sort-filter-bar/sort-filter-bar.test.ts +205 -12
- package/tsconfig.json +1 -1
|
@@ -16,11 +16,16 @@ import '@internetarchive/ia-dropdown';
|
|
|
16
16
|
import type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';
|
|
17
17
|
import type { SortDirection } from '@internetarchive/search-service';
|
|
18
18
|
import {
|
|
19
|
+
ALL_DATE_SORT_FIELDS,
|
|
20
|
+
ALL_VIEWS_SORT_FIELDS,
|
|
19
21
|
CollectionDisplayMode,
|
|
22
|
+
DateSortField,
|
|
23
|
+
defaultSortAvailability,
|
|
20
24
|
PrefixFilterCounts,
|
|
21
25
|
PrefixFilterType,
|
|
22
26
|
SORT_OPTIONS,
|
|
23
27
|
SortField,
|
|
28
|
+
ViewsSortField,
|
|
24
29
|
} from '../models';
|
|
25
30
|
import './alpha-bar';
|
|
26
31
|
|
|
@@ -51,6 +56,13 @@ export class SortFilterBar
|
|
|
51
56
|
SortField.default
|
|
52
57
|
> = SortField.relevance;
|
|
53
58
|
|
|
59
|
+
/** Which view sort option to expose by default. */
|
|
60
|
+
@property({ type: String }) defaultViewSort: ViewsSortField =
|
|
61
|
+
SortField.weeklyview;
|
|
62
|
+
|
|
63
|
+
/** Which date sort option to expose by default */
|
|
64
|
+
@property({ type: String }) defaultDateSort: DateSortField = SortField.date;
|
|
65
|
+
|
|
54
66
|
/** The current sort direction (asc/desc), or null if none is set */
|
|
55
67
|
@property({ type: String }) sortDirection: SortDirection | null = null;
|
|
56
68
|
|
|
@@ -63,11 +75,20 @@ export class SortFilterBar
|
|
|
63
75
|
/** The currently selected creator letter filter, or null if none is set */
|
|
64
76
|
@property({ type: String }) selectedCreatorFilter: string | null = null;
|
|
65
77
|
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
78
|
+
/**
|
|
79
|
+
* Map defining which sortable fields should be included on the sort bar.
|
|
80
|
+
*
|
|
81
|
+
* E.g.,
|
|
82
|
+
* ```
|
|
83
|
+
* {
|
|
84
|
+
* [SortField.relevance]: true,
|
|
85
|
+
* [SortField.date]: false,
|
|
86
|
+
* [SortField.title]: true,
|
|
87
|
+
* ...
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
@property({ type: Object }) sortFieldAvailability = defaultSortAvailability;
|
|
71
92
|
|
|
72
93
|
/** Whether to replace the default sort options with a slot for customization (default `false`) */
|
|
73
94
|
@property({ type: Boolean, reflect: true }) enableSortOptionsSlot: boolean =
|
|
@@ -88,12 +109,12 @@ export class SortFilterBar
|
|
|
88
109
|
/**
|
|
89
110
|
* The Views sort option that was most recently selected (or the default, if none has been selected yet)
|
|
90
111
|
*/
|
|
91
|
-
@state() private lastSelectedViewSort =
|
|
112
|
+
@state() private lastSelectedViewSort = this.defaultViewSort;
|
|
92
113
|
|
|
93
114
|
/**
|
|
94
115
|
* The Date sort option that was most recently selected (or the default, if none has been selected yet)
|
|
95
116
|
*/
|
|
96
|
-
@state() private lastSelectedDateSort = this.
|
|
117
|
+
@state() private lastSelectedDateSort = this.defaultDateSort;
|
|
97
118
|
|
|
98
119
|
/**
|
|
99
120
|
* Which of the alphabet bars (title/creator) should be shown, or null if one
|
|
@@ -135,11 +156,11 @@ export class SortFilterBar
|
|
|
135
156
|
|
|
136
157
|
/** The dropdown component containing options for weekly and all-time views */
|
|
137
158
|
@query('#views-dropdown')
|
|
138
|
-
private viewsDropdown
|
|
159
|
+
private viewsDropdown?: IaDropdown;
|
|
139
160
|
|
|
140
|
-
/** The dropdown component containing the
|
|
161
|
+
/** The dropdown component containing all the available date options */
|
|
141
162
|
@query('#date-dropdown')
|
|
142
|
-
private dateDropdown
|
|
163
|
+
private dateDropdown?: IaDropdown;
|
|
143
164
|
|
|
144
165
|
/** The single, consolidated dropdown component shown in mobile view */
|
|
145
166
|
@query('#mobile-dropdown')
|
|
@@ -193,19 +214,18 @@ export class SortFilterBar
|
|
|
193
214
|
}
|
|
194
215
|
|
|
195
216
|
if (this.viewOptionSelected) {
|
|
196
|
-
this.lastSelectedViewSort = this.finalizedSortField;
|
|
217
|
+
this.lastSelectedViewSort = this.finalizedSortField as ViewsSortField;
|
|
197
218
|
} else if (this.dateOptionSelected) {
|
|
198
|
-
this.lastSelectedDateSort = this.finalizedSortField;
|
|
219
|
+
this.lastSelectedDateSort = this.finalizedSortField as DateSortField;
|
|
199
220
|
}
|
|
200
221
|
}
|
|
201
222
|
|
|
202
|
-
// If we change which dropdown options are
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
this.lastSelectedDateSort = this.defaultDateSortField;
|
|
223
|
+
// If we change which dropdown options are defaulted, update the default selections
|
|
224
|
+
if (changed.has('defaultViewSort')) {
|
|
225
|
+
this.lastSelectedViewSort = this.defaultViewSort;
|
|
226
|
+
}
|
|
227
|
+
if (changed.has('defaultDateSort')) {
|
|
228
|
+
this.lastSelectedDateSort = this.defaultDateSort;
|
|
209
229
|
}
|
|
210
230
|
}
|
|
211
231
|
|
|
@@ -378,47 +398,11 @@ export class SortFilterBar
|
|
|
378
398
|
class=${this.mobileSelectorVisible ? 'hidden' : 'visible'}
|
|
379
399
|
>
|
|
380
400
|
<ul id="desktop-sort-selector">
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
if (this.finalizedSortField !== SortField.relevance) {
|
|
387
|
-
this.clearAlphaBarFilters();
|
|
388
|
-
this.setSelectedSort(SortField.relevance);
|
|
389
|
-
}
|
|
390
|
-
},
|
|
391
|
-
})}
|
|
392
|
-
</li>`
|
|
393
|
-
: nothing}
|
|
394
|
-
<li>${this.viewsDropdownTemplate}</li>
|
|
395
|
-
<li>
|
|
396
|
-
${this.getSortDisplayOption(SortField.title, {
|
|
397
|
-
onClick: () => {
|
|
398
|
-
this.dropdownBackdropVisible = false;
|
|
399
|
-
if (this.finalizedSortField !== SortField.title) {
|
|
400
|
-
this.alphaSelectorVisible = 'title';
|
|
401
|
-
this.selectedCreatorFilter = null;
|
|
402
|
-
this.setSelectedSort(SortField.title);
|
|
403
|
-
this.emitCreatorLetterChangedEvent();
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
})}
|
|
407
|
-
</li>
|
|
408
|
-
<li>${this.dateDropdownTemplate}</li>
|
|
409
|
-
<li>
|
|
410
|
-
${this.getSortDisplayOption(SortField.creator, {
|
|
411
|
-
onClick: () => {
|
|
412
|
-
this.dropdownBackdropVisible = false;
|
|
413
|
-
if (this.finalizedSortField !== SortField.creator) {
|
|
414
|
-
this.alphaSelectorVisible = 'creator';
|
|
415
|
-
this.selectedTitleFilter = null;
|
|
416
|
-
this.setSelectedSort(SortField.creator);
|
|
417
|
-
this.emitTitleLetterChangedEvent();
|
|
418
|
-
}
|
|
419
|
-
},
|
|
420
|
-
})}
|
|
421
|
-
</li>
|
|
401
|
+
<li>${this.relevanceSortSelectorTemplate}</li>
|
|
402
|
+
<li>${this.allViewsSortOptionsTemplate}</li>
|
|
403
|
+
<li>${this.titleSortSelectorTemplate}</li>
|
|
404
|
+
<li>${this.allDateSortOptionsTemplate}</li>
|
|
405
|
+
<li>${this.creatorSortSelectorTemplate}</li>
|
|
422
406
|
</ul>
|
|
423
407
|
</div>
|
|
424
408
|
`;
|
|
@@ -426,12 +410,9 @@ export class SortFilterBar
|
|
|
426
410
|
|
|
427
411
|
/** The template to render all the sort options in mobile view */
|
|
428
412
|
private get mobileSortSelectorTemplate() {
|
|
429
|
-
const displayedOptions = Object.values(SORT_OPTIONS)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
.filter(
|
|
433
|
-
opt => this.showDateFavorited || opt.field !== SortField.datefavorited,
|
|
434
|
-
);
|
|
413
|
+
const displayedOptions = Object.values(SORT_OPTIONS).filter(
|
|
414
|
+
opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],
|
|
415
|
+
);
|
|
435
416
|
|
|
436
417
|
return html`
|
|
437
418
|
<div
|
|
@@ -439,7 +420,7 @@ export class SortFilterBar
|
|
|
439
420
|
class=${this.mobileSelectorVisible ? 'visible' : 'hidden'}
|
|
440
421
|
>
|
|
441
422
|
${this.getSortDropdown({
|
|
442
|
-
displayName:
|
|
423
|
+
displayName: SORT_OPTIONS[this.finalizedSortField].displayName,
|
|
443
424
|
id: 'mobile-dropdown',
|
|
444
425
|
selected: true,
|
|
445
426
|
dropdownOptions: displayedOptions.map(opt =>
|
|
@@ -460,37 +441,37 @@ export class SortFilterBar
|
|
|
460
441
|
}
|
|
461
442
|
|
|
462
443
|
/**
|
|
463
|
-
* This generates each of the non-dropdown sort option
|
|
444
|
+
* This generates each of the non-dropdown sort option buttons.
|
|
464
445
|
*
|
|
465
446
|
* It manages the display value and the selected state of the option.
|
|
466
447
|
*
|
|
467
|
-
* @param sortField
|
|
468
|
-
* @param options
|
|
469
|
-
*
|
|
470
|
-
*
|
|
471
|
-
* selected?: boolean; true if the option is selected. Defaults to the selectedSort === sortField.
|
|
472
|
-
* }
|
|
473
|
-
* @returns
|
|
448
|
+
* @param sortField Which sort field the button represents
|
|
449
|
+
* @param options Additional options:
|
|
450
|
+
* - `onSelected?: (e: Event) => void;` If this is provided, it will also be called when the option is selected.
|
|
451
|
+
* Default is to clear any selected alphabetical filters.
|
|
474
452
|
*/
|
|
475
|
-
private
|
|
453
|
+
private getSortSelectorButton(
|
|
476
454
|
sortField: SortField,
|
|
477
455
|
options?: {
|
|
478
|
-
|
|
479
|
-
selected?: boolean;
|
|
480
|
-
onClick?: (e: Event) => void;
|
|
456
|
+
onSelected?: (e: Event) => void;
|
|
481
457
|
},
|
|
482
458
|
): TemplateResult {
|
|
483
|
-
const isSelected =
|
|
484
|
-
|
|
485
|
-
const
|
|
486
|
-
options?.
|
|
459
|
+
const isSelected = this.finalizedSortField === sortField;
|
|
460
|
+
const displayName = SORT_OPTIONS[sortField].displayName;
|
|
461
|
+
const onSelected =
|
|
462
|
+
options?.onSelected ?? (() => this.clearAlphaBarFilters());
|
|
463
|
+
|
|
487
464
|
return html`
|
|
488
465
|
<button
|
|
489
|
-
class=${isSelected ? 'selected' :
|
|
490
|
-
data-title
|
|
466
|
+
class=${isSelected ? 'selected' : ''}
|
|
467
|
+
data-title=${displayName}
|
|
491
468
|
@click=${(e: Event) => {
|
|
492
469
|
e.preventDefault();
|
|
493
|
-
|
|
470
|
+
this.dropdownBackdropVisible = false;
|
|
471
|
+
if (this.finalizedSortField !== sortField) {
|
|
472
|
+
onSelected?.(e);
|
|
473
|
+
this.setSelectedSort(sortField);
|
|
474
|
+
}
|
|
494
475
|
}}
|
|
495
476
|
>
|
|
496
477
|
${displayName}
|
|
@@ -513,8 +494,8 @@ export class SortFilterBar
|
|
|
513
494
|
* on the dropdown's label
|
|
514
495
|
*/
|
|
515
496
|
private getSortDropdown(options: {
|
|
516
|
-
displayName:
|
|
517
|
-
id
|
|
497
|
+
displayName: string;
|
|
498
|
+
id: string;
|
|
518
499
|
dropdownOptions: optionInterface[];
|
|
519
500
|
selectedOption?: string;
|
|
520
501
|
selected: boolean;
|
|
@@ -524,8 +505,8 @@ export class SortFilterBar
|
|
|
524
505
|
}): TemplateResult {
|
|
525
506
|
return html`
|
|
526
507
|
<ia-dropdown
|
|
527
|
-
id=${options.id
|
|
528
|
-
class=${options.selected ? 'selected' :
|
|
508
|
+
id=${options.id}
|
|
509
|
+
class=${options.selected ? 'selected' : ''}
|
|
529
510
|
displayCaret
|
|
530
511
|
closeOnSelect
|
|
531
512
|
includeSelectedOption
|
|
@@ -538,7 +519,7 @@ export class SortFilterBar
|
|
|
538
519
|
<span
|
|
539
520
|
class="dropdown-label"
|
|
540
521
|
slot="dropdown-label"
|
|
541
|
-
data-title
|
|
522
|
+
data-title=${options.displayName}
|
|
542
523
|
@click=${options.onLabelInteraction ?? nothing}
|
|
543
524
|
@keydown=${options.onLabelInteraction
|
|
544
525
|
? (e: KeyboardEvent) => {
|
|
@@ -577,31 +558,102 @@ export class SortFilterBar
|
|
|
577
558
|
const sortField = e.detail.option.id as SortField;
|
|
578
559
|
this.setSelectedSort(sortField);
|
|
579
560
|
if (this.viewOptionSelected) {
|
|
580
|
-
this.lastSelectedViewSort = sortField;
|
|
561
|
+
this.lastSelectedViewSort = sortField as ViewsSortField;
|
|
581
562
|
} else if (this.dateOptionSelected) {
|
|
582
|
-
this.lastSelectedDateSort = sortField;
|
|
563
|
+
this.lastSelectedDateSort = sortField as DateSortField;
|
|
583
564
|
}
|
|
584
565
|
}
|
|
585
566
|
|
|
586
|
-
|
|
567
|
+
//
|
|
568
|
+
// SORT OPTION TEMPLATES
|
|
569
|
+
//
|
|
570
|
+
|
|
571
|
+
/**
|
|
572
|
+
* Template for the Relevance sort selector button, or `nothing` if the relevance
|
|
573
|
+
* field is not available for display.
|
|
574
|
+
*/
|
|
575
|
+
private get relevanceSortSelectorTemplate(): TemplateResult | typeof nothing {
|
|
576
|
+
if (!this.sortFieldAvailability.relevance) return nothing;
|
|
577
|
+
return this.getSortSelectorButton(SortField.relevance);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* Template for the Views sort selector button.
|
|
582
|
+
* This is shown instead of the views dropdown when only a single views sort field
|
|
583
|
+
* is available.
|
|
584
|
+
*/
|
|
585
|
+
private get viewsSortSelectorTemplate(): TemplateResult | typeof nothing {
|
|
586
|
+
const { availableViewsFields } = this;
|
|
587
|
+
if (availableViewsFields.length < 1) return nothing;
|
|
588
|
+
return this.getSortSelectorButton(availableViewsFields[0]);
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/**
|
|
592
|
+
* Template for the Title sort selector button, or `nothing` if the title field is
|
|
593
|
+
* not available for display.
|
|
594
|
+
*/
|
|
595
|
+
private get titleSortSelectorTemplate(): TemplateResult | typeof nothing {
|
|
596
|
+
if (!this.sortFieldAvailability.title) return nothing;
|
|
597
|
+
|
|
598
|
+
return this.getSortSelectorButton(SortField.title, {
|
|
599
|
+
onSelected: () => {
|
|
600
|
+
this.alphaSelectorVisible = 'title';
|
|
601
|
+
this.selectedCreatorFilter = null;
|
|
602
|
+
this.emitCreatorLetterChangedEvent();
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
/**
|
|
608
|
+
* Template for the Date sort selector button.
|
|
609
|
+
* This is shown instead of the dates dropdown when only a single date sort field
|
|
610
|
+
* is available.
|
|
611
|
+
*/
|
|
612
|
+
private get dateSortSelectorTemplate(): TemplateResult | typeof nothing {
|
|
613
|
+
const { availableDateFields } = this;
|
|
614
|
+
if (availableDateFields.length < 1) return nothing;
|
|
615
|
+
return this.getSortSelectorButton(availableDateFields[0]);
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
/**
|
|
619
|
+
* Template for the Creator sort selector button, or `nothing` if the creator field
|
|
620
|
+
* is not available for display.
|
|
621
|
+
*/
|
|
622
|
+
private get creatorSortSelectorTemplate(): TemplateResult | typeof nothing {
|
|
623
|
+
if (!this.sortFieldAvailability.creator) return nothing;
|
|
624
|
+
|
|
625
|
+
return this.getSortSelectorButton(SortField.creator, {
|
|
626
|
+
onSelected: () => {
|
|
627
|
+
this.alphaSelectorVisible = 'creator';
|
|
628
|
+
this.selectedTitleFilter = null;
|
|
629
|
+
this.emitTitleLetterChangedEvent();
|
|
630
|
+
},
|
|
631
|
+
});
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
/**
|
|
635
|
+
* Template for the Views dropdown, shown when 2+ views sort fields are available.
|
|
636
|
+
*/
|
|
587
637
|
private get viewsDropdownTemplate(): TemplateResult {
|
|
638
|
+
const displayedOptions = ALL_VIEWS_SORT_FIELDS.filter(
|
|
639
|
+
field => this.sortFieldAvailability[field],
|
|
640
|
+
).map(field => this.getDropdownOption(field));
|
|
641
|
+
|
|
588
642
|
return this.getSortDropdown({
|
|
589
|
-
displayName:
|
|
643
|
+
displayName: this.viewSortDisplayName,
|
|
590
644
|
id: 'views-dropdown',
|
|
591
645
|
selected: this.viewOptionSelected,
|
|
592
|
-
dropdownOptions:
|
|
593
|
-
this.getDropdownOption(SortField.weeklyview),
|
|
594
|
-
this.getDropdownOption(SortField.alltimeview),
|
|
595
|
-
],
|
|
646
|
+
dropdownOptions: displayedOptions,
|
|
596
647
|
selectedOption: this.viewOptionSelected ? this.finalizedSortField : '',
|
|
597
648
|
onOptionSelected: this.dropdownOptionSelected,
|
|
598
649
|
onDropdownClick: () => {
|
|
599
|
-
this.dateDropdown.open = false;
|
|
600
|
-
|
|
601
|
-
this.
|
|
650
|
+
if (this.dateDropdown) this.dateDropdown.open = false;
|
|
651
|
+
const viewsDropdown = this.viewsDropdown as IaDropdown;
|
|
652
|
+
this.dropdownBackdropVisible = viewsDropdown.open;
|
|
653
|
+
viewsDropdown.classList.toggle('open', viewsDropdown.open);
|
|
602
654
|
},
|
|
603
655
|
onLabelInteraction: (e: Event) => {
|
|
604
|
-
if (!this.viewsDropdown
|
|
656
|
+
if (!this.viewsDropdown?.open && !this.viewOptionSelected) {
|
|
605
657
|
e.stopPropagation();
|
|
606
658
|
this.clearAlphaBarFilters();
|
|
607
659
|
this.setSelectedSort(this.lastSelectedViewSort);
|
|
@@ -610,30 +662,29 @@ export class SortFilterBar
|
|
|
610
662
|
});
|
|
611
663
|
}
|
|
612
664
|
|
|
613
|
-
/**
|
|
665
|
+
/**
|
|
666
|
+
* Template for the Date dropdown, shown when 2+ date sort fields are available.
|
|
667
|
+
*/
|
|
614
668
|
private get dateDropdownTemplate(): TemplateResult {
|
|
669
|
+
const displayedOptions = ALL_DATE_SORT_FIELDS.filter(
|
|
670
|
+
field => this.sortFieldAvailability[field],
|
|
671
|
+
).map(field => this.getDropdownOption(field));
|
|
672
|
+
|
|
615
673
|
return this.getSortDropdown({
|
|
616
|
-
displayName:
|
|
674
|
+
displayName: this.dateSortDisplayName,
|
|
617
675
|
id: 'date-dropdown',
|
|
618
676
|
selected: this.dateOptionSelected,
|
|
619
|
-
dropdownOptions:
|
|
620
|
-
...(this.showDateFavorited
|
|
621
|
-
? [this.getDropdownOption(SortField.datefavorited)]
|
|
622
|
-
: []),
|
|
623
|
-
this.getDropdownOption(SortField.date),
|
|
624
|
-
this.getDropdownOption(SortField.datearchived),
|
|
625
|
-
this.getDropdownOption(SortField.datereviewed),
|
|
626
|
-
this.getDropdownOption(SortField.dateadded),
|
|
627
|
-
],
|
|
677
|
+
dropdownOptions: displayedOptions,
|
|
628
678
|
selectedOption: this.dateOptionSelected ? this.finalizedSortField : '',
|
|
629
679
|
onOptionSelected: this.dropdownOptionSelected,
|
|
630
680
|
onDropdownClick: () => {
|
|
631
|
-
this.viewsDropdown.open = false;
|
|
632
|
-
|
|
633
|
-
this.
|
|
681
|
+
if (this.viewsDropdown) this.viewsDropdown.open = false;
|
|
682
|
+
const dateDropdown = this.dateDropdown as IaDropdown;
|
|
683
|
+
this.dropdownBackdropVisible = dateDropdown.open;
|
|
684
|
+
dateDropdown.classList.toggle('open', dateDropdown.open);
|
|
634
685
|
},
|
|
635
686
|
onLabelInteraction: (e: Event) => {
|
|
636
|
-
if (!this.dateDropdown
|
|
687
|
+
if (!this.dateDropdown?.open && !this.dateOptionSelected) {
|
|
637
688
|
e.stopPropagation();
|
|
638
689
|
this.clearAlphaBarFilters();
|
|
639
690
|
this.setSelectedSort(this.lastSelectedDateSort);
|
|
@@ -642,6 +693,38 @@ export class SortFilterBar
|
|
|
642
693
|
});
|
|
643
694
|
}
|
|
644
695
|
|
|
696
|
+
/**
|
|
697
|
+
* Provides the appropriate template to use for Views sorting, depending on how many
|
|
698
|
+
* views sort fields are available.
|
|
699
|
+
*/
|
|
700
|
+
private get allViewsSortOptionsTemplate(): TemplateResult | typeof nothing {
|
|
701
|
+
const numViewsSortOptions = this.availableViewsFields.length;
|
|
702
|
+
switch (numViewsSortOptions) {
|
|
703
|
+
case 0:
|
|
704
|
+
return nothing;
|
|
705
|
+
case 1:
|
|
706
|
+
return this.viewsSortSelectorTemplate;
|
|
707
|
+
default:
|
|
708
|
+
return this.viewsDropdownTemplate;
|
|
709
|
+
}
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* Provides the appropriate template to use for Date sorting, depending on how many
|
|
714
|
+
* date sort fields are available.
|
|
715
|
+
*/
|
|
716
|
+
private get allDateSortOptionsTemplate(): TemplateResult | typeof nothing {
|
|
717
|
+
const numDateSortOptions = this.availableDateFields.length;
|
|
718
|
+
switch (numDateSortOptions) {
|
|
719
|
+
case 0:
|
|
720
|
+
return nothing;
|
|
721
|
+
case 1:
|
|
722
|
+
return this.dateSortSelectorTemplate;
|
|
723
|
+
default:
|
|
724
|
+
return this.dateDropdownTemplate;
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
645
728
|
/** Handler for when a new mobile sort dropdown option is selected */
|
|
646
729
|
private mobileSortChanged(e: CustomEvent<{ option: optionInterface }>) {
|
|
647
730
|
this.dropdownBackdropVisible = false;
|
|
@@ -731,6 +814,7 @@ export class SortFilterBar
|
|
|
731
814
|
this.mobileDropdown,
|
|
732
815
|
];
|
|
733
816
|
for (const dropdown of allDropdowns) {
|
|
817
|
+
if (!dropdown) continue;
|
|
734
818
|
dropdown.open = false;
|
|
735
819
|
dropdown.classList.remove('open');
|
|
736
820
|
}
|
|
@@ -844,14 +928,6 @@ export class SortFilterBar
|
|
|
844
928
|
return viewSortFields.includes(this.finalizedSortField);
|
|
845
929
|
}
|
|
846
930
|
|
|
847
|
-
/**
|
|
848
|
-
* The default field for the date sort dropdown.
|
|
849
|
-
* This is Date Favorited when that option is available, or Date Published otherwise.
|
|
850
|
-
*/
|
|
851
|
-
private get defaultDateSortField(): SortField {
|
|
852
|
-
return this.showDateFavorited ? SortField.datefavorited : SortField.date;
|
|
853
|
-
}
|
|
854
|
-
|
|
855
931
|
/**
|
|
856
932
|
* The display name of the last selected date field
|
|
857
933
|
*
|
|
@@ -876,6 +952,24 @@ export class SortFilterBar
|
|
|
876
952
|
return SORT_OPTIONS[this.lastSelectedViewSort].displayName;
|
|
877
953
|
}
|
|
878
954
|
|
|
955
|
+
/**
|
|
956
|
+
* Array of all the views sorts that should be shown
|
|
957
|
+
*/
|
|
958
|
+
private get availableViewsFields(): SortField[] {
|
|
959
|
+
return ALL_VIEWS_SORT_FIELDS.filter(
|
|
960
|
+
field => this.sortFieldAvailability[field],
|
|
961
|
+
);
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
/**
|
|
965
|
+
* Array of all the date sorts that should be shown
|
|
966
|
+
*/
|
|
967
|
+
private get availableDateFields(): SortField[] {
|
|
968
|
+
return ALL_DATE_SORT_FIELDS.filter(
|
|
969
|
+
field => this.sortFieldAvailability[field],
|
|
970
|
+
);
|
|
971
|
+
}
|
|
972
|
+
|
|
879
973
|
private get titleSelectorBar() {
|
|
880
974
|
return html` <alpha-bar
|
|
881
975
|
.selectedLetter=${this.selectedTitleFilter}
|