Sort Gaiia entity mapping: items with suggestions shown first

Both network sites and inventory items tabs now sort entries
with match suggestions to the top of the list.
This commit is contained in:
Graham McIntire 2026-02-15 16:35:35 -06:00
parent f4442c3a43
commit 074c55cd7d

View file

@ -199,8 +199,11 @@ defmodule ToweropsWeb.Org.GaiiaMappingLive do
if matches == [], do: acc, else: Map.put(acc, site.gaiia_id, matches)
end)
# Sort items with suggestions first
sorted_sites = Enum.sort_by(sites, fn site -> if Map.has_key?(suggestions, site.gaiia_id), do: 0, else: 1 end)
socket
|> assign(:items, sites)
|> assign(:items, sorted_sites)
|> assign(:suggestions, suggestions)
end
@ -217,8 +220,11 @@ defmodule ToweropsWeb.Org.GaiiaMappingLive do
if matches == [], do: acc, else: Map.put(acc, item.gaiia_id, matches)
end)
# Sort items with suggestions first
sorted_items = Enum.sort_by(items, fn item -> if Map.has_key?(suggestions, item.gaiia_id), do: 0, else: 1 end)
socket
|> assign(:items, items)
|> assign(:items, sorted_items)
|> assign(:suggestions, suggestions)
end