Aggiunge i tornei con hub, pagina pubblica e tabellone per semifinali e finali.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-05 15:05:57 +02:00
co-authored by Cursor
parent d52434fb2e
commit a1f4c24a43
124 changed files with 6979 additions and 91 deletions
@@ -0,0 +1,113 @@
<div class="card">
<% if @writable && @tournament.uses_knockout? %>
<div class="tournament-knockout-help">
<h2 style="margin-top:0"><%= t("tournaments.hub.knockout_how_title") %></h2>
<ol class="tournament-knockout-help__steps">
<li><%= t("tournaments.hub.knockout_how_groups") %></li>
<li><%= t("tournaments.hub.knockout_how_seed") %></li>
<li><%= t("tournaments.hub.knockout_how_advance") %></li>
</ol>
<% if @tournament.uses_groups? %>
<%= button_to t("tournaments.hub.propose_knockout"),
public_propose_knockout_tournament_path(@tournament),
method: :post, class: "btn btn-primary" %>
<% end %>
</div>
<% end %>
<% @groups.each do |group| %>
<h2 style="margin-top:20px"><%= group.name %><%= t("tournaments.hub.standings") %></h2>
<% rows = @standings_by_group[group] %>
<% if rows.any? %>
<table class="data">
<thead>
<tr>
<th></th>
<th><%= t("tournaments.hub.played") %></th>
<th><%= t("tournaments.hub.won") %></th>
<th><%= t("tournaments.hub.lost") %></th>
<th><%= t("tournaments.hub.points") %></th>
</tr>
</thead>
<tbody>
<% rows.each_with_index do |row, idx| %>
<tr>
<td><%= idx + 1 %>. <%= tournament_team_chip(row.participant) %></td>
<td><%= row.played %></td>
<td><%= row.won %></td>
<td><%= row.lost %></td>
<td><strong><%= row.points %></strong></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% end %>
<% @rounds.each do |round| %>
<h2 style="margin-top:24px"><%= round.name %></h2>
<% round_matches = @matches.select { |m| m.tournament_round_id == round.id } %>
<% if round_matches.any? %>
<div class="tournament-table-wrap">
<table class="data tournament-match-table">
<thead>
<tr>
<th><%= t("tournaments.hub.datetime") %></th>
<th><%= t("tournaments.hub.home") %></th>
<th><%= t("tournaments.hub.away") %></th>
<th><%= t("tournaments.hub.result") %></th>
<% if @writable %><th></th><% end %>
</tr>
</thead>
<tbody>
<% round_matches.each do |match| %>
<% form_id = "ko-edit-#{match.id}" %>
<%= form_with url: public_tournament_match_path(@tournament, match), method: :patch, html: { id: form_id, class: "visually-hidden" } do %>
<%= hidden_field_tag :tab, "tabellone", form: form_id %>
<%= datetime_local_field_tag "match[scheduled_at]", tournament_datetime_local(match.scheduled_at),
id: "ko_at_#{match.id}", form: form_id %>
<% end %>
<tr>
<td><%= match.scheduled_at ? l(match.scheduled_at, format: :short) : "—" %></td>
<td>
<%= render "public/tournaments/match_side_select", match: match, side: :home, form_id: form_id %>
<% src = tournament_side_source_label(match, :home) %>
<% if src.present? && match.home_participant_id.blank? %>
<div class="tournament-knockout-source"><%= src %></div>
<% end %>
</td>
<td>
<%= render "public/tournaments/match_side_select", match: match, side: :away, form_id: form_id %>
<% src = tournament_side_source_label(match, :away) %>
<% if src.present? && match.away_participant_id.blank? %>
<div class="tournament-knockout-source"><%= src %></div>
<% end %>
</td>
<td>
<% if tournament_match_sides_locked?(match) %>
<%= match.home_score %><%= match.away_score %>
<% elsif @writable %>
<span class="tournament-match-form__score">
<%= number_field_tag :home_score, match.home_score, id: "ko_home_score_#{match.id}", form: form_id %>
<span></span>
<%= number_field_tag :away_score, match.away_score, id: "ko_away_score_#{match.id}", form: form_id %>
</span>
<% else %>
<% end %>
</td>
<% if @writable %>
<td class="tournament-match-form__actions">
<%= submit_tag t("tournaments.hub.save_match"), form: form_id, class: "btn btn-secondary tournament-match-form__save" %>
</td>
<% end %>
</tr>
<% end %>
</tbody>
</table>
</div>
<% else %>
<p class="tournament-hub-hint"><%= t("tournaments.hub.knockout_round_empty") %></p>
<% end %>
<% end %>
</div>