PosterWall: an optional sectionTotal, so a section whose cards overlap counts its people groups once
A section's total (its header count, and what orders the sections) defaults to the sum of its cards' counts, unchanged for every wall that does not pass the prop. The Country Posters India section holds India's own card and one card per state and union territory (the same 855 groups twice), so it passes India's count instead.
This commit is contained in:
parent
fe43c966f3
commit
e16e204530
1 changed files with 5 additions and 1 deletions
|
|
@ -80,6 +80,10 @@ const props = defineProps({
|
|||
itemCountKey: { type: String, default: '' },
|
||||
collapsible: { type: Boolean, default: false },
|
||||
collapsedBy: { type: Function, default: () => false },
|
||||
// A section's people-group total, shown in its header and used to order the sections (largest first).
|
||||
// Default: the sum of its cards' counts. A caller whose cards overlap overrides it, so a group is counted
|
||||
// once: the Country Posters India section holds India's own card AND one card per state, the same 855 groups.
|
||||
sectionTotal: { type: Function, default: null },
|
||||
// A card may declare itself unsupported (India: 855 groups do not fit a sheet).
|
||||
// The caller supplies the reason; the wall renders it instead of a poster.
|
||||
unsupported: { type: Function, default: () => null },
|
||||
|
|
@ -351,7 +355,7 @@ const sections = computed(() => {
|
|||
.map(([name, items]) => ({
|
||||
name,
|
||||
items: items.slice().sort((a, b) => (b.count || 0) - (a.count || 0)),
|
||||
total: items.reduce((n, x) => n + (x.count || 0), 0),
|
||||
total: props.sectionTotal ? props.sectionTotal(name, items) : items.reduce((n, x) => n + (x.count || 0), 0),
|
||||
}))
|
||||
.sort((a, b) => b.total - a.total)
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in a new issue