feat(products): every menu text per language, the editor's language picker, service item dialog
- Alembic 0042: a `translations` column on every choice (groups, quick options, extras, ingredients, preference sets and choices; sub-choices and shared sub-sets in their JSON); the texts typed so far become the text in their language (Greek letters → el, else the venue's); the product's old quick map moves onto the quick options. API, catalogue bundle and the cloud's quick option names carry them; names are checked before anything is replaced. - Editor: a language picker beside the close button (Default = the venue's language, plus every menu language) drives every name and description, left and right; an empty language shows what is used instead as its placeholder. The shown name is the venue language's, else any (never mixed). - Choices: one name field; the shared controls at one height (heart red when on, several / compact… chips coloured when on, delete red on hover); "+ Preference" at the right end of the tab strip; preference groups made inside a preference. - Categories: the shared dropdown to add one; the category dialog per language. - The service item switch is gone: "New service item" opens its own small dialog. - UI: Dialog headerEnd; a toned toggle keeps its colour while pressed. - Tests: backend (choice names, migration 0042), access, editor logic, e2e. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
// The menu's languages (plan step 6.4, owner 2026-11-18): English and Greek, the same list as the
|
||||
// backend's core/menu_languages.py. A product's own name is its base text; a translation adds
|
||||
// the other language; a missing translation shows the base text.
|
||||
// backend's core/menu_languages.py. Since 2026-11-21 every menu text is kept per language, the
|
||||
// venue's own included; "Default" in the editors is the venue's language. What is shown for an
|
||||
// item: the venue language's text, else the first language that has one (never mixed, never
|
||||
// machine-translated).
|
||||
export const MENU_LANGUAGES = ['el', 'en']
|
||||
|
||||
/** The languages a venue translates its menu into: every menu language but its own. */
|
||||
@@ -9,3 +11,16 @@ export const translatedLanguages = venueLanguage => MENU_LANGUAGES.filter(l => l
|
||||
/** A product's or category's text in a language: `names` / `descriptions` {lang: text} as the
|
||||
* backend resolves them for customer screens, else the base text. */
|
||||
export const inLanguage = (texts, lang, base) => (texts && texts[lang]) || base
|
||||
|
||||
/** The editors' "Default" (owner 2026-11-21): the venue's language. */
|
||||
export const DEFAULT_LANGUAGE = 'default'
|
||||
|
||||
/** The language a picker's choice edits: "default" → the venue's language. */
|
||||
export const slotOf = (lang, venueLanguage) => (!lang || lang === DEFAULT_LANGUAGE ? (MENU_LANGUAGES.includes(venueLanguage) ? venueLanguage : MENU_LANGUAGES[0]) : lang)
|
||||
|
||||
const filled = v => (typeof v === 'string' && v.trim() ? v.trim() : '')
|
||||
|
||||
/** The text shown for an item {language: text}: the venue language's, else the first language
|
||||
* that has one, else `fallback` (the row's stored text, for items never given a language). */
|
||||
export const shownText = (texts, venueLanguage, fallback = '') =>
|
||||
filled(texts?.[venueLanguage]) || MENU_LANGUAGES.map(l => filled(texts?.[l])).find(Boolean) || filled(fallback)
|
||||
|
||||
Reference in New Issue
Block a user