fix(elixir): storage rendering in component list
This commit is contained in:
@@ -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">
|
||||
|
||||
Reference in New Issue
Block a user