feat(manager): the menu board editor and widgets (platform-v2 step 5.6b)
- Menu board: everything or chosen whole categories (sub-categories included, new products join) plus single products found by search; hide a product from the board (and show it again); the board's own order with arrows on what the server resolved (categories and products; boardOrder writes it); a badge per product; grouping, headings, photos, descriptions, whose prices (a sales point or none), sold out crossed out or hidden, columns, products per page (or as many as fit), seconds per page; colours, font, size, background. - Widgets (text and menu slides): logo, venue name, date (long / short), clock (seconds), message of the day (or its own text), QR code (ordering / QR menu / a link + caption), weather (1-3 days, says it needs internet); where (corners, bars) and size. - The preview stays in view while the settings scroll. - @xenia/signage: the venue clock's Intl call names its time zone where the i18n guard reads it. - tests: manager signage.test.mjs +1; e2e signage.mjs builds a menu board in the editor (categories, a single product, the order, a badge, hiding, a clock) and checks what was saved and resolved. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -115,3 +115,38 @@ export function mediaLookup(map) {
|
||||
return m ? { ...m, src: m.url } : null
|
||||
}
|
||||
}
|
||||
|
||||
// ── menu boards and widgets (5.6b) ───────────────────────────────────────────
|
||||
|
||||
export const WIDGET_KINDS = ['logo', 'name', 'date', 'clock', 'message', 'qr', 'weather']
|
||||
export const WIDGET_POSITIONS = ['top-left', 'top-center', 'top-right', 'bottom-left', 'bottom-center', 'bottom-right', 'top-bar', 'bottom-bar']
|
||||
export const BADGES = ['new', 'chef', 'offer', 'popular', 'spicy', 'vegetarian', 'vegan']
|
||||
|
||||
/**
|
||||
* The board's own order from the groups as they are shown: categories in that order, every product
|
||||
* in that order (the server puts listed ids first, so this pins the whole board).
|
||||
*/
|
||||
export function boardOrder(groups) {
|
||||
return {
|
||||
category_order: groups.filter(g => g.category).map(g => g.category.id),
|
||||
product_order: groups.flatMap(g => g.items.map(i => i.id)),
|
||||
}
|
||||
}
|
||||
|
||||
/** Groups with group `i` moved by `d` (−1 up, +1 down). */
|
||||
export function moveGroup(groups, i, d) {
|
||||
return moved(groups, i, i + d)
|
||||
}
|
||||
|
||||
/** Groups with item `ii` of group `gi` moved by `d` inside its group. */
|
||||
export function moveItem(groups, gi, ii, d) {
|
||||
return groups.map((g, j) => (j === gi ? { ...g, items: moved(g.items, ii, ii + d) } : g))
|
||||
}
|
||||
|
||||
/** Toggle an id in a list (kept sorted for stable saves). */
|
||||
export function toggled(list, id) {
|
||||
const set = new Set(list || [])
|
||||
if (set.has(id)) set.delete(id)
|
||||
else set.add(id)
|
||||
return [...set].sort((a, b) => a - b)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user