diff --git a/local_backend/migrations/versions/0041_floor_item_color.py b/local_backend/migrations/versions/0041_floor_item_color.py
new file mode 100644
index 0000000..7d2d173
--- /dev/null
+++ b/local_backend/migrations/versions/0041_floor_item_color.py
@@ -0,0 +1,23 @@
+"""A floor area's colour (UI review 2026-11-20): "#rrggbb", drawn see-through on the plan.
+
+Revision ID: 0041_floor_item_color
+Revises: 0040_channel_prices
+Create Date: 2026-11-20 18:00:00
+"""
+from alembic import op
+import sqlalchemy as sa
+
+revision = '0041_floor_item_color'
+down_revision = '0040_channel_prices'
+branch_labels = None
+depends_on = None
+
+
+def upgrade() -> None:
+ with op.batch_alter_table('floor_items', schema=None) as batch_op:
+ batch_op.add_column(sa.Column('color', sa.String(), nullable=True))
+
+
+def downgrade() -> None:
+ with op.batch_alter_table('floor_items', schema=None) as batch_op:
+ batch_op.drop_column('color')
diff --git a/local_backend/models/floor_plan.py b/local_backend/models/floor_plan.py
index 4a19b3b..6207c54 100644
--- a/local_backend/models/floor_plan.py
+++ b/local_backend/models/floor_plan.py
@@ -54,5 +54,6 @@ class FloorItem(Base):
height = Column(Float, nullable=False)
rotation = Column(Float, nullable=False, default=0.0)
text = Column(String, nullable=True)
+ color = Column(String, nullable=True) # an area's colour, "#rrggbb" (drawn see-through; 2026-11-20)
plan = relationship("FloorPlan", back_populates="items")
diff --git a/local_backend/routers/floor_plans.py b/local_backend/routers/floor_plans.py
index dcd2a41..e53b39e 100644
--- a/local_backend/routers/floor_plans.py
+++ b/local_backend/routers/floor_plans.py
@@ -88,6 +88,7 @@ class PlacedItem(BaseModel):
height: float = Field(gt=0, le=6000)
rotation: float = 0.0
text: Optional[str] = Field(None, max_length=60)
+ color: Optional[str] = Field(None, pattern=r"^#[0-9a-fA-F]{6}$") # an area's colour (2026-11-20)
class LayoutBody(BaseModel):
@@ -110,7 +111,7 @@ def plan_out(p: FloorPlan) -> dict:
"media_id": p.media_id, "background": media_store.image_of(p.media) if p.media_id else None,
"background_opacity": p.background_opacity,
"items": [{"id": i.id, "kind": i.kind, "x": i.x, "y": i.y, "width": i.width, "height": i.height,
- "rotation": i.rotation, "text": i.text} for i in p.items],
+ "rotation": i.rotation, "text": i.text, "color": i.color} for i in p.items],
}
@@ -211,7 +212,8 @@ def save_layout(plan_id: int, body: LayoutBody, db: Session = Depends(get_db), u
db.flush()
for it in body.items:
p.items.append(FloorItem(kind=it.kind, x=_inside(it.x, p.width), y=_inside(it.y, p.height), width=round(it.width, 1),
- height=round(it.height, 1), rotation=_rot(it.rotation), text=(it.text or "").strip() or None))
+ height=round(it.height, 1), rotation=_rot(it.rotation), text=(it.text or "").strip() or None,
+ color=it.color if it.kind == "area" else None))
db.commit()
db.refresh(p)
_changed()
diff --git a/local_backend/tests/test_floor_plans.py b/local_backend/tests/test_floor_plans.py
index 6afffbc..42e0146 100644
--- a/local_backend/tests/test_floor_plans.py
+++ b/local_backend/tests/test_floor_plans.py
@@ -90,3 +90,16 @@ def test_the_live_map_shows_each_table_state_to_the_right_people(client, owner_h
assert len(client.get("/api/floor-plans/live", headers=owner_h).json()["tables"]) == 4
# only the tables' managers set plans up
assert client.post("/api/floor-plans", headers=h, json={"name": "x"}).status_code == 403
+
+
+def test_an_area_keeps_its_colour(client, owner_h, venue):
+ """2026-11-20: an area has a colour ("#rrggbb", drawn see-through); other things don't."""
+ p = plan(client, owner_h, group_id=venue["inside"].id)
+ r = client.put(f"/api/floor-plans/{p['id']}/layout", headers=owner_h, json={"items": [
+ {"kind": "area", "x": 300, "y": 300, "width": 300, "height": 200, "text": "Terrace", "color": "#86efac"},
+ {"kind": "wall", "x": 10, "y": 10, "width": 100, "height": 12, "color": "#86efac"}]})
+ assert r.status_code == 200, r.text
+ assert [(i["kind"], i["color"]) for i in r.json()["items"]] == [("area", "#86efac"), ("wall", None)]
+ bad = client.put(f"/api/floor-plans/{p['id']}/layout", headers=owner_h, json={"items": [
+ {"kind": "area", "x": 1, "y": 1, "width": 10, "height": 10, "color": "red; drop"}]})
+ assert bad.status_code == 422
diff --git a/manager_dashboard/src/pages/Management/TablesConfigPage.jsx b/manager_dashboard/src/pages/Management/TablesConfigPage.jsx
index 75f587b..04c36c0 100644
--- a/manager_dashboard/src/pages/Management/TablesConfigPage.jsx
+++ b/manager_dashboard/src/pages/Management/TablesConfigPage.jsx
@@ -1,7 +1,9 @@
// Management → Tables: the tables and their zones (the list, for typing and bulk changes), and
-// the floor plans (plan step 6.8: where the tables stand, drawn on a map).
-import { useState } from 'react'
+// the floor plans (plan step 6.8: where the tables stand, drawn on a map). On the page rule
+// (2026-11-20): the tabs above, the tab in the address (?tab=).
+import { useSearchParams } from 'react-router-dom'
import { useTranslation } from '@xenia/i18n'
+import { Page, Tabs } from '@xenia/ui'
import FloorPlansTab from '../floor/FloorPlansTab'
import TablesListTab from '../tables/TablesListTab'
@@ -9,21 +11,14 @@ const TABS = ['list', 'floor']
export default function TablesConfigPage() {
const { t } = useTranslation('manager')
- const [tab, setTab] = useState('list')
+ const [params, setParams] = useSearchParams()
+ const tab = TABS.includes(params.get('tab')) ? params.get('tab') : 'list'
+ const setTab = v => setParams(p => { const n = new URLSearchParams(p); n.set('tab', v); return n }, { replace: true })
return (
-
-
- {TABS.map(k => (
-
- ))}
-
-
- {tab === 'list' ?
:
}
-
-
+ ({ id: k, label: t(`floor.tabs.${k}`), testId: `tables-tab-${k}` }))} />}>
+ {tab === 'list' ? : }
+
)
}
diff --git a/manager_dashboard/src/pages/floor/FloorEditor.jsx b/manager_dashboard/src/pages/floor/FloorEditor.jsx
index 6f0f23f..01c78e0 100644
--- a/manager_dashboard/src/pages/floor/FloorEditor.jsx
+++ b/manager_dashboard/src/pages/floor/FloorEditor.jsx
@@ -1,24 +1,44 @@
// One floor plan's editor (plan step 6.8, D-31). Drag tables and things on the floor; the panel
// on the right edits what's selected (shape, seats, size, rotation, text), adds the tables that
// aren't on the plan and walls / the bar / labels / areas, and holds the plan's settings: name,
-// zone, size, the grid (snap on / off and its size), the floor's shape (drag its corners; add or
-// remove corners) and a background picture from the media library. Arrow keys move the selected
-// thing (a grid cell, or 5; Shift: 1), Delete takes it off, Escape lets go. Nothing is saved
-// until "Save"; then every app's map changes at once.
-import { useMemo, useRef, useState } from 'react'
+// zone, size, a background picture. The toolbar over both: the grid (on / off and its resolution),
+// "Edit the floor's shape", fit the width or the whole plan, undo, save.
+// The floor's shape (2026-11-20): drag a corner; on an edge a "+" shows where a click adds a
+// corner; resting on a corner shows a bubble to remove it (a floor keeps at least 3). An area
+// (2026-11-20) is resized by the handles on its sides and corners, and has a colour (pastel, see-
+// through); when tables cover its name, the name shows in its corner too.
+// Arrow keys move the selected thing (a grid cell, or 5; Shift: 1), Delete takes it off, Escape
+// lets go. Nothing is saved until "Save"; then every app's map changes at once.
+import { useLayoutEffect, useMemo, useRef, useState } from 'react'
import toast from 'react-hot-toast'
import { RotateCcw, RotateCw, Save, Trash2, Undo2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import {
- Floor, GRID_SIZES, ITEM_KINDS, Item, SHAPES, TableShape, addCorner, defaultSize, moveCorner, moveTo, outlineOf, removeCorner, toPlan,
+ AREA_COLOURS, Floor, GRID_LEVELS, ITEM_KINDS, Item, SHAPES, TableShape, addCornerAt, coveredAreas, defaultSize, moveCorner, moveTo,
+ nearestEdge, outlineOf, removeCorner, resizeBox, toPlan,
} from '@xenia/floorplan'
import { useTranslation } from '@xenia/i18n'
-import { Button, Dialog, Field, IconButton, Input, Select, Switch, cx } from '@xenia/ui'
+import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Switch, cx } from '@xenia/ui'
import MediaField from '../media/MediaField'
import * as api from './floorApi'
import { addItem, addable, find, fitOutline, layoutBody, layoutOf, nudge, placeTable, planBody, remove, resize, rotate, sameLayout, update } from './editorLogic'
const PAD = 30 // room around the floor for the corner handles
+const HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']
+const CURSOR = { n: 'ns-resize', s: 'ns-resize', e: 'ew-resize', w: 'ew-resize', nw: 'nwse-resize', se: 'nwse-resize', ne: 'nesw-resize', sw: 'nesw-resize' }
+
+/** The size of an element, kept up to date. */
+function useSize(ref) {
+ const [size, setSize] = useState({ width: 0, height: 0 })
+ useLayoutEffect(() => {
+ const el = ref.current
+ if (!el) return undefined
+ const ro = new ResizeObserver(([e]) => setSize({ width: e.contentRect.width, height: e.contentRect.height }))
+ ro.observe(el)
+ return () => ro.disconnect()
+ }, [ref])
+ return size
+}
export default function FloorEditor({ plan: saved, data, groups, onSaved, onDeleted }) {
const { t } = useTranslation('manager')
@@ -30,8 +50,14 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const [newShape, setNewShape] = useState('square')
const [busy, setBusy] = useState(false)
const [deleting, setDeleting] = useState(false)
+ const [fit, setFit] = useState('width') // 'width' | 'all'
+ const [edgeHover, setEdgeHover] = useState(null) // where a click on the edge adds a corner
+ const [cornerTip, setCornerTip] = useState(null) // the corner showing its "remove" bubble
+ const tipTimer = useRef(null)
const svg = useRef(null)
+ const box = useRef(null)
const drag = useRef(null)
+ const size = useSize(box)
const plan = form // the preview follows the unsaved settings
const dirtySettings = JSON.stringify(planBody(form)) !== JSON.stringify(planBody(saved))
@@ -40,6 +66,13 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const corners = outlineOf(plan)
const setF = (k, v) => setForm(f => ({ ...f, [k]: v }))
const { own, other } = addable(data, plan, layout)
+ const covered = coveredAreas(layout.items, layout.tables)
+
+ // the scale: the plan (and its margin) fitted to the width, or whole in the box
+ const vbW = plan.width + 2 * PAD
+ const vbH = plan.height + 2 * PAD
+ const scale = size.width ? (fit === 'all' && size.height ? Math.min(size.width / vbW, size.height / vbH) : size.width / vbW) : 1
+ const r = Math.max(8, 9 / scale) // a handle's size on screen ≈ 18 px
const point = e => toPlan(svg.current, e.clientX, e.clientY)
const start = (e, target) => {
@@ -49,6 +82,8 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
if (target.type === 'corner') {
setSel(target)
drag.current = { target }
+ } else if (target.handle) {
+ drag.current = { target }
} else {
const thing = find(layout, target)
setSel(target)
@@ -58,12 +93,22 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
}
const move = e => {
const d = drag.current
- if (!d) return
const [px, py] = point(e)
+ if (!d) {
+ if (shapeMode) {
+ const n = nearestEdge(corners, [px, py])
+ setEdgeHover(n && n.d < 14 / scale ? n : null)
+ }
+ return
+ }
if (d.target.type === 'corner') {
setForm(f => ({ ...f, outline: moveCorner(outlineOf(f), d.target.index, px, py, f) }))
return
}
+ if (d.target.handle) {
+ setLayout(l => update(l, d.target, resizeBox(find(l, d.target), d.target.handle, px, py, plan)))
+ return
+ }
setLayout(l => {
const thing = find(l, d.target)
if (!thing) return l
@@ -72,6 +117,17 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
})
}
const end = () => { drag.current = null }
+ const down = e => {
+ if (shapeMode && edgeHover) {
+ // a click on an edge adds a corner there and starts dragging it
+ const index = edgeHover.index + 1
+ setForm(f => ({ ...f, outline: addCornerAt(outlineOf(f), edgeHover.index, edgeHover.x, edgeHover.y, f) }))
+ setEdgeHover(null)
+ start(e, { type: 'corner', index })
+ return
+ }
+ setSel(null)
+ }
const keys = e => {
if (!sel || sel.type === 'corner') return
const dirs = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, -1], ArrowDown: [0, 1] }
@@ -79,6 +135,9 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
else if (e.key === 'Delete' || e.key === 'Backspace') { e.preventDefault(); setLayout(l => remove(l, sel)); setSel(null) }
else if (e.key === 'Escape') setSel(null)
}
+ const showTip = i => { clearTimeout(tipTimer.current); tipTimer.current = setTimeout(() => setCornerTip(i), 600) }
+ const hideTip = () => { clearTimeout(tipTimer.current); tipTimer.current = setTimeout(() => setCornerTip(null), 500) }
+ const keepTip = () => clearTimeout(tipTimer.current)
const save = async () => {
setBusy(true)
@@ -90,33 +149,39 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
} catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) }
}
const zoneName = id => groups.find(g => g.id === id)?.name ?? t('floor.noZone')
+ const gridOptions = [...GRID_LEVELS.map(([k, v]) => ({ value: v, label: t(`floor.gridLevels.${k}`), hint: t('floor.gridCell', { size: v }) })),
+ ...(GRID_LEVELS.some(([, v]) => v === form.grid_size) ? [] : [{ value: form.grid_size, label: t('floor.gridCell', { size: form.grid_size }) }])]
+ const resizable = selected && sel.type === 'item' && selected.kind === 'area' && !shapeMode && Math.round(selected.rotation || 0) % 180 === 0
return (
-
-
-
-
{form.name || saved.name}
- {dirty && {t('floor.unsaved')}}
- } disabled={!dirty || busy}
- onClick={() => { setLayout(initial); setForm({ ...saved }); setSel(null) }}>{t('floor.undoAll')}
- } loading={busy} disabled={!dirty || !form.name.trim()} onClick={save} data-testid="floor-save">{t('floor.save')}
-
-
- setF('grid_on', v)} label={t('floor.grid')} data-testid="floor-grid" />
- {form.grid_on && (
-
- {shapeMode &&
{t('floor.shapeHint')}
}
-
-