Show grouped reciprocal QSOs on main listing, not just search
This commit is contained in:
parent
341a04190a
commit
b9aac6f688
1 changed files with 63 additions and 84 deletions
|
|
@ -95,93 +95,72 @@ defmodule MicrowavepropWeb.QsoLive.Index do
|
|||
</div>
|
||||
</form>
|
||||
|
||||
<%= if @search != "" do %>
|
||||
<table class="table table-sm w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-8"></th>
|
||||
<th>Station 1</th>
|
||||
<th>Grid 1</th>
|
||||
<th>Station 2</th>
|
||||
<th>Grid 2</th>
|
||||
<th>Band</th>
|
||||
<th>Mode</th>
|
||||
<th>Distance (km)</th>
|
||||
<th>Timestamp</th>
|
||||
<table class="table table-sm w-full">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-8"></th>
|
||||
<th>Station 1</th>
|
||||
<th>Grid 1</th>
|
||||
<th>Station 2</th>
|
||||
<th>Grid 2</th>
|
||||
<th>Band</th>
|
||||
<th>Mode</th>
|
||||
<th>Distance (km)</th>
|
||||
<th>Submitted</th>
|
||||
<th>Timestamp</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for {primary, reciprocals} <- @grouped_qsos do %>
|
||||
<tr class="h-1">
|
||||
<td colspan="10"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%= for {primary, reciprocals} <- @grouped_qsos do %>
|
||||
<%!-- Spacer row between groups --%>
|
||||
<tr class="h-2">
|
||||
<td colspan="9"></td>
|
||||
</tr>
|
||||
<tr
|
||||
class={[
|
||||
"hover:bg-base-200 cursor-pointer",
|
||||
reciprocals != [] && "bg-primary/5"
|
||||
]}
|
||||
phx-click={JS.navigate(~p"/qsos/#{primary.id}")}
|
||||
>
|
||||
<td class="w-8 text-center">
|
||||
<span
|
||||
:if={reciprocals != []}
|
||||
class="badge badge-primary badge-xs"
|
||||
title="Has reciprocal QSO"
|
||||
>
|
||||
{length(reciprocals) + 1}
|
||||
</span>
|
||||
</td>
|
||||
<td class="font-mono font-semibold">{primary.station1}</td>
|
||||
<td>{primary.grid1 || "—"}</td>
|
||||
<td class="font-mono font-semibold">{primary.station2}</td>
|
||||
<td>{primary.grid2 || "—"}</td>
|
||||
<td>{primary.band}</td>
|
||||
<td>{primary.mode}</td>
|
||||
<td>{primary.distance_km}</td>
|
||||
<td>{Calendar.strftime(primary.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||
</tr>
|
||||
<%= for recip <- reciprocals do %>
|
||||
<tr
|
||||
class="hover:bg-base-200 cursor-pointer bg-primary/5 opacity-70 border-t-0"
|
||||
phx-click={JS.navigate(~p"/qsos/#{recip.id}")}
|
||||
<tr
|
||||
class={[
|
||||
"hover:bg-base-200 cursor-pointer",
|
||||
reciprocals != [] && "bg-primary/5"
|
||||
]}
|
||||
phx-click={JS.navigate(~p"/qsos/#{primary.id}")}
|
||||
>
|
||||
<td class="w-8 text-center">
|
||||
<span
|
||||
:if={reciprocals != []}
|
||||
class="badge badge-primary badge-xs"
|
||||
title="Has reciprocal QSO"
|
||||
>
|
||||
<td class="w-8 text-center text-primary">↳</td>
|
||||
<td class="font-mono">{recip.station1}</td>
|
||||
<td>{recip.grid1 || "—"}</td>
|
||||
<td class="font-mono">{recip.station2}</td>
|
||||
<td>{recip.grid2 || "—"}</td>
|
||||
<td>{recip.band}</td>
|
||||
<td>{recip.mode}</td>
|
||||
<td>{recip.distance_km}</td>
|
||||
<td>{Calendar.strftime(recip.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
{length(reciprocals) + 1}
|
||||
</span>
|
||||
</td>
|
||||
<td class="font-mono font-semibold">{primary.station1}</td>
|
||||
<td>{primary.grid1 || "—"}</td>
|
||||
<td class="font-mono font-semibold">{primary.station2}</td>
|
||||
<td>{primary.grid2 || "—"}</td>
|
||||
<td>{primary.band}</td>
|
||||
<td>{primary.mode}</td>
|
||||
<td>{primary.distance_km}</td>
|
||||
<td>{if primary.user_submitted, do: "Yes", else: "—"}</td>
|
||||
<td>{Calendar.strftime(primary.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||
</tr>
|
||||
<%= for recip <- reciprocals do %>
|
||||
<tr
|
||||
class="hover:bg-base-200 cursor-pointer bg-primary/5 opacity-70 border-t-0"
|
||||
phx-click={JS.navigate(~p"/qsos/#{recip.id}")}
|
||||
>
|
||||
<td class="w-8 text-center text-primary">↳</td>
|
||||
<td class="font-mono">{recip.station1}</td>
|
||||
<td>{recip.grid1 || "—"}</td>
|
||||
<td class="font-mono">{recip.station2}</td>
|
||||
<td>{recip.grid2 || "—"}</td>
|
||||
<td>{recip.band}</td>
|
||||
<td>{recip.mode}</td>
|
||||
<td>{recip.distance_km}</td>
|
||||
<td>{if recip.user_submitted, do: "Yes", else: "—"}</td>
|
||||
<td>{Calendar.strftime(recip.qso_timestamp, "%Y-%m-%d %H:%M")}</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<.table
|
||||
id="qsos"
|
||||
rows={@qsos}
|
||||
row_id={fn qso -> "qso-#{qso.id}" end}
|
||||
row_click={fn qso -> JS.navigate(~p"/qsos/#{qso.id}") end}
|
||||
sort_by={@sort_by}
|
||||
sort_order={@sort_order}
|
||||
>
|
||||
<:col :let={qso} label="Station 1" sort_field="station1">{qso.station1}</:col>
|
||||
<:col :let={qso} label="Grid 1">{qso.grid1 || "—"}</:col>
|
||||
<:col :let={qso} label="Station 2" sort_field="station2">{qso.station2}</:col>
|
||||
<:col :let={qso} label="Grid 2">{qso.grid2 || "—"}</:col>
|
||||
<:col :let={qso} label="Band" sort_field="band">{qso.band}</:col>
|
||||
<:col :let={qso} label="Mode" sort_field="mode">{qso.mode}</:col>
|
||||
<:col :let={qso} label="Distance (km)" sort_field="distance_km">{qso.distance_km}</:col>
|
||||
<:col :let={qso} label="Submitted">{if qso.user_submitted, do: "Yes", else: "—"}</:col>
|
||||
<:col :let={qso} label="Timestamp" sort_field="qso_timestamp">
|
||||
{Calendar.strftime(qso.qso_timestamp, "%Y-%m-%d %H:%M")}
|
||||
</:col>
|
||||
</.table>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="flex items-center justify-between pt-4">
|
||||
<.link
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue