PhoenixKitLocations.Schemas.Space (PhoenixKitLocations v0.2.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

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.

kinds()

statuses()