Skip to content

Locations 0.2.0: Floors, rooms and files for every location

Locations 0.2.0 lets you break a location down into floors and rooms in the PhoenixKit locations module, and attach a featured image and files to each location, floor and room.

Floors and rooms

The location form gets a Spaces section. Add floor creates a floor; each floor is a tab, and the rooms of the active floor sit under it, with Add room. A floor or room has a name, a description and its own language selector, so it can be translated separately from the location. As the section says, changes save together with the location: floors and rooms are drafts on the page until you press the location’s save button.

Before saving, every draft is checked. A floor or room without a name stops the save with a message that names it, such as “Floor 2 needs a name”. Deleting a floor also deletes its rooms; the form asks first and applies the deletion when you save. If the location saves but some spaces fail, the page says how many failed and keeps them on screen so nothing is lost.

Images and files

Each location, and each floor and room, gets a Featured Image picker and an Attached Files card. Drag and drop or click to upload, and files go to the place being edited. Removing a file from a location moves it to the trash if nothing else uses it, and admins can restore it.

A cleaner admin

The Locations and Types switcher on the page is gone: the PhoenixKit admin sidebar already offers both as subtabs. The pages use the standard admin header and the full width of the screen, and clicking a name in either list opens it for editing.

Upgrading

Locations 0.2 needs PhoenixKit 1.7.125 or later, the first core release with the table for floors and rooms. Run PhoenixKit’s migrations as usual after updating; Locations itself adds none.

Full release notes: Locations 0.2.0

0.2.0 · 29 May 2026

Added

  • Spaces — nested floors and rooms under a Location (PhoenixKitLocations.Spaces + Schemas.Space, backed by core migration V122 phoenix_kit_location_spaces). Edited as staged in-memory drafts that commit on the global Location save; floors are top-level tabs, rooms nest under the active floor. Block-on-invalid validation gate with a kind-aware flash that names the offending draft (“Floor 2 needs a name” / “Room 1 in Floor 2 needs a name”). Floor delete cascades to its rooms; partial-save failures keep the failed drafts on the page. Context guards the same-Location parent invariant and indirect-cycle prevention (depth-bounded walk-up).
  • Attachments — scope-aware Files cards + featured-image picker per Location and per Space draft (PhoenixKitLocations.Attachments), routing drag-and-drop uploads to the right scope.
  • Per-draft independent language selector on floor and room editors.
  • PhoenixKitLocations.Errors atoms for Spaces: :space_not_found, :parent_in_other_location, :parent_not_found, :cycle, :parent_floor_unsaved.

Changed

  • Dependency floor raised: {:phoenix_kit, "~> 1.7.105"} → "~> 1.7.125". 1.7.125 is the first core release shipping migration V122; the Spaces feature would have no table on older cores.
  • Locations/Types in-page tab nav removed in favor of the PhoenixKit admin dashboard’s sibling subtabs; replaced with <.admin_page_header>. Name cells in both tables now navigate to the edit page on click.
  • Full-width admin layout across all three LiveViews (forms capped at an inner max-w); dropped the deprecated back= attr from headers.

Fixed

  • Saving a Location with no staged spaces no longer crashes the form — persist_space_drafts/3 had a dead [] -> nil clause shadowing the {nil, MapSet.new()} clause, so the empty-drafts path raised a MatchError on the (common) spaceless save.
  • Spaces.reorder_siblings/4 no longer silently no-ops for root-level floors — a pinned parent_uuid == ^nil compiled to SQL = NULL (zero rows); the nil-parent case now uses is_nil/1.
  • Spaces.update_space/3’s cycle check now reads parent_uuid under both string and atom keys (via a shared fetch_attr/2), matching the parent-location check — an atom-keyed attrs map no longer bypasses the guard.
  • check_parent_under_location/2 returns the accurate :parent_not_found when a parent UUID doesn’t exist, instead of conflating it with :parent_in_other_location.

Quality

  • mix precommit clean: compile --force --warnings-as-errors, deps.unlock --check-unused, format --check-formatted, credo --strict, dialyzer all pass. Restored handle_event/3 and persist_room/5 clause grouping that the Spaces work had split (which --warnings-as-errors rejected).
  • Pure-helper test suites for Space schema, Attachments helpers, and the new Errors atoms.

Locations 0.2.0. Install or update: {:phoenix_kit_locations, "~> 0.2"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.