fix(rover-planning): index 'Band' column shows all mission bands
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.
This commit is contained in:
parent
833897e2f5
commit
893a02e1e2
1 changed files with 19 additions and 10 deletions
|
|
@ -8,6 +8,7 @@ defmodule MicrowavepropWeb.RoverPlanningLive do
|
||||||
|
|
||||||
alias Microwaveprop.Accounts.User
|
alias Microwaveprop.Accounts.User
|
||||||
alias Microwaveprop.RoverPlanning
|
alias Microwaveprop.RoverPlanning
|
||||||
|
alias Microwaveprop.RoverPlanning.Mission
|
||||||
|
|
||||||
def table_options do
|
def table_options do
|
||||||
%{sorting: %{default_sort: [inserted_at: :desc]}}
|
%{sorting: %{default_sort: [inserted_at: :desc]}}
|
||||||
|
|
@ -18,7 +19,7 @@ defmodule MicrowavepropWeb.RoverPlanningLive do
|
||||||
id: %{label: "ID", hidden: true},
|
id: %{label: "ID", hidden: true},
|
||||||
user_id: %{label: "Owner", hidden: true},
|
user_id: %{label: "Owner", hidden: true},
|
||||||
name: %{label: "Mission", sortable: true, searchable: true, renderer: &name_cell/2},
|
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},
|
only_known_good: %{label: "Scope", sortable: true, renderer: &scope_cell/1},
|
||||||
inserted_at: %{label: "Created", sortable: true, renderer: &format_ts/1}
|
inserted_at: %{label: "Created", sortable: true, renderer: &format_ts/1}
|
||||||
]
|
]
|
||||||
|
|
@ -136,18 +137,26 @@ defmodule MicrowavepropWeb.RoverPlanningLive do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
defp band_cell(nil), do: "—"
|
# 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
|
||||||
defp band_cell(mhz) when is_integer(mhz) do
|
# primary band, but the cell shows every band the matrix scores).
|
||||||
if mhz >= 1000 do
|
defp bands_cell(_value, record) do
|
||||||
ghz = mhz / 1000
|
case Mission.bands(struct(Mission, Map.take(record, [:band_mhz, :bands_mhz]))) do
|
||||||
label = if ghz == trunc(ghz), do: "#{trunc(ghz)}", else: Float.to_string(Float.round(ghz, 1))
|
[] -> "—"
|
||||||
"#{label} GHz"
|
[single] -> band_label(single)
|
||||||
else
|
list -> Enum.map_join(list, " · ", &band_label/1)
|
||||||
"#{mhz} MHz"
|
|
||||||
end
|
end
|
||||||
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
|
defp scope_cell(true) do
|
||||||
assigns = %{}
|
assigns = %{}
|
||||||
~H|<span class="badge badge-success badge-sm">Known good only</span>|
|
~H|<span class="badge badge-success badge-sm">Known good only</span>|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue