Country Posters: India is its own section, first, above Asia, counted once
India's country card, its 34 state and union territory posters and the two with none listed now share one section, headed by India's name and counted once (855, through PosterWall's sectionTotal), which puts it above every regional section. One line at the top of the wall says why India is set apart. Asia keeps every other Asian country. check:country-sheet-one-path ARM E: the wall passes sectionTotal, India's card is in the India section, PosterWall's default is still the card sum, and over the real data India comes first with 855 (India 855 > Asia 454 > Africa 314).
This commit is contained in:
parent
eeaea4c3e9
commit
ddb7a4850c
2 changed files with 40 additions and 4 deletions
|
|
@ -191,8 +191,16 @@ async function countryMap(c) {
|
|||
// wall and the Regions dashboard cannot name one region two ways. A label with no key stays as drawn.
|
||||
const t = useOptionalT('')
|
||||
const regionSlug = (label) => String(label).toLowerCase().replace(/\s+/g, '_')
|
||||
// ★ INDIA IS ITS OWN SECTION, FIRST: India's country card, one card per state and union territory, and the two
|
||||
// with none listed. Its 855 groups are counted ONCE (sectionTotal below; the state cards are India's groups again),
|
||||
// and that true total is also what puts it above every other section. Headed by the country's own name.
|
||||
const wallLang = () => { const l = wallLocale && (wallLocale.value ?? wallLocale); return (typeof l === 'string' && l) || getRuntimeLocale() || detectLocale() || 'en' }
|
||||
const indiaHeading = () => (/^en\b/i.test(wallLang()) ? 'India' : countryName('IND', wallLang()) || 'India')
|
||||
const isIndia = (c) => c.indiaState || String(c.iso3 || '').toUpperCase() === 'IND'
|
||||
const INDIA_COUNT = (byIso3.get('IND') || {}).count || 0
|
||||
const sectionTotal = (name, items) => (items.some(isIndia) && INDIA_COUNT ? INDIA_COUNT : items.reduce((n, x) => n + (x.count || 0), 0))
|
||||
const groupBy = (c) => {
|
||||
if (c.indiaState) return t('countryPosters.indiaStatesHeading')
|
||||
if (isIndia(c)) return indiaHeading()
|
||||
if (!c.region || c.region === 'Other') return t('dashboard.other')
|
||||
const key = `dashboard.wagfRegion.${regionSlug(c.region)}`
|
||||
const v = t(key)
|
||||
|
|
@ -218,7 +226,9 @@ const unsupported = (c) => (c.noGroups ? t('countryPosters.indiaStateNoGroups')
|
|||
const escHtml = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
||||
const heading = computed(() => t('messages.countryWallHeading'))
|
||||
const wallTag = computed(() => t('messages.upg100WallTag'))
|
||||
const intro = computed(() => `${escHtml(t('messages.countryWallIntroA'))}<strong>${escHtml(t('messages.upg100WallIntroEmph'))}</strong>${escHtml(t('messages.countryWallIntroB'))}`)
|
||||
const intro = computed(() => `${escHtml(t('messages.countryWallIntroA'))}<strong>${escHtml(t('messages.upg100WallIntroEmph'))}</strong>${escHtml(t('messages.countryWallIntroB'))}`
|
||||
// Why India is first and different, in one line (only on the unfiltered wall, the only one that shows its section).
|
||||
+ (INDIA_COUNT ? `<br>${escHtml(t('countryPosters.indiaNote', { count: INDIA_COUNT }))}` : ''))
|
||||
const soonMessage = computed(() => t('messages.countryWallSoon'))
|
||||
</script>
|
||||
|
||||
|
|
@ -242,6 +252,7 @@ const soonMessage = computed(() => t('messages.countryWallSoon'))
|
|||
:map-image="countryMap"
|
||||
:collapsible="!filtered"
|
||||
:collapsed-by="filtered ? neverCollapsed : collapsedBy"
|
||||
:section-total="filtered ? null : sectionTotal"
|
||||
:section-heads="!filtered"
|
||||
:embedded="filtered"
|
||||
:columns="filtered ? hostColumns : 0"
|
||||
|
|
|
|||
|
|
@ -134,6 +134,28 @@ export function armC(H, states, adm1Ind) {
|
|||
return fails
|
||||
}
|
||||
|
||||
// ARM E: India is its OWN section, FIRST, counted ONCE. The India country card, the state cards and the none-listed
|
||||
// cards group together; the section's total is India's own count (not the card sum, which counts 855 twice); on that
|
||||
// true total it outranks every regional section. PosterWall's default (no sectionTotal) must still be the card sum.
|
||||
export function armE(countries, states, wallSrc, posterWallSrc, H) {
|
||||
const fails = []
|
||||
if (!/:section-total=/.test(wallSrc)) fails.push('country-poster-wall.vue does not pass :section-total, so India is counted twice')
|
||||
if (!/String\(c\.iso3[^)]*\)\.toUpperCase\(\) === 'IND'/.test(wallSrc)) fails.push("the wall's isIndia() no longer puts India's country card in the India section")
|
||||
if (!/props\.sectionTotal \? props\.sectionTotal\(name, items\) : items\.reduce\(\(n, x\) => n \+ \(x\.count \|\| 0\), 0\)/.test(posterWallSrc)) fails.push("PosterWall's default section total is no longer the card sum (every other wall would change)")
|
||||
const ind = countries.find((c) => c.iso3 === 'IND')
|
||||
const stateCards = [...H.statesWithPosters(states).map((st) => ({ count: st.count, indiaState: true })), ...states.filter((st) => !st.count).map(() => ({ count: 0, indiaState: true }))]
|
||||
const groups = new Map()
|
||||
for (const c of [...countries, ...stateCards]) {
|
||||
const g = c.indiaState || c.iso3 === 'IND' ? 'India' : (c.region || 'Other')
|
||||
if (!groups.has(g)) groups.set(g, []); groups.get(g).push(c)
|
||||
}
|
||||
const total = (g, items) => (g === 'India' ? ind.count : items.reduce((n, x) => n + (x.count || 0), 0))
|
||||
const order = [...groups].map(([g, items]) => [g, total(g, items)]).sort((a, b) => b[1] - a[1])
|
||||
if (order[0][0] !== 'India') fails.push(`India is not the first section: ${order.slice(0, 3).map(([g, t]) => `${g} ${t}`).join(', ')}`)
|
||||
if (order.find(([g]) => g === 'India')[1] !== ind.count) fails.push(`the India section counts ${order.find(([g]) => g === 'India')[1]}, not India's ${ind.count}`)
|
||||
return { fails, order }
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const selfTest = process.argv.includes('--self-test')
|
||||
const { seriesFor } = await import(join(ROOT, 'library/packet/countrySheet.js'))
|
||||
|
|
@ -160,6 +182,8 @@ async function main() {
|
|||
['the wall calls generateSheet directly', () => armA({ ...files, [wall]: files[wall].replace('<script setup>', "<script setup>\nimport { generateSheet } from '@map/packet/posterSheets.js'\ngenerateSheet({})") })],
|
||||
['a state with groups loses its outline', () => armC(H, states.map((st) => (st.id === 'india-gj' ? { ...st, shapeName: 'Nowhere' } : st)), adm1Ind)],
|
||||
['a division silently dropped', () => armC(H, states.filter((st) => st.id !== 'india-mz'), adm1Ind)],
|
||||
['the wall stops passing sectionTotal (India counted twice)', () => armE(countries, states, files[wall].replace(':section-total=', ':x-section-total='), readFileSync(join(ROOT, 'library/components/poster/PosterWall.vue'), 'utf8'), H).fails],
|
||||
['India country card left in Asia', () => armE(countries, states, files[wall].replace("=== 'IND'", "=== 'XXX'"), readFileSync(join(ROOT, 'library/components/poster/PosterWall.vue'), 'utf8'), H).fails],
|
||||
['a helper that mutates the shared ADM1', () => armC({ ...H, stateGeometry: (z, a, n) => { (a.features || []).forEach((f) => { if (f.properties.shapeName === n) f.properties.listId = z.id }); return H.stateGeometry(z, a, n) } }, states, JSON.parse(JSON.stringify(adm1Ind)))],
|
||||
]
|
||||
let bad = 0
|
||||
|
|
@ -177,12 +201,13 @@ async function main() {
|
|||
}
|
||||
|
||||
const callers = []
|
||||
const fails = [...armA(files, callers), ...armB(seriesFor, countries), ...armC(H, states, adm1Ind)]
|
||||
const E = armE(countries, states, files['plugin-designs/country-posters/country-poster-wall.vue'], readFileSync(join(ROOT, 'library/components/poster/PosterWall.vue'), 'utf8'), H)
|
||||
const fails = [...armA(files, callers), ...armB(seriesFor, countries), ...armC(H, states, adm1Ind), ...E.fails]
|
||||
const missing = [...KNOWN_CALLERS, `${STATE_CALLER}#state`].filter((k) => !callers.includes(k))
|
||||
if (missing.length) fails.push(`known callers not found calling makeCountrySheet: ${missing.join(', ')}`)
|
||||
if (fails.length) { fails.forEach((f) => console.log(`FAIL ${f}`)); process.exitCode = 1; return }
|
||||
const ind = seriesFor(countries, countries.find((c) => c.iso3 === 'IND'))
|
||||
console.log(`PASS check:country-sheet-one-path — ${Object.keys(files).length} plugin sources parsed-or-skipped, makeCountrySheet callers: ${callers.join(', ')}; seriesFor over ${countries.length} countries (India ${ind.index} of ${ind.totalLists}); ${H.statesWithPosters(states).length} state posters, series 1..${H.statesWithPosters(states).length}, every outline found`)
|
||||
console.log(`PASS check:country-sheet-one-path — ${Object.keys(files).length} plugin sources parsed-or-skipped, makeCountrySheet callers: ${callers.join(', ')}; seriesFor over ${countries.length} countries (India ${ind.index} of ${ind.totalLists}); ${H.statesWithPosters(states).length} state posters, series 1..${H.statesWithPosters(states).length}, every outline found; sections ${E.order.slice(0, 3).map(([g, t]) => `${g} ${t}`).join(' > ')}`)
|
||||
}
|
||||
|
||||
main().catch((e) => { console.error(`FAIL ${e.stack || e}`); process.exitCode = 1 })
|
||||
|
|
|
|||
Loading…
Reference in a new issue