seriesFor: India (sheet null) is its own 1-of-1 series

seriesFor skipped any country without a sheet size, so India's packet page 1
from the Regions tab printed "map 1 of 0", while the Country Posters wall's
own inline copy printed "map 1 of 1". A null sheet is now a tier like any
other. A country absent from the list (a host's code with no poster) still
gets no series, so the renderer keeps its default rather than a made-up
position.
This commit is contained in:
Doxa Maps 2026-09-30 21:12:22 +00:00
parent f8de00edf7
commit ea9211a5f9

View file

@ -1,7 +1,8 @@
/**
* countrySheet.js — a country's map sheet, GENERATED in the browser at the click.
*
* SHARED (@map/packet/countrySheet.js). Its caller is the regions dashboard's regions-list.
* SHARED (@map/packet/countrySheet.js). Its callers are the regions dashboard's regions-list and the
* Country Posters wall (country-poster-wall.vue), which used to define its own inline copy.
*
* ⚠ THE MOVE HERE WAS NEVER FINISHED, and it cost a real defect. This module's comment used to claim
* two consumers -- the country-poster wall and <doxa-country-map> -- and a CENSUS of the tree found
@ -14,7 +15,8 @@
* `country` without a region -- so countryRegionColor(undefined) returned the old flat teal and
* warned. The same country then printed HUED from Country Posters and TEAL from the Regions tab,
* which is exactly the "two different posters for one country" the hue change exists to refuse.
* The copy is deleted and regions-list imports this. Do not re-copy it: a duplicate of this file is
* The copy is deleted, and regions-list and the wall both import this (check:country-sheet-one-path
* refuses a caller that draws a country sheet any other way). Do not re-copy it: a duplicate of this file is
* indistinguishable from it until one of them is edited, and then it is a silent divergence.
*
* The print standard is generate, store only previews: no country sheet is shipped, and none should
@ -52,12 +54,16 @@
* not introduced by the one-definition change: the plugin-local copy regions-list used before it
* passed no series either. The wall was never affected because it computes its own.
*
* Returns undefined when the item has no sheet tier, so a row without a poster keeps the renderer's
* own default rather than a fabricated position.
* Returns undefined when the item is not in the list (a host's country with no poster), so that row
* keeps the renderer's own default rather than a fabricated position.
*
* A null sheet is a tier too: India (sheet null, too many groups for any paper size) is its own
* 1-of-1 series. Skipping it printed "map 1 of 0" on India's packet page 1 from the Regions tab
* while the wall's own copy printed "map 1 of 1" -- the two paths disagreeing again.
*/
export function seriesFor(countries, item) {
if (!item || !item.sheet || !Array.isArray(countries)) return undefined
const tier = countries.filter((x) => x.sheet === item.sheet)
if (!item || !Array.isArray(countries)) return undefined
const tier = countries.filter((x) => (x.sheet ?? null) === (item.sheet ?? null))
const index = tier.findIndex((x) => x.id === item.id) + 1
if (!index) return undefined
return { totalGroups: tier.reduce((a, x) => a + (x.count || 0), 0), totalLists: tier.length, index }