feat(manager): the floor plan editor reworked; Management -> Tables on the page rule; area colours

- Floor editor: one toolbar over the map and the panels (grid on / off, grid resolution Ultra high
  ... Very low, edit the shape, Fit width / Whole plan, undo, save), panels top-aligned and sticky.
- The floor's shape: a '+' on the edge under the pointer, press to add a corner (and drag it);
  resting on a corner shows a bubble to remove it (never below 3).
- Areas: resize handles on the sides and corners, a colour (pastel, see-through; floor_items.color,
  migration 0041), the name repeated in the corner when tables cover it (live maps too).
- Labels can be clicked again after they're placed (transparent fill, not none).
- Management -> Tables: <Page> with the tabs above (?tab=), the list as a container, toolbar
  buttons one height.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-20 15:17:45 +02:00
co-authored by Claude Opus 5.5
parent 476c55abc0
commit 244e93f827
17 changed files with 389 additions and 111 deletions
@@ -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')
+1
View File
@@ -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")
+4 -2
View File
@@ -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()
+13
View File
@@ -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