feat(signage): Slides library, widgets placed on the preview, blank slides, slide editor rework

- Slides library (Alembic 0044, /api/signage/library): slides kept with a name and a
  description, added to playlists as copies ("Add a slide" → Your slides, "Keep in Slides"),
  or shown alone as a screen's default (device config `slide`, played as "slide:<id>",
  also as a schedule's fallback). Signage → Slides: gallery + a two-pane editor.
- Widgets moved and sized by hand on the preview (WidgetCanvas: handles, snapping, arrow
  keys): position/size "custom" with a box the TV draws the same; alignment per widget.
- Blank slides (background + widgets); menu boards narrower and placed left/centre/right.
- Slide editor reworked: name | show, transition effect | seconds; sections; text look on
  one row with ready colours; one card per widget, settings on one row.
- Questions inside the page (@xenia/ui ConfirmDialog/useConfirm), Switch boxed, Segmented
  fill; the timeline's drop line; schedule lines run on weekdays or smart days, not both;
  the playlist editor stays within 1080p with a long timeline.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 07:53:27 +02:00
co-authored by Claude Opus 5.5
parent 60e6a16217
commit 83551714f7
46 changed files with 1934 additions and 431 deletions
+44
View File
@@ -57,3 +57,47 @@ test('the board\'s own order from what it shows; moving categories and products;
assert.deepEqual(toggled([1, 2], 2), [1])
assert.deepEqual(toggled(undefined, 4), [4])
})
test('widgets moved and sized on the preview: boxes kept on the slide, snapping, custom and back (2026-11-21)', async () => {
const { boxFromRect, moveBox, placeWidget, presetWidget, resizeBox, snapBox } = await import('../src/pages/signage/signageLogic.js')
const frame = { left: 100, top: 50, width: 800, height: 450 }
assert.deepEqual(boxFromRect({ left: 500, top: 95, width: 160, height: 45 }, frame), { x: 50, y: 10, w: 20, h: 10 })
const b = { x: 50, y: 10, w: 20, h: 10 }
assert.deepEqual(moveBox(b, 40, -20), { x: 80, y: 0, w: 20, h: 10 }) // stopped at the edges
assert.deepEqual(resizeBox(b, 'se', 5, 5), { x: 50, y: 10, w: 25, h: 15 })
assert.deepEqual(resizeBox(b, 'nw', 30, 30), { x: 67, y: 17, w: 3, h: 3 }) // never smaller than 3 %
assert.deepEqual(resizeBox(b, 'e', 90, 0), { x: 50, y: 10, w: 50, h: 10 })
const s = snapBox({ x: 40.5, y: 0.8, w: 20, h: 10 }) // its middle near 50, its top near 0
assert.deepEqual(s.box, { x: 40, y: 0, w: 20, h: 10 })
assert.deepEqual(s.guides, ['x:50', 'y:0'])
assert.deepEqual(snapBox({ x: 10, y: 10, w: 89.5, h: 10 }, 'e').box, { x: 10, y: 10, w: 90, h: 10 }) // a handle moves only its edge
const w = placeWidget({ kind: 'clock', position: 'top-right', size: 'large' }, b)
assert.deepEqual(w, { kind: 'clock', position: 'custom', size: 'custom', box: b })
assert.deepEqual(presetWidget(w, 'bottom-left'), { kind: 'clock', position: 'bottom-left', size: 'medium' })
assert.deepEqual(presetWidget({ kind: 'clock', position: 'top-right', size: 'large' }, 'top-left').size, 'large')
})
test('a schedule line runs on weekdays or on smart days, not both (2026-11-21)', async () => {
const { setDayShortcut, shortcutOf, toggleMonthDay, toggleWeekday } = await import('../src/pages/signage/signageLogic.js')
const line = { days: [0, 1], month_days: [] }
assert.deepEqual(toggleMonthDay(line, 'holiday'), { month_days: ['holiday'], days: [] })
assert.deepEqual(toggleWeekday({ days: [], month_days: ['first'] }, 3), { days: [3], month_days: [] })
assert.deepEqual(setDayShortcut('weekend'), { days: [5, 6], month_days: [] })
assert.equal(shortcutOf({ days: [], month_days: [] }), 'everyday')
assert.equal(shortcutOf({ days: [], month_days: ['last'] }), null) // a smart day: "every day" isn't lit
assert.equal(shortcutOf({ days: [0, 1, 2, 3, 4], month_days: [] }), 'weekdays')
})
test('the Slides library: what is saved, and a copy for a playlist', async () => {
const { savedBody, slideFromSaved } = await import('../src/pages/signage/signageLogic.js')
const saved = { id: 4, name: ' Logo ', description: ' ', orientation: 'portrait', kind: 'blank', duration_s: 12, enabled: true, days: [], content: { widgets: [{ kind: 'name' }] } }
const body = savedBody(saved)
assert.equal(body.name, 'Logo')
assert.equal(body.description, null)
assert.equal(body.orientation, 'portrait')
const copy = slideFromSaved(saved)
assert.equal(copy.kind, 'blank')
assert.equal(copy.duration_s, 12)
copy.content.widgets[0].kind = 'clock'
assert.equal(saved.content.widgets[0].kind, 'name') // a copy, never the kept slide
})