Block a desktop-only large sheet on a phone through the country poster type
countryPosterType mirrors the Country Posters wall's phone rule on top of the India tab's withheld API: phoneBlocked = isPhonePrint() && largeSheet(c)?.desktopOnly (largeSheet is null while a country is withheld, so this bites only a non-withheld large sheet — India in DEV preview, or any future one). records() reject poster.phoneLimitAll and unsupported() reads it, after the permanent reasons (withheld, an unsupported non-large sheet) so a device reason never outranks a permanent one. So the delegating regions list and any dxm-poster-section embed cannot print India's 60x96 on a phone.
This commit is contained in:
parent
464c1c729a
commit
557f6e3678
1 changed files with 12 additions and 3 deletions
|
|
@ -9,6 +9,7 @@
|
|||
*/
|
||||
import data from '@map/data/country-posters.json'
|
||||
import { makeCountrySheet, largeSheet, posterWithheld, rowsWithheld } from '@map/packet/countrySheet.js'
|
||||
import { isPhonePrint } from '@map/composables/printInPlace.js'
|
||||
import { createPeopleGroupRecords } from '@map/lists/peopleGroupRecords.js'
|
||||
import { keyedError } from '@map/i18n/keyedError.js'
|
||||
import { countryName } from '@map/utils/countryName.js'
|
||||
|
|
@ -18,6 +19,10 @@ export const regionKey = (s) => String(s || '').normalize('NFD').replace(/[\u030
|
|||
.replace(/['’.]/g, '').replace(/&/g, ' and ').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'other'
|
||||
const TOO_MANY = 'Too many people groups to fit on one poster legibly — a solution is in progress.'
|
||||
const inScope = (scope) => (c) => regionKey(c.region) === regionKey(scope)
|
||||
// A phone cannot draw a desktop-only large sheet (the same rule as the Country Posters wall, country-poster-wall.vue).
|
||||
// largeSheet() is null while a country is withheld, so this bites only a non-withheld large sheet (India in DEV preview,
|
||||
// or any future one). Evaluated at call time so the type is correct in whatever runtime context a host mounts it.
|
||||
const phoneBlocked = (c) => isPhonePrint() && Boolean(largeSheet(c)?.desktopOnly)
|
||||
|
||||
export default {
|
||||
scopes: () => [...new Set(data.countries.map((c) => regionKey(c.region)))],
|
||||
|
|
@ -38,11 +43,15 @@ export default {
|
|||
const sheet = makeCountrySheet({ records: recordsFor, assetsBase, countries: data.countries })
|
||||
const byId = new Map(data.countries.map((c) => [c.id, c]))
|
||||
return {
|
||||
// a whole country's withheld rows (countrySheet.js WITHHELD: India's list, packet and cards) say so, unfetched
|
||||
records: (c) => (rowsWithheld(c) ? Promise.reject(keyedError('messages.countryPosterTooMany', TOO_MANY)) : recordsFor({ type: 'country', values: [c.iso3] })),
|
||||
// a whole country's withheld rows (countrySheet.js WITHHELD: India's list, packet and cards) say so, unfetched;
|
||||
// and on a phone a desktop-only large sheet is blocked (poster.phoneLimitAll), as on the Country Posters wall.
|
||||
records: (c) => (rowsWithheld(c) ? Promise.reject(keyedError('messages.countryPosterTooMany', TOO_MANY))
|
||||
: phoneBlocked(c) ? Promise.reject(keyedError('poster.phoneLimitAll', 'This needs a desktop or laptop computer.'))
|
||||
: recordsFor({ type: 'country', values: [c.iso3] })),
|
||||
// the sheet gets the data's own record (English, the series index by id), as on the wall
|
||||
sheet: (card, format) => sheet(byId.get(card.id) || card, format),
|
||||
unsupported: (c) => (posterWithheld(c) || (c.unsupportedReason && !largeSheet(c)) ? t('messages.countryPosterTooMany') : null),
|
||||
// a permanent reason (withheld, or an unsupported non-large sheet) outranks the phone (device) reason.
|
||||
unsupported: (c) => (posterWithheld(c) ? t('messages.countryPosterTooMany') : phoneBlocked(c) ? t('poster.phoneLimitAll') : (c.unsupportedReason && !largeSheet(c)) ? t('messages.countryPosterTooMany') : null),
|
||||
unit: 'UPG', itemCountKey: 'regions.countryCount', eventName: 'doxa-country-posters:show-on-map', downloadPrefix: 'doxa-country', cardStocks: true,
|
||||
}
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue