fix(elixir): storage rendering in component list
This commit is contained in:
@@ -295,10 +295,24 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
|||||||
end)
|
end)
|
||||||
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
|
defp storage_location_options(storage_locations) do
|
||||||
[{"No storage location", nil}] ++
|
[{"No storage location", nil}] ++
|
||||||
Enum.map(storage_locations, fn location ->
|
Enum.map(storage_locations, fn location ->
|
||||||
{location.path, location.id}
|
{storage_location_display_name(location), location.id}
|
||||||
end)
|
end)
|
||||||
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">
|
<div class="mt-2 flex items-center text-sm text-gray-500 sm:mt-0">
|
||||||
<%= if component.storage_location do %>
|
<%= if component.storage_location do %>
|
||||||
<p class="mr-6">
|
<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>
|
</p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p class="mr-6">
|
<p class="mr-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user