diff --git a/manager_dashboard/src/pages/floor/FloorEditor.jsx b/manager_dashboard/src/pages/floor/FloorEditor.jsx
index 01c78e0..bace9ed 100644
--- a/manager_dashboard/src/pages/floor/FloorEditor.jsx
+++ b/manager_dashboard/src/pages/floor/FloorEditor.jsx
@@ -7,21 +7,26 @@
// 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.
+// 2026-11-21: the "+" on an edge hides near a corner (there the corner's bubble removes it);
+// minus / fit width / whole plan / plus; "Edit the floor's shape" is a button that turns into
+// "Save shape" (saves the shape and the floor's size at once, nothing else); every unrotated table
+// or thing has resize handles, and sizes are in grid cells (half cells), so they follow the grid
+// resolution picked; a wall's thickness in steps.
// 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 { Check, Minus, PenTool, Plus, RotateCcw, RotateCw, Save, Trash2, Undo2 } from 'lucide-react'
import { errorMessage } from '@xenia/api'
import {
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, Dropdown, Field, IconButton, Input, Segmented, Switch, cx } from '@xenia/ui'
+import { Button, Dialog, Dropdown, Field, IconButton, Input, Segmented, Stepper, 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'
+import { WALL_THICKNESS, addItem, addable, cellOf, find, fitOutline, layoutBody, layoutOf, nudge, placeTable, planBody, remove, resizeCells, rotate, sameLayout, toCells, update } from './editorLogic'
const PAD = 30 // room around the floor for the corner handles
const HANDLES = ['nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w']
@@ -44,6 +49,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const { t } = useTranslation('manager')
const initial = useMemo(() => layoutOf(data, saved.id), [data, saved.id])
const [layout, setLayout] = useState(initial)
+ const [base, setBase] = useState(saved) // the plan as saved (a saved shape updates it)
const [form, setForm] = useState(() => ({ ...saved }))
const [sel, setSel] = useState(null) // {type: 'table'|'item', id} | {type: 'corner', index}
const [shapeMode, setShapeMode] = useState(false)
@@ -51,6 +57,8 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const [busy, setBusy] = useState(false)
const [deleting, setDeleting] = useState(false)
const [fit, setFit] = useState('width') // 'width' | 'all'
+ const [zoom, setZoom] = useState(null) // a scale picked with − / + (null: the fit)
+ const [shapeBusy, setShapeBusy] = useState(false)
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)
@@ -60,7 +68,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const size = useSize(box)
const plan = form // the preview follows the unsaved settings
- const dirtySettings = JSON.stringify(planBody(form)) !== JSON.stringify(planBody(saved))
+ const dirtySettings = JSON.stringify(planBody(form)) !== JSON.stringify(planBody(base))
const dirty = dirtySettings || !sameLayout(layout, initial)
const selected = sel && sel.type !== 'corner' ? find(layout, sel) : null
const corners = outlineOf(plan)
@@ -71,7 +79,9 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
// 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 fitScale = size.width ? (fit === 'all' && size.height ? Math.min(size.width / vbW, size.height / vbH) : size.width / vbW) : 1
+ const scale = zoom ?? fitScale
+ const zoomBy = f => setZoom(Math.min(4, Math.max(0.1, scale * f)))
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)
@@ -96,7 +106,9 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
const [px, py] = point(e)
if (!d) {
if (shapeMode) {
- const n = nearestEdge(corners, [px, py])
+ // near a corner there is no "+": that corner's bubble removes it
+ const nearCorner = corners.some(([x, y]) => Math.hypot(x - px, y - py) < r * 3)
+ const n = nearCorner ? null : nearestEdge(corners, [px, py])
setEdgeHover(n && n.d < 14 / scale ? n : null)
}
return
@@ -106,7 +118,7 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
return
}
if (d.target.handle) {
- setLayout(l => update(l, d.target, resizeBox(find(l, d.target), d.target.handle, px, py, plan)))
+ setLayout(l => update(l, d.target, resizeBox(find(l, d.target), d.target.handle, px, py, plan, cellOf(plan) / 2)))
return
}
setLayout(l => {
@@ -148,10 +160,27 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
onSaved()
} catch (err) { toast.error(errorMessage(err, t)) } finally { setBusy(false) }
}
+ const enterShape = () => { setShapeMode(true); setSel(null); setEdgeHover(null); setCornerTip(null) }
+ const leaveShape = () => { setShapeMode(false); setEdgeHover(null); setCornerTip(null); setSel(null) }
+ // "Save shape": the floor's shape and size are saved at once; the rest waits for "Save"
+ const saveShape = async () => {
+ const shape = { outline: form.outline ?? null, width: form.width, height: form.height }
+ if (JSON.stringify(planBody({ ...base, ...shape })) !== JSON.stringify(planBody(base))) {
+ setShapeBusy(true)
+ try {
+ await api.savePlan(saved.id, planBody({ ...base, ...shape }))
+ setBase(b => ({ ...b, ...shape }))
+ toast.success(t('floor.shapeSaved'))
+ } catch (err) { toast.error(errorMessage(err, t)); setShapeBusy(false); return }
+ setShapeBusy(false)
+ }
+ leaveShape()
+ }
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
+ const resizable = selected && !shapeMode && Math.round(selected.rotation || 0) % 180 === 0
+ const handles = resizable && selected.kind === 'wall' ? ['e', 'w'] : HANDLES
return (
@@ -164,16 +193,27 @@ export default function FloorEditor({ plan: saved, data, groups, onSaved, onDele
{form.grid_on && (
setF('grid_size', v)} aria-label={t('floor.gridSize')} data-testid="floor-grid-size" options={gridOptions} />
)}
- { setShapeMode(v); setSel(null); setEdgeHover(null); setCornerTip(null) }} label={t('floor.editShape')} data-testid="floor-shape-mode" />
-
+ {shapeMode ? (
+
+
+ } loading={shapeBusy} onClick={saveShape} data-testid="floor-shape-save">{t('floor.saveShape')}
+
+ ) : (
+ } onClick={enterShape} data-testid="floor-shape-mode">{t('floor.editShape')}
+ )}
+
+ zoomBy(1 / 1.25)} data-testid="floor-zoom-out">
+ { setFit(v); setZoom(null) }} aria-label={t('floor.fit')}
+ options={[{ value: 'width', label: t('floor.fitWidth'), testId: 'floor-fit-width' }, { value: 'all', label: t('floor.fitAll'), testId: 'floor-fit-all' }]} />
+ zoomBy(1.25)} data-testid="floor-zoom-in">
+
} disabled={!dirty || busy}
- onClick={() => { setLayout(initial); setForm({ ...saved }); setSel(null) }}>{t('floor.undoAll')}
+ onClick={() => { setLayout(initial); setForm({ ...base }); setSel(null) }}>{t('floor.undoAll')}
} loading={busy} disabled={!dirty || !form.name.trim()} onClick={save} data-testid="floor-save">{t('floor.save')}
-