fix(elixir): storage rendering in component list

This commit is contained in:
Schuwi
2025-09-14 20:10:13 +02:00
parent 2cf9fb8282
commit 4d68922876

View File

@@ -295,10 +295,24 @@ defmodule ComponentsElixirWeb.ComponentsLive do
end)
end
defp storage_location_display_name(location) do
# Use the computed path from Inventory context for full hierarchy, or fall back to location.path
path = Inventory.compute_storage_location_path(location) || location.path
if path do
# Convert path from "Shelf A/Drawer 2/Box 1" to "Shelf A > Drawer 2 > Box 1"
path
|> String.split("/")
|> Enum.join(" > ")
else
location.name
end
end
defp storage_location_options(storage_locations) do
[{"No storage location", nil}] ++
Enum.map(storage_locations, fn location ->
{location.path, location.id}
{storage_location_display_name(location), location.id}
end)
end
@@ -703,7 +717,7 @@ defmodule ComponentsElixirWeb.ComponentsLive do
<div class="mt-2 flex items-center text-sm text-gray-500 sm:mt-0">
<%= if component.storage_location do %>
<p class="mr-6">
<span class="font-medium">Location:</span> {Inventory.compute_storage_location_path(component.storage_location)}
<span class="font-medium">Location:</span> {storage_location_display_name(component.storage_location)}
</p>
<% end %>
<p class="mr-6">