From 893a02e1e2ee94876eb3fb9ba2609e65dfc0e0f8 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sun, 3 May 2026 16:06:07 -0500 Subject: [PATCH] fix(rover-planning): index 'Band' column shows all mission bands MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /rover-planning index was rendering only band_mhz (the legacy primary single-band column), so multi-band missions with bands_mhz populated showed just the first band. Switched the renderer to arity-2 and now pulls the full bands list via Mission.bands/1, so multi-band missions render '10 GHz · 24 GHz · 47 GHz' etc. Sort still keys on band_mhz so the column stays sortable on a single scalar value. --- .../live/rover_planning_live.ex | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/microwaveprop_web/live/rover_planning_live.ex b/lib/microwaveprop_web/live/rover_planning_live.ex index d55e39b7..66b2f386 100644 --- a/lib/microwaveprop_web/live/rover_planning_live.ex +++ b/lib/microwaveprop_web/live/rover_planning_live.ex @@ -8,6 +8,7 @@ defmodule MicrowavepropWeb.RoverPlanningLive do alias Microwaveprop.Accounts.User alias Microwaveprop.RoverPlanning + alias Microwaveprop.RoverPlanning.Mission def table_options do %{sorting: %{default_sort: [inserted_at: :desc]}} @@ -18,7 +19,7 @@ defmodule MicrowavepropWeb.RoverPlanningLive do id: %{label: "ID", hidden: true}, user_id: %{label: "Owner", hidden: true}, name: %{label: "Mission", sortable: true, searchable: true, renderer: &name_cell/2}, - band_mhz: %{label: "Band", sortable: true, renderer: &band_cell/1}, + band_mhz: %{label: "Bands", sortable: true, renderer: &bands_cell/2}, only_known_good: %{label: "Scope", sortable: true, renderer: &scope_cell/1}, inserted_at: %{label: "Created", sortable: true, renderer: &format_ts/1} ] @@ -136,18 +137,26 @@ defmodule MicrowavepropWeb.RoverPlanningLive do """ end - defp band_cell(nil), do: "—" - - defp band_cell(mhz) when is_integer(mhz) do - if mhz >= 1000 do - ghz = mhz / 1000 - label = if ghz == trunc(ghz), do: "#{trunc(ghz)}", else: Float.to_string(Float.round(ghz, 1)) - "#{label} GHz" - else - "#{mhz} MHz" + # Renders the full bands list (multi-band missions can have several; + # the bound column is `band_mhz` so the table can still sort by the + # primary band, but the cell shows every band the matrix scores). + defp bands_cell(_value, record) do + case Mission.bands(struct(Mission, Map.take(record, [:band_mhz, :bands_mhz]))) do + [] -> "—" + [single] -> band_label(single) + list -> Enum.map_join(list, " · ", &band_label/1) end end + defp band_label(mhz) when is_integer(mhz) and mhz >= 1000 do + ghz = mhz / 1000 + label = if ghz == trunc(ghz), do: "#{trunc(ghz)}", else: Float.to_string(Float.round(ghz, 1)) + "#{label} GHz" + end + + defp band_label(mhz) when is_integer(mhz), do: "#{mhz} MHz" + defp band_label(_), do: "—" + defp scope_cell(true) do assigns = %{} ~H|Known good only|