Files
MatchLiveTv/backend/app/views/public/tournaments/_tab_squadre.html.erb
T

101 lines
4.6 KiB
ERB

<div class="card">
<p class="tournament-hub-hint"><%= t("tournaments.hub.squadre_edit_hint") %></p>
<% if @writable %>
<%= form_with url: public_tournament_participants_path(@tournament), method: :post, html: { class: "tournament-form" } do %>
<div class="tournament-form__field">
<%= label_tag "tournament_participant[name]", t("tournaments.hub.add_participant") %>
<%= text_field_tag "tournament_participant[name]", nil, required: true, placeholder: t("tournaments.hub.participant_name") %>
</div>
<% if @groups.any? %>
<div class="tournament-form__field">
<%= label_tag "tournament_participant[group_id]", t("tournaments.hub.participant_group") %>
<%= select_tag "tournament_participant[group_id]",
options_for_select([[t("tournaments.hub.no_group"), ""]] + @groups.map { |g| [g.name, g.id] }) %>
</div>
<% end %>
<div class="tournament-form__actions">
<%= submit_tag t("tournaments.hub.add_participant"), class: "btn btn-primary" %>
</div>
<% end %>
<% end %>
<% if @participants.any? %>
<div class="tournament-table-wrap">
<table class="data tournament-squad-table">
<thead>
<tr>
<th><%= t("tournaments.hub.logo") %></th>
<th><%= t("tournaments.hub.participant_name") %></th>
<th><%= t("tournaments.hub.participant_group") %></th>
<th></th>
</tr>
</thead>
<tbody>
<% @participants.each do |participant| %>
<% form_id = "participant-edit-#{participant.id}" %>
<% logo = participant.effective_logo_url %>
<%= form_with url: public_tournament_participant_path(@tournament, participant),
method: :patch,
multipart: true,
html: { id: form_id, class: "visually-hidden" } do %>
<% end %>
<tr>
<td>
<div class="tournament-squad-logo">
<div class="tournament-squad-logo__preview" aria-hidden="true">
<% if logo.present? %>
<%= image_tag logo, alt: "" %>
<% else %>
<span class="tournament-squad-logo__empty">+</span>
<% end %>
</div>
<% if @writable %>
<label class="btn btn-secondary tournament-squad-logo__btn">
<%= t("tournaments.hub.logo_file") %>
<%= file_field_tag "tournament_participant[logo_file]",
id: "logo_file_#{participant.id}",
form: form_id,
accept: "image/png,image/jpeg,image/webp",
onchange: "this.form.requestSubmit()" %>
</label>
<% end %>
</div>
</td>
<td>
<% if @writable %>
<%= text_field_tag "tournament_participant[name]", participant.name,
id: "participant_name_#{participant.id}",
form: form_id,
required: true,
class: "tournament-squad-name" %>
<% else %>
<%= tournament_team_chip(participant) %>
<% end %>
</td>
<td>
<% if @writable && @groups.any? %>
<%= select_tag "tournament_participant[group_id]",
options_for_select([[t("tournaments.hub.no_group"), ""]] + @groups.map { |g| [g.name, g.id] }, participant.group_id),
id: "participant_group_#{participant.id}",
form: form_id,
class: "tournament-squad-group" %>
<% else %>
<%= participant.group&.name || "—" %>
<% end %>
</td>
<td class="tournament-match-form__actions">
<% if @writable %>
<%= submit_tag t("tournaments.hub.save_match"), form: form_id, class: "btn btn-secondary tournament-match-form__save" %>
<%= button_to t("matches.index.delete"), public_tournament_participant_path(@tournament, participant),
method: :delete, class: "btn btn-secondary tournament-match-form__save",
form: { data: { turbo_confirm: participant.name } } %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>