From 074c55cd7d29a952c9516e7531c03e05d1878eb2 Mon Sep 17 00:00:00 2001 From: Graham McIntie Date: Sun, 15 Feb 2026 16:35:35 -0600 Subject: [PATCH] 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. --- lib/towerops_web/live/org/gaiia_mapping_live.ex | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/towerops_web/live/org/gaiia_mapping_live.ex b/lib/towerops_web/live/org/gaiia_mapping_live.ex index 1543a9d2..14e83c87 100644 --- a/lib/towerops_web/live/org/gaiia_mapping_live.ex +++ b/lib/towerops_web/live/org/gaiia_mapping_live.ex @@ -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