Pure helpers for a grid dashboard's layout list — the ordered
config["layouts"] entries (%{"id","name","cols","rows"}), each one exactly
one screenful on the gapless 25px lattice (see PhoenixKitDashboards.Lattice).
Read/derivation only: reading the (normalized, clamped) list, finding an entry
by id, the first/landing id, and minting the next unused id/name for a new
layout. This module never touches the Repo — the layout write paths
(add_layout / rename_layout / delete_layout / set_grid_dims) stay in
PhoenixKitDashboards.Dashboards alongside the CAS persist, which still
re-exposes layouts/1, get_layout/2, and first_layout_id/1 as its public
API (via defdelegate).
Summary
Functions
The baseline single-layout entry a never-persisted dashboard renders on.
The id of the first (default/landing) layout.
One layout entry by id, or nil.
The dashboard's grid layouts, ordered. A dashboard that has never persisted a layout list gets the default single "Layout 1" (64×36).
Mint a layout id not already used by entries — a short random id ("l" + 8
hex chars), regenerated on the (astronomically unlikely) clash.
The next free "Layout N" name for entries (falls back to "Layout ?").
Functions
@spec default_layout() :: map()
The baseline single-layout entry a never-persisted dashboard renders on.
@spec first_layout_id(PhoenixKitDashboards.Schemas.Dashboard.t()) :: String.t()
The id of the first (default/landing) layout.
@spec get_layout(PhoenixKitDashboards.Schemas.Dashboard.t(), String.t()) :: map() | nil
One layout entry by id, or nil.
@spec layouts(PhoenixKitDashboards.Schemas.Dashboard.t()) :: [map()]
The dashboard's grid layouts, ordered. A dashboard that has never persisted a layout list gets the default single "Layout 1" (64×36).
Mint a layout id not already used by entries — a short random id ("l" + 8
hex chars), regenerated on the (astronomically unlikely) clash.
The next free "Layout N" name for entries (falls back to "Layout ?").