PhoenixKitLocations.Schemas.Space (PhoenixKitLocations v0.3.0)

Copy Markdown View Source

A nested space inside a Location — a floor, room, zone, etc.

Spaces form a filesystem-like tree per Location: each row belongs to exactly one Location (required FK) and may optionally belong to a parent Space (self-ref FK), forming arbitrary-depth nesting.

Translatable fields

name and description are translatable. Primary-language values stay in the dedicated columns; secondary languages live under a language-code key in data, e.g.:

%{ "es-ES" => %{ "name" => "Planta 2" } }

Top-level keys in data carry attachment pointers (files_folder_uuid, featured_image_uuid), mirroring how phoenix_kit_locations.data is used.

Kind

kind is a fixed string from @kinds. The DB CHECK constraint in V122 mirrors the same list — keep both in sync if a new label is added.

Summary

Functions

Form-facing changeset.

Heroicon name for a kind value, used by the Spaces tree UI. Falls back to a generic cube icon for anything outside @kinds.

Human-readable label for a kind value, translated via the module's own Gettext backend. Falls back to the raw kind string for anything outside @kinds (e.g. reserved-but-unused DB CHECK values).

Types

t()

@type t() :: %PhoenixKitLocations.Schemas.Space{
  __meta__: term(),
  children: term(),
  data: term(),
  description: term(),
  inserted_at: term(),
  kind: term(),
  location: term(),
  location_uuid: term(),
  name: term(),
  notes: term(),
  parent: term(),
  parent_uuid: term(),
  position: term(),
  status: term(),
  updated_at: term(),
  uuid: term()
}

Functions

changeset(space, attrs)

Form-facing changeset.

Note: the "child belongs to the same Location as its parent" guarantee is enforced in the PhoenixKitLocations.Spaces context, not here — the schema doesn't have parent context to compare against without an extra DB read. Keep that invariant load-bearing on the context.

kind_icon(arg1)

@spec kind_icon(String.t()) :: String.t()

Heroicon name for a kind value, used by the Spaces tree UI. Falls back to a generic cube icon for anything outside @kinds.

kind_label(kind)

@spec kind_label(String.t()) :: String.t()

Human-readable label for a kind value, translated via the module's own Gettext backend. Falls back to the raw kind string for anything outside @kinds (e.g. reserved-but-unused DB CHECK values).

kinds()

statuses()