feat(elixir): complete storage location integration
This commit is contained in:
@@ -13,12 +13,14 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
||||
{:ok, socket |> push_navigate(to: ~p"/login")}
|
||||
else
|
||||
categories = Inventory.list_categories()
|
||||
storage_locations = Inventory.list_storage_locations()
|
||||
stats = Inventory.component_stats()
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:session, session)
|
||||
|> assign(:categories, categories)
|
||||
|> assign(:storage_locations, storage_locations)
|
||||
|> assign(:stats, stats)
|
||||
|> assign(:search, "")
|
||||
|> assign(:sort_criteria, "all_not_id")
|
||||
@@ -293,6 +295,13 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
||||
end)
|
||||
end
|
||||
|
||||
defp storage_location_options(storage_locations) do
|
||||
[{"No storage location", nil}] ++
|
||||
Enum.map(storage_locations, fn location ->
|
||||
{location.path, location.id}
|
||||
end)
|
||||
end
|
||||
|
||||
@impl true
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
@@ -439,8 +448,12 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
||||
<.input field={@form[:keywords]} type="text" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Position</label>
|
||||
<.input field={@form[:position]} type="text" />
|
||||
<label class="block text-sm font-medium text-gray-700">Storage Location</label>
|
||||
<.input
|
||||
field={@form[:storage_location_id]}
|
||||
type="select"
|
||||
options={storage_location_options(@storage_locations)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -552,8 +565,12 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
||||
<.input field={@form[:keywords]} type="text" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700">Position</label>
|
||||
<.input field={@form[:position]} type="text" />
|
||||
<label class="block text-sm font-medium text-gray-700">Storage Location</label>
|
||||
<.input
|
||||
field={@form[:storage_location_id]}
|
||||
type="select"
|
||||
options={storage_location_options(@storage_locations)}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -684,9 +701,9 @@ defmodule ComponentsElixirWeb.ComponentsLive do
|
||||
</p>
|
||||
</div>
|
||||
<div class="mt-2 flex items-center text-sm text-gray-500 sm:mt-0">
|
||||
<%= if component.position do %>
|
||||
<%= if component.storage_location do %>
|
||||
<p class="mr-6">
|
||||
<span class="font-medium">Position:</span> {component.position}
|
||||
<span class="font-medium">Location:</span> {Inventory.compute_storage_location_path(component.storage_location)}
|
||||
</p>
|
||||
<% end %>
|
||||
<p class="mr-6">
|
||||
|
||||
Reference in New Issue
Block a user