feat(manager): Media page, photo field for products and categories (platform-v2 step 5.2)

- Management → Media (src/pages/media/): every picture and video, search,
  pictures / videos, batch upload (many files or drop on the page) with a
  result per file, details (preview, display name, kind, resolution, length,
  file size, uploaded file, when / who, the sizes made, what uses it, delete
  off while used).
- MediaField: upload on the spot (into the library and set at once), pick
  from the library (MediaPicker, which can also upload), remove; after an
  upload on the spot "Name it after the product / category" renames it in
  Latin letters. Used by the product editor and the category dialog.
- nav: `anyPerm` (any of the keys that manage pictures); the route guard uses
  the same rule. Product rows have test ids.
- @xenia/i18n: latin() (Greek to Latin, the way venues write it) + tests.
- tests: manager media.test.mjs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-17 15:57:50 +02:00
co-authored by Claude Opus 5.5
parent 5ad4c4ef55
commit e09056a7a4
20 changed files with 810 additions and 57 deletions
+1
View File
@@ -16,6 +16,7 @@ export { I18nProvider } from './provider.jsx'
export { useFormat, useLanguage, useUiLabels } from './hooks.js'
export { createFormatters, toDate, DATE_STYLES } from './format.js'
export { parseNumber } from './number.js'
export { latin } from './latin.js'
export {
SUPPORTED_LANGUAGES, FALLBACK_LANGUAGE, LANGUAGE_NAMES, DEFAULT_TIMEZONE, DEFAULT_CURRENCY,
resolveLanguage, normalizeLanguage, intlLocale,
+32
View File
@@ -0,0 +1,32 @@
// Greek → Latin letters ("Greeklish"), for names that must be plain English characters, e.g. a
// media item named after its product ("Γύρος χοιρινός" → "Gyros xoirinos", plan step 5.2).
// The style follows how Greek venues write it themselves: χ → x, ξ → ks, η → i, υ → y,
// ου → ou, αυ / ευ → av / ev. Accents go; anything that still isn't plain ASCII is dropped.
const ONE = {
α: 'a', β: 'v', γ: 'g', δ: 'd', ε: 'e', ζ: 'z', η: 'i', θ: 'th', ι: 'i', κ: 'k', λ: 'l', μ: 'm',
ν: 'n', ξ: 'ks', ο: 'o', π: 'p', ρ: 'r', σ: 's', ς: 's', τ: 't', υ: 'y', φ: 'f', χ: 'x', ψ: 'ps', ω: 'o',
}
const TWO = { ου: 'ou', αυ: 'av', ευ: 'ev', γγ: 'ng', ει: 'ei', οι: 'oi', αι: 'ai' }
function matchCase(src, out) {
return src === src.toLowerCase() ? out : out[0].toUpperCase() + out.slice(1)
}
function word(w) {
let out = ''
for (let i = 0; i < w.length; i++) {
const two = TWO[w.slice(i, i + 2).toLowerCase()]
if (two) { out += matchCase(w[i], two); i++; continue }
const one = ONE[w[i].toLowerCase()]
out += one ? matchCase(w[i], one) : w[i]
}
// an all-caps word stays all caps ("ΘΕΑ" → "THEA", not "ThEA")
const letters = w.replace(/[^\p{L}]/gu, '')
return letters.length > 1 && letters === letters.toUpperCase() ? out.toUpperCase() : out
}
/** Latin letters for Greek text; other text passes through (accents removed). */
export function latin(text) {
const s = String(text ?? '').normalize('NFD').replace(/[\u0300-\u036f]/g, '').normalize('NFC')
return s.split(/(\s+)/).map(word).join('').replace(/[^\x20-\x7e]/g, '').replace(/\s+/g, ' ').trim()
}