@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
|
@@ -3,7 +3,7 @@ import { LitElement, html, css, nothing, } from 'lit';
|
|
|
3
3
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
4
|
import { msg } from '@lit/localize';
|
|
5
5
|
import '@internetarchive/ia-dropdown';
|
|
6
|
-
import { SORT_OPTIONS, SortField, } from '../models';
|
|
6
|
+
import { ALL_DATE_SORT_FIELDS, ALL_VIEWS_SORT_FIELDS, defaultSortAvailability, SORT_OPTIONS, SortField, } from '../models';
|
|
7
7
|
import './alpha-bar';
|
|
8
8
|
import { sortUpIcon } from './img/sort-toggle-up';
|
|
9
9
|
import { sortDownIcon } from './img/sort-toggle-down';
|
|
@@ -19,6 +19,10 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
19
19
|
this.defaultSortDirection = null;
|
|
20
20
|
/** The default sort field to use if none is set */
|
|
21
21
|
this.defaultSortField = SortField.relevance;
|
|
22
|
+
/** Which view sort option to expose by default. */
|
|
23
|
+
this.defaultViewSort = SortField.weeklyview;
|
|
24
|
+
/** Which date sort option to expose by default */
|
|
25
|
+
this.defaultDateSort = SortField.date;
|
|
22
26
|
/** The current sort direction (asc/desc), or null if none is set */
|
|
23
27
|
this.sortDirection = null;
|
|
24
28
|
/** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
|
|
@@ -27,10 +31,20 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
27
31
|
this.selectedTitleFilter = null;
|
|
28
32
|
/** The currently selected creator letter filter, or null if none is set */
|
|
29
33
|
this.selectedCreatorFilter = null;
|
|
30
|
-
/**
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Map defining which sortable fields should be included on the sort bar.
|
|
36
|
+
*
|
|
37
|
+
* E.g.,
|
|
38
|
+
* ```
|
|
39
|
+
* {
|
|
40
|
+
* [SortField.relevance]: true,
|
|
41
|
+
* [SortField.date]: false,
|
|
42
|
+
* [SortField.title]: true,
|
|
43
|
+
* ...
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
this.sortFieldAvailability = defaultSortAvailability;
|
|
34
48
|
/** Whether to replace the default sort options with a slot for customization (default `false`) */
|
|
35
49
|
this.enableSortOptionsSlot = false;
|
|
36
50
|
/** Whether to suppress showing the three display mode options on the right of the bar (default `false`) */
|
|
@@ -38,11 +52,11 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
38
52
|
/**
|
|
39
53
|
* The Views sort option that was most recently selected (or the default, if none has been selected yet)
|
|
40
54
|
*/
|
|
41
|
-
this.lastSelectedViewSort =
|
|
55
|
+
this.lastSelectedViewSort = this.defaultViewSort;
|
|
42
56
|
/**
|
|
43
57
|
* The Date sort option that was most recently selected (or the default, if none has been selected yet)
|
|
44
58
|
*/
|
|
45
|
-
this.lastSelectedDateSort = this.
|
|
59
|
+
this.lastSelectedDateSort = this.defaultDateSort;
|
|
46
60
|
/**
|
|
47
61
|
* Which of the alphabet bars (title/creator) should be shown, or null if one
|
|
48
62
|
* should not currently be rendered.
|
|
@@ -119,11 +133,12 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
119
133
|
this.lastSelectedDateSort = this.finalizedSortField;
|
|
120
134
|
}
|
|
121
135
|
}
|
|
122
|
-
// If we change which dropdown options are
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
136
|
+
// If we change which dropdown options are defaulted, update the default selections
|
|
137
|
+
if (changed.has('defaultViewSort')) {
|
|
138
|
+
this.lastSelectedViewSort = this.defaultViewSort;
|
|
139
|
+
}
|
|
140
|
+
if (changed.has('defaultDateSort')) {
|
|
141
|
+
this.lastSelectedDateSort = this.defaultDateSort;
|
|
127
142
|
}
|
|
128
143
|
}
|
|
129
144
|
updated(changed) {
|
|
@@ -265,64 +280,25 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
265
280
|
class=${this.mobileSelectorVisible ? 'hidden' : 'visible'}
|
|
266
281
|
>
|
|
267
282
|
<ul id="desktop-sort-selector">
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
if (this.finalizedSortField !== SortField.relevance) {
|
|
274
|
-
this.clearAlphaBarFilters();
|
|
275
|
-
this.setSelectedSort(SortField.relevance);
|
|
276
|
-
}
|
|
277
|
-
},
|
|
278
|
-
})}
|
|
279
|
-
</li>`
|
|
280
|
-
: nothing}
|
|
281
|
-
<li>${this.viewsDropdownTemplate}</li>
|
|
282
|
-
<li>
|
|
283
|
-
${this.getSortDisplayOption(SortField.title, {
|
|
284
|
-
onClick: () => {
|
|
285
|
-
this.dropdownBackdropVisible = false;
|
|
286
|
-
if (this.finalizedSortField !== SortField.title) {
|
|
287
|
-
this.alphaSelectorVisible = 'title';
|
|
288
|
-
this.selectedCreatorFilter = null;
|
|
289
|
-
this.setSelectedSort(SortField.title);
|
|
290
|
-
this.emitCreatorLetterChangedEvent();
|
|
291
|
-
}
|
|
292
|
-
},
|
|
293
|
-
})}
|
|
294
|
-
</li>
|
|
295
|
-
<li>${this.dateDropdownTemplate}</li>
|
|
296
|
-
<li>
|
|
297
|
-
${this.getSortDisplayOption(SortField.creator, {
|
|
298
|
-
onClick: () => {
|
|
299
|
-
this.dropdownBackdropVisible = false;
|
|
300
|
-
if (this.finalizedSortField !== SortField.creator) {
|
|
301
|
-
this.alphaSelectorVisible = 'creator';
|
|
302
|
-
this.selectedTitleFilter = null;
|
|
303
|
-
this.setSelectedSort(SortField.creator);
|
|
304
|
-
this.emitTitleLetterChangedEvent();
|
|
305
|
-
}
|
|
306
|
-
},
|
|
307
|
-
})}
|
|
308
|
-
</li>
|
|
283
|
+
<li>${this.relevanceSortSelectorTemplate}</li>
|
|
284
|
+
<li>${this.allViewsSortOptionsTemplate}</li>
|
|
285
|
+
<li>${this.titleSortSelectorTemplate}</li>
|
|
286
|
+
<li>${this.allDateSortOptionsTemplate}</li>
|
|
287
|
+
<li>${this.creatorSortSelectorTemplate}</li>
|
|
309
288
|
</ul>
|
|
310
289
|
</div>
|
|
311
290
|
`;
|
|
312
291
|
}
|
|
313
292
|
/** The template to render all the sort options in mobile view */
|
|
314
293
|
get mobileSortSelectorTemplate() {
|
|
315
|
-
const displayedOptions = Object.values(SORT_OPTIONS)
|
|
316
|
-
.filter(opt => opt.shownInSortBar)
|
|
317
|
-
.filter(opt => this.showRelevance || opt.field !== SortField.relevance)
|
|
318
|
-
.filter(opt => this.showDateFavorited || opt.field !== SortField.datefavorited);
|
|
294
|
+
const displayedOptions = Object.values(SORT_OPTIONS).filter(opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field]);
|
|
319
295
|
return html `
|
|
320
296
|
<div
|
|
321
297
|
id="mobile-sort-container"
|
|
322
298
|
class=${this.mobileSelectorVisible ? 'visible' : 'hidden'}
|
|
323
299
|
>
|
|
324
300
|
${this.getSortDropdown({
|
|
325
|
-
displayName:
|
|
301
|
+
displayName: SORT_OPTIONS[this.finalizedSortField].displayName,
|
|
326
302
|
id: 'mobile-dropdown',
|
|
327
303
|
selected: true,
|
|
328
304
|
dropdownOptions: displayedOptions.map(opt => this.getDropdownOption(opt.field)),
|
|
@@ -337,30 +313,31 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
337
313
|
`;
|
|
338
314
|
}
|
|
339
315
|
/**
|
|
340
|
-
* This generates each of the non-dropdown sort option
|
|
316
|
+
* This generates each of the non-dropdown sort option buttons.
|
|
341
317
|
*
|
|
342
318
|
* It manages the display value and the selected state of the option.
|
|
343
319
|
*
|
|
344
|
-
* @param sortField
|
|
345
|
-
* @param options
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
* selected?: boolean; true if the option is selected. Defaults to the selectedSort === sortField.
|
|
349
|
-
* }
|
|
350
|
-
* @returns
|
|
320
|
+
* @param sortField Which sort field the button represents
|
|
321
|
+
* @param options Additional options:
|
|
322
|
+
* - `onSelected?: (e: Event) => void;` If this is provided, it will also be called when the option is selected.
|
|
323
|
+
* Default is to clear any selected alphabetical filters.
|
|
351
324
|
*/
|
|
352
|
-
|
|
353
|
-
var _a
|
|
354
|
-
const isSelected =
|
|
355
|
-
const displayName =
|
|
325
|
+
getSortSelectorButton(sortField, options) {
|
|
326
|
+
var _a;
|
|
327
|
+
const isSelected = this.finalizedSortField === sortField;
|
|
328
|
+
const displayName = SORT_OPTIONS[sortField].displayName;
|
|
329
|
+
const onSelected = (_a = options === null || options === void 0 ? void 0 : options.onSelected) !== null && _a !== void 0 ? _a : (() => this.clearAlphaBarFilters());
|
|
356
330
|
return html `
|
|
357
331
|
<button
|
|
358
|
-
class=${isSelected ? 'selected' :
|
|
359
|
-
data-title
|
|
332
|
+
class=${isSelected ? 'selected' : ''}
|
|
333
|
+
data-title=${displayName}
|
|
360
334
|
@click=${(e) => {
|
|
361
|
-
var _a;
|
|
362
335
|
e.preventDefault();
|
|
363
|
-
|
|
336
|
+
this.dropdownBackdropVisible = false;
|
|
337
|
+
if (this.finalizedSortField !== sortField) {
|
|
338
|
+
onSelected === null || onSelected === void 0 ? void 0 : onSelected(e);
|
|
339
|
+
this.setSelectedSort(sortField);
|
|
340
|
+
}
|
|
364
341
|
}}
|
|
365
342
|
>
|
|
366
343
|
${displayName}
|
|
@@ -382,25 +359,25 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
382
359
|
* on the dropdown's label
|
|
383
360
|
*/
|
|
384
361
|
getSortDropdown(options) {
|
|
385
|
-
var _a, _b, _c, _d
|
|
362
|
+
var _a, _b, _c, _d;
|
|
386
363
|
return html `
|
|
387
364
|
<ia-dropdown
|
|
388
|
-
id=${
|
|
389
|
-
class=${options.selected ? 'selected' :
|
|
365
|
+
id=${options.id}
|
|
366
|
+
class=${options.selected ? 'selected' : ''}
|
|
390
367
|
displayCaret
|
|
391
368
|
closeOnSelect
|
|
392
369
|
includeSelectedOption
|
|
393
370
|
.openViaButton=${options.selected}
|
|
394
371
|
.options=${options.dropdownOptions}
|
|
395
|
-
.selectedOption=${(
|
|
396
|
-
@optionSelected=${(
|
|
397
|
-
@click=${(
|
|
372
|
+
.selectedOption=${(_a = options.selectedOption) !== null && _a !== void 0 ? _a : ''}
|
|
373
|
+
@optionSelected=${(_b = options.onOptionSelected) !== null && _b !== void 0 ? _b : nothing}
|
|
374
|
+
@click=${(_c = options.onDropdownClick) !== null && _c !== void 0 ? _c : nothing}
|
|
398
375
|
>
|
|
399
376
|
<span
|
|
400
377
|
class="dropdown-label"
|
|
401
378
|
slot="dropdown-label"
|
|
402
|
-
data-title
|
|
403
|
-
@click=${(
|
|
379
|
+
data-title=${options.displayName}
|
|
380
|
+
@click=${(_d = options.onLabelInteraction) !== null && _d !== void 0 ? _d : nothing}
|
|
404
381
|
@keydown=${options.onLabelInteraction
|
|
405
382
|
? (e) => {
|
|
406
383
|
var _a;
|
|
@@ -442,25 +419,92 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
442
419
|
this.lastSelectedDateSort = sortField;
|
|
443
420
|
}
|
|
444
421
|
}
|
|
445
|
-
|
|
422
|
+
//
|
|
423
|
+
// SORT OPTION TEMPLATES
|
|
424
|
+
//
|
|
425
|
+
/**
|
|
426
|
+
* Template for the Relevance sort selector button, or `nothing` if the relevance
|
|
427
|
+
* field is not available for display.
|
|
428
|
+
*/
|
|
429
|
+
get relevanceSortSelectorTemplate() {
|
|
430
|
+
if (!this.sortFieldAvailability.relevance)
|
|
431
|
+
return nothing;
|
|
432
|
+
return this.getSortSelectorButton(SortField.relevance);
|
|
433
|
+
}
|
|
434
|
+
/**
|
|
435
|
+
* Template for the Views sort selector button.
|
|
436
|
+
* This is shown instead of the views dropdown when only a single views sort field
|
|
437
|
+
* is available.
|
|
438
|
+
*/
|
|
439
|
+
get viewsSortSelectorTemplate() {
|
|
440
|
+
const { availableViewsFields } = this;
|
|
441
|
+
if (availableViewsFields.length < 1)
|
|
442
|
+
return nothing;
|
|
443
|
+
return this.getSortSelectorButton(availableViewsFields[0]);
|
|
444
|
+
}
|
|
445
|
+
/**
|
|
446
|
+
* Template for the Title sort selector button, or `nothing` if the title field is
|
|
447
|
+
* not available for display.
|
|
448
|
+
*/
|
|
449
|
+
get titleSortSelectorTemplate() {
|
|
450
|
+
if (!this.sortFieldAvailability.title)
|
|
451
|
+
return nothing;
|
|
452
|
+
return this.getSortSelectorButton(SortField.title, {
|
|
453
|
+
onSelected: () => {
|
|
454
|
+
this.alphaSelectorVisible = 'title';
|
|
455
|
+
this.selectedCreatorFilter = null;
|
|
456
|
+
this.emitCreatorLetterChangedEvent();
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* Template for the Date sort selector button.
|
|
462
|
+
* This is shown instead of the dates dropdown when only a single date sort field
|
|
463
|
+
* is available.
|
|
464
|
+
*/
|
|
465
|
+
get dateSortSelectorTemplate() {
|
|
466
|
+
const { availableDateFields } = this;
|
|
467
|
+
if (availableDateFields.length < 1)
|
|
468
|
+
return nothing;
|
|
469
|
+
return this.getSortSelectorButton(availableDateFields[0]);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Template for the Creator sort selector button, or `nothing` if the creator field
|
|
473
|
+
* is not available for display.
|
|
474
|
+
*/
|
|
475
|
+
get creatorSortSelectorTemplate() {
|
|
476
|
+
if (!this.sortFieldAvailability.creator)
|
|
477
|
+
return nothing;
|
|
478
|
+
return this.getSortSelectorButton(SortField.creator, {
|
|
479
|
+
onSelected: () => {
|
|
480
|
+
this.alphaSelectorVisible = 'creator';
|
|
481
|
+
this.selectedTitleFilter = null;
|
|
482
|
+
this.emitTitleLetterChangedEvent();
|
|
483
|
+
},
|
|
484
|
+
});
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Template for the Views dropdown, shown when 2+ views sort fields are available.
|
|
488
|
+
*/
|
|
446
489
|
get viewsDropdownTemplate() {
|
|
490
|
+
const displayedOptions = ALL_VIEWS_SORT_FIELDS.filter(field => this.sortFieldAvailability[field]).map(field => this.getDropdownOption(field));
|
|
447
491
|
return this.getSortDropdown({
|
|
448
|
-
displayName:
|
|
492
|
+
displayName: this.viewSortDisplayName,
|
|
449
493
|
id: 'views-dropdown',
|
|
450
494
|
selected: this.viewOptionSelected,
|
|
451
|
-
dropdownOptions:
|
|
452
|
-
this.getDropdownOption(SortField.weeklyview),
|
|
453
|
-
this.getDropdownOption(SortField.alltimeview),
|
|
454
|
-
],
|
|
495
|
+
dropdownOptions: displayedOptions,
|
|
455
496
|
selectedOption: this.viewOptionSelected ? this.finalizedSortField : '',
|
|
456
497
|
onOptionSelected: this.dropdownOptionSelected,
|
|
457
498
|
onDropdownClick: () => {
|
|
458
|
-
this.dateDropdown
|
|
459
|
-
|
|
460
|
-
|
|
499
|
+
if (this.dateDropdown)
|
|
500
|
+
this.dateDropdown.open = false;
|
|
501
|
+
const viewsDropdown = this.viewsDropdown;
|
|
502
|
+
this.dropdownBackdropVisible = viewsDropdown.open;
|
|
503
|
+
viewsDropdown.classList.toggle('open', viewsDropdown.open);
|
|
461
504
|
},
|
|
462
505
|
onLabelInteraction: (e) => {
|
|
463
|
-
|
|
506
|
+
var _a;
|
|
507
|
+
if (!((_a = this.viewsDropdown) === null || _a === void 0 ? void 0 : _a.open) && !this.viewOptionSelected) {
|
|
464
508
|
e.stopPropagation();
|
|
465
509
|
this.clearAlphaBarFilters();
|
|
466
510
|
this.setSelectedSort(this.lastSelectedViewSort);
|
|
@@ -468,30 +512,28 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
468
512
|
},
|
|
469
513
|
});
|
|
470
514
|
}
|
|
471
|
-
/**
|
|
515
|
+
/**
|
|
516
|
+
* Template for the Date dropdown, shown when 2+ date sort fields are available.
|
|
517
|
+
*/
|
|
472
518
|
get dateDropdownTemplate() {
|
|
519
|
+
const displayedOptions = ALL_DATE_SORT_FIELDS.filter(field => this.sortFieldAvailability[field]).map(field => this.getDropdownOption(field));
|
|
473
520
|
return this.getSortDropdown({
|
|
474
|
-
displayName:
|
|
521
|
+
displayName: this.dateSortDisplayName,
|
|
475
522
|
id: 'date-dropdown',
|
|
476
523
|
selected: this.dateOptionSelected,
|
|
477
|
-
dropdownOptions:
|
|
478
|
-
...(this.showDateFavorited
|
|
479
|
-
? [this.getDropdownOption(SortField.datefavorited)]
|
|
480
|
-
: []),
|
|
481
|
-
this.getDropdownOption(SortField.date),
|
|
482
|
-
this.getDropdownOption(SortField.datearchived),
|
|
483
|
-
this.getDropdownOption(SortField.datereviewed),
|
|
484
|
-
this.getDropdownOption(SortField.dateadded),
|
|
485
|
-
],
|
|
524
|
+
dropdownOptions: displayedOptions,
|
|
486
525
|
selectedOption: this.dateOptionSelected ? this.finalizedSortField : '',
|
|
487
526
|
onOptionSelected: this.dropdownOptionSelected,
|
|
488
527
|
onDropdownClick: () => {
|
|
489
|
-
this.viewsDropdown
|
|
490
|
-
|
|
491
|
-
|
|
528
|
+
if (this.viewsDropdown)
|
|
529
|
+
this.viewsDropdown.open = false;
|
|
530
|
+
const dateDropdown = this.dateDropdown;
|
|
531
|
+
this.dropdownBackdropVisible = dateDropdown.open;
|
|
532
|
+
dateDropdown.classList.toggle('open', dateDropdown.open);
|
|
492
533
|
},
|
|
493
534
|
onLabelInteraction: (e) => {
|
|
494
|
-
|
|
535
|
+
var _a;
|
|
536
|
+
if (!((_a = this.dateDropdown) === null || _a === void 0 ? void 0 : _a.open) && !this.dateOptionSelected) {
|
|
495
537
|
e.stopPropagation();
|
|
496
538
|
this.clearAlphaBarFilters();
|
|
497
539
|
this.setSelectedSort(this.lastSelectedDateSort);
|
|
@@ -499,6 +541,36 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
499
541
|
},
|
|
500
542
|
});
|
|
501
543
|
}
|
|
544
|
+
/**
|
|
545
|
+
* Provides the appropriate template to use for Views sorting, depending on how many
|
|
546
|
+
* views sort fields are available.
|
|
547
|
+
*/
|
|
548
|
+
get allViewsSortOptionsTemplate() {
|
|
549
|
+
const numViewsSortOptions = this.availableViewsFields.length;
|
|
550
|
+
switch (numViewsSortOptions) {
|
|
551
|
+
case 0:
|
|
552
|
+
return nothing;
|
|
553
|
+
case 1:
|
|
554
|
+
return this.viewsSortSelectorTemplate;
|
|
555
|
+
default:
|
|
556
|
+
return this.viewsDropdownTemplate;
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* Provides the appropriate template to use for Date sorting, depending on how many
|
|
561
|
+
* date sort fields are available.
|
|
562
|
+
*/
|
|
563
|
+
get allDateSortOptionsTemplate() {
|
|
564
|
+
const numDateSortOptions = this.availableDateFields.length;
|
|
565
|
+
switch (numDateSortOptions) {
|
|
566
|
+
case 0:
|
|
567
|
+
return nothing;
|
|
568
|
+
case 1:
|
|
569
|
+
return this.dateSortSelectorTemplate;
|
|
570
|
+
default:
|
|
571
|
+
return this.dateDropdownTemplate;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
502
574
|
/** Handler for when a new mobile sort dropdown option is selected */
|
|
503
575
|
mobileSortChanged(e) {
|
|
504
576
|
this.dropdownBackdropVisible = false;
|
|
@@ -583,6 +655,8 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
583
655
|
this.mobileDropdown,
|
|
584
656
|
];
|
|
585
657
|
for (const dropdown of allDropdowns) {
|
|
658
|
+
if (!dropdown)
|
|
659
|
+
continue;
|
|
586
660
|
dropdown.open = false;
|
|
587
661
|
dropdown.classList.remove('open');
|
|
588
662
|
}
|
|
@@ -679,13 +753,6 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
679
753
|
];
|
|
680
754
|
return viewSortFields.includes(this.finalizedSortField);
|
|
681
755
|
}
|
|
682
|
-
/**
|
|
683
|
-
* The default field for the date sort dropdown.
|
|
684
|
-
* This is Date Favorited when that option is available, or Date Published otherwise.
|
|
685
|
-
*/
|
|
686
|
-
get defaultDateSortField() {
|
|
687
|
-
return this.showDateFavorited ? SortField.datefavorited : SortField.date;
|
|
688
|
-
}
|
|
689
756
|
/**
|
|
690
757
|
* The display name of the last selected date field
|
|
691
758
|
*
|
|
@@ -708,6 +775,18 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
708
775
|
get viewSortDisplayName() {
|
|
709
776
|
return SORT_OPTIONS[this.lastSelectedViewSort].displayName;
|
|
710
777
|
}
|
|
778
|
+
/**
|
|
779
|
+
* Array of all the views sorts that should be shown
|
|
780
|
+
*/
|
|
781
|
+
get availableViewsFields() {
|
|
782
|
+
return ALL_VIEWS_SORT_FIELDS.filter(field => this.sortFieldAvailability[field]);
|
|
783
|
+
}
|
|
784
|
+
/**
|
|
785
|
+
* Array of all the date sorts that should be shown
|
|
786
|
+
*/
|
|
787
|
+
get availableDateFields() {
|
|
788
|
+
return ALL_DATE_SORT_FIELDS.filter(field => this.sortFieldAvailability[field]);
|
|
789
|
+
}
|
|
711
790
|
get titleSelectorBar() {
|
|
712
791
|
var _a;
|
|
713
792
|
return html ` <alpha-bar
|
|
@@ -1009,6 +1088,12 @@ __decorate([
|
|
|
1009
1088
|
__decorate([
|
|
1010
1089
|
property({ type: String })
|
|
1011
1090
|
], SortFilterBar.prototype, "defaultSortField", void 0);
|
|
1091
|
+
__decorate([
|
|
1092
|
+
property({ type: String })
|
|
1093
|
+
], SortFilterBar.prototype, "defaultViewSort", void 0);
|
|
1094
|
+
__decorate([
|
|
1095
|
+
property({ type: String })
|
|
1096
|
+
], SortFilterBar.prototype, "defaultDateSort", void 0);
|
|
1012
1097
|
__decorate([
|
|
1013
1098
|
property({ type: String })
|
|
1014
1099
|
], SortFilterBar.prototype, "sortDirection", void 0);
|
|
@@ -1022,11 +1107,8 @@ __decorate([
|
|
|
1022
1107
|
property({ type: String })
|
|
1023
1108
|
], SortFilterBar.prototype, "selectedCreatorFilter", void 0);
|
|
1024
1109
|
__decorate([
|
|
1025
|
-
property({ type:
|
|
1026
|
-
], SortFilterBar.prototype, "
|
|
1027
|
-
__decorate([
|
|
1028
|
-
property({ type: Boolean })
|
|
1029
|
-
], SortFilterBar.prototype, "showDateFavorited", void 0);
|
|
1110
|
+
property({ type: Object })
|
|
1111
|
+
], SortFilterBar.prototype, "sortFieldAvailability", void 0);
|
|
1030
1112
|
__decorate([
|
|
1031
1113
|
property({ type: Boolean, reflect: true })
|
|
1032
1114
|
], SortFilterBar.prototype, "enableSortOptionsSlot", void 0);
|