Skip to content

Support nested bins (parent/child hierarchy) #1

@akifbayram

Description

@akifbayram

Problem

Users with complex storage setups (e.g., a toolbox with drawers, a filing cabinet with folders) can't represent containment relationships between bins. Everything is flat, making it hard to model real-world storage hierarchies.

Proposed Solution

Allow bins to have an optional parent bin, creating a tree structure.

Data Model

  • Add parent_id TEXT REFERENCES bins(id) ON DELETE SET NULL to the bins table
  • Enforce max depth of 3 levels to keep UI manageable (e.g., Cabinet → Drawer → Section)
  • A bin's location_id must match its parent's location_id

API Changes

  • POST /api/bins and PUT /api/bins/:id accept optional parent_id
  • GET /api/bins returns parent_id and parent_name fields
  • GET /api/bins/:id returns children: Bin[] array
  • Deleting a parent bin nullifies parent_id on children (they become top-level)

UI/UX

Bin List Page

  • Default view remains a flat grid — nested bins show a subtle "contains X bins" badge
  • Add a "Tree View" toggle (icon button next to sort) that switches to an indented, collapsible list layout
  • Tree view: parent bins are expandable rows; clicking expands to show children inline

Bin Detail Page

  • "Parent Bin" selector field (searchable dropdown of bins in the same location, excluding self and descendants to prevent cycles)
  • "Contains" section listing child bins as clickable cards
  • Breadcrumb trail at top: Location > Parent > Current Bin

Bin Create Dialog

  • Optional "Parent Bin" field — pre-filled if creating from within a parent bin's detail page

Scope

  • No drag-and-drop reparenting in v1 — use the edit form
  • Search results remain flat (but show parent name as context)
  • Export/import preserves hierarchy via parent_id references

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions