fix(rover): wire delete X button to actually remove station rows

This commit is contained in:
Graham McIntire 2026-04-25 16:32:10 -05:00
parent 10fcc764f6
commit 6f25993998
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -465,8 +465,9 @@ defmodule MicrowavepropWeb.RoverLive do
Enum.find_value(@bands, "#{band} MHz", fn b -> if b.value == band, do: b.label end)
end
defp station_id(%{id: id}), do: to_string(id)
defp station_id(_), do: nil
defp station_id(%{id: id}) when not is_nil(id), do: to_string(id)
defp station_id(%{callsign: call}) when is_binary(call), do: "call:" <> call
defp station_id(_), do: ""
# ── Render ───────────────────────────────────────────────────────────
@ -571,9 +572,9 @@ defmodule MicrowavepropWeb.RoverLive do
</.sidebar_section>
<.sidebar_section title="FIXED STATIONS">
<ul class="menu menu-sm p-0 gap-0.5">
<li :for={s <- @fixed_stations}>
<label class="cursor-pointer flex items-center gap-2 py-1">
<div class="flex flex-col gap-0.5">
<div :for={s <- @fixed_stations} class="flex items-center gap-2 py-1">
<label class="cursor-pointer flex items-center gap-2 flex-1 min-w-0">
<input
type="checkbox"
class="checkbox checkbox-xs"
@ -581,20 +582,20 @@ defmodule MicrowavepropWeb.RoverLive do
phx-click="toggle_station"
phx-value-id={station_id(s)}
/>
<span class="font-mono text-xs flex-1">{s.callsign}</span>
<span class="font-mono text-xs flex-1 truncate">{s.callsign}</span>
<span :if={s.grid} class="opacity-60 text-[11px]">{s.grid}</span>
<button
type="button"
class="btn btn-ghost btn-xs btn-square opacity-50 hover:opacity-100"
phx-click="delete_station"
phx-value-id={station_id(s)}
title="Remove"
>
×
</button>
</label>
</li>
</ul>
<button
type="button"
class="btn btn-ghost btn-xs btn-square opacity-50 hover:opacity-100 shrink-0"
phx-click="delete_station"
phx-value-id={station_id(s)}
title="Remove"
>
×
</button>
</div>
</div>
<form phx-submit="add_station" class="flex gap-1 mt-2">
<input
type="text"