171 lines
10 KiB
ERB
171 lines
10 KiB
ERB
<% coverage = tournament_streaming_coverage(@matches) %>
|
||
<% live_counts = tournament_streaming_live_counts(@matches) %>
|
||
<div class="tournament-stream-plan">
|
||
<div class="card">
|
||
<div class="tournament-stream-plan__header">
|
||
<div>
|
||
<h2 class="tournament-stream-plan__title"><%= t("tournaments.hub.stream_plan_title") %></h2>
|
||
<p class="tournament-hub-hint"><%= t("tournaments.hub.stream_plan_hint") %></p>
|
||
</div>
|
||
<% if @writable && @matches.any? %>
|
||
<a class="btn btn-secondary tournament-stream-plan__jump" href="#invito-operatore"><%= t("tournaments.hub.stream_plan_invite_title") %></a>
|
||
<% end %>
|
||
</div>
|
||
|
||
<% if @matches.any? %>
|
||
<div class="tournament-stream-plan__stats">
|
||
<% %i[live waiting_time waiting_operator ended uncovered].each do |state| %>
|
||
<% count = live_counts[state].to_i %>
|
||
<% next if count.zero? %>
|
||
<span class="tournament-stream-plan__stat tournament-stream-plan__stat--<%= state %>">
|
||
<%= t("tournaments.hub.stream_plan_live_count.#{state}", count: count) %>
|
||
</span>
|
||
<% end %>
|
||
<% if @writable && coverage[:open].positive? %>
|
||
<button type="button" class="btn btn-secondary tournament-stream-plan__select" data-select-uncovered="tournament-stream-invite">
|
||
<%= t("tournaments.hub.stream_plan_select_open") %>
|
||
</button>
|
||
<% end %>
|
||
</div>
|
||
|
||
<% tournament_matches_grouped_by_date(@matches).each do |date, matches| %>
|
||
<h3 class="tournament-stream-plan__day">
|
||
<%= date ? l(date, format: :long) : t("tournaments.hub.stream_plan_unscheduled") %>
|
||
</h3>
|
||
<div class="tournament-table-wrap">
|
||
<table class="data tournament-stream-plan__table">
|
||
<thead>
|
||
<tr>
|
||
<% if @writable %><th class="tournament-stream-plan__check-col"></th><% end %>
|
||
<th><%= t("tournaments.hub.datetime") %></th>
|
||
<th><%= t("tournaments.hub.court") %></th>
|
||
<th><%= t("tournaments.hub.stream_plan_match") %></th>
|
||
<th><%= t("tournaments.hub.stream_plan_live_col") %></th>
|
||
<th><%= t("tournaments.hub.stream_plan_operator") %></th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<% matches.each do |match| %>
|
||
<% state = tournament_broadcast_live_state(match) %>
|
||
<% uncovered = state == :uncovered %>
|
||
<tr class="tournament-stream-plan__row tournament-stream-plan__row--<%= state %>">
|
||
<% if @writable %>
|
||
<td class="tournament-stream-plan__check-col">
|
||
<% if uncovered %>
|
||
<label class="tournament-stream-plan__check">
|
||
<%= check_box_tag "match_ids[]", match.id, false,
|
||
id: "plan_match_#{match.id}",
|
||
form: "tournament-stream-invite",
|
||
data: { uncovered_match: true } %>
|
||
<span class="visually-hidden"><%= t("tournaments.hub.stream_plan_select_match") %></span>
|
||
</label>
|
||
<% end %>
|
||
</td>
|
||
<% end %>
|
||
<td><%= match.scheduled_at ? match.scheduled_at.in_time_zone.strftime("%H:%M") : "—" %></td>
|
||
<td><%= match.court.presence || "—" %></td>
|
||
<td>
|
||
<div class="tournament-stream-plan__matchup">
|
||
<%= tournament_team_chip(match.home_participant, name: match.home_display_name) %>
|
||
<span class="tournament-stream-plan__vs">–</span>
|
||
<%= tournament_team_chip(match.away_participant, name: match.away_display_name) %>
|
||
</div>
|
||
</td>
|
||
<td>
|
||
<span class="tournament-live-status tournament-live-status--<%= state %>">
|
||
<span class="tournament-live-status__dot" aria-hidden="true"></span>
|
||
<%= t("tournaments.hub.stream_plan_live.#{state}") %>
|
||
</span>
|
||
</td>
|
||
<%= render "public/tournaments/match_streaming", match: match, writable: @writable, allow_invite: false, return_tab: "dirette" %>
|
||
</tr>
|
||
<% end %>
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
<% end %>
|
||
<% else %>
|
||
<p class="tournament-hub-hint" style="margin-top:16px"><%= t("tournaments.hub.no_matches") %></p>
|
||
<% end %>
|
||
</div>
|
||
|
||
<% if @writable %>
|
||
<div class="card tournament-stream-plan__invite-card" id="invito-operatore">
|
||
<h2 class="tournament-stream-plan__title"><%= t("tournaments.hub.stream_plan_invite_title") %></h2>
|
||
<p class="tournament-hub-hint"><%= t("tournaments.hub.stream_plan_invite_hint") %></p>
|
||
|
||
<%= form_with url: public_tournament_invitations_path(@tournament), method: :post,
|
||
html: { id: "tournament-stream-invite", class: "tournament-form tournament-invite-form tournament-stream-plan__invite" } do %>
|
||
<%= hidden_field_tag :tab, "dirette" %>
|
||
<div class="tournament-form__field">
|
||
<%= label_tag :email, t("tournaments.hub.invite_email") %>
|
||
<%= email_field_tag :email, @tournament.invite_draft_email, required: true, autocomplete: "email" %>
|
||
</div>
|
||
<div class="tournament-form__field">
|
||
<%= label_tag :note, t("tournaments.hub.invite_note") %>
|
||
<%= text_area_tag :note, @tournament.invite_draft_note, rows: 2, maxlength: 2000, data: { invite_note: true },
|
||
placeholder: t("tournaments.hub.invite_note_placeholder") %>
|
||
</div>
|
||
<div class="tournament-form__field">
|
||
<%= label_tag :court, t("tournaments.hub.court") %>
|
||
<%= select_tag :court, options_for_select(@tournament.court_list) %>
|
||
</div>
|
||
<div class="tournament-form__field">
|
||
<%= label_tag :on_date, t("tournaments.hub.datetime") %>
|
||
<%= date_field_tag :on_date, @tournament.starts_on %>
|
||
</div>
|
||
<p class="tournament-hub-hint tournament-form__full"><%= t("tournaments.hub.stream_plan_court_day_hint") %></p>
|
||
|
||
<div class="tournament-form__full tournament-stream-plan__mail">
|
||
<h3 class="tournament-stream-plan__mail-title"><%= t("tournaments.hub.invite_email_body") %></h3>
|
||
<p class="tournament-hub-hint"><%= t("tournaments.hub.invite_email_hint") %></p>
|
||
<% if @tournament.invite_draft_saved_at.present? %>
|
||
<p class="tournament-hub-hint"><%= t("tournaments.hub.invite_draft_hint", time: l(@tournament.invite_draft_saved_at, format: :short)) %></p>
|
||
<% end %>
|
||
<div class="invite-editor"
|
||
data-invite-editor
|
||
data-upload-url="<%= public_tournament_invite_images_path(@tournament) %>"
|
||
data-msg-type="<%= t("tournaments.hub.invite_image_invalid") %>"
|
||
data-msg-size="<%= t("tournaments.hub.invite_image_too_big") %>"
|
||
data-msg-uploading="<%= t("tournaments.hub.invite_image_uploading") %>"
|
||
data-msg-failed="<%= t("tournaments.hub.invite_image_failed") %>"
|
||
data-msg-link="<%= t("tournaments.hub.invite_editor_link_prompt") %>">
|
||
<div class="invite-editor__toolbar" role="toolbar" aria-label="<%= t("tournaments.hub.invite_editor_toolbar") %>">
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="bold" aria-label="<%= t("tournaments.hub.invite_editor_bold") %>"><i class="fa-solid fa-bold" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="italic" aria-label="<%= t("tournaments.hub.invite_editor_italic") %>"><i class="fa-solid fa-italic" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="underline" aria-label="<%= t("tournaments.hub.invite_editor_underline") %>"><i class="fa-solid fa-underline" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="insertUnorderedList" aria-label="<%= t("tournaments.hub.invite_editor_ul") %>"><i class="fa-solid fa-list-ul" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="insertOrderedList" aria-label="<%= t("tournaments.hub.invite_editor_ol") %>"><i class="fa-solid fa-list-ol" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="createLink" aria-label="<%= t("tournaments.hub.invite_editor_link") %>"><i class="fa-solid fa-link" aria-hidden="true"></i></button>
|
||
<button type="button" class="invite-editor__btn" data-invite-cmd="image" aria-label="<%= t("tournaments.hub.invite_editor_image") %>"><i class="fa-solid fa-image" aria-hidden="true"></i></button>
|
||
<input type="file" accept="image/png,image/jpeg,image/webp,image/gif" hidden data-invite-file>
|
||
</div>
|
||
<div class="invite-editor__frame">
|
||
<div class="invite-editor__surface" contenteditable="true" role="textbox" aria-multiline="true">
|
||
<%= raw tournament_invite_editor_html(@tournament, current_user) %>
|
||
</div>
|
||
<span class="invite-editor__handle" hidden></span>
|
||
</div>
|
||
<p class="invite-editor__status" data-invite-status hidden></p>
|
||
</div>
|
||
<%= hidden_field_tag :email_html, "", id: "invite-email-html", data: { invite_html: true } %>
|
||
</div>
|
||
|
||
<div class="tournament-form__actions">
|
||
<%= button_tag t("tournaments.hub.invite_save"), type: "submit", name: "intent", value: "save",
|
||
formnovalidate: true, class: "btn btn-secondary" %>
|
||
<%= submit_tag t("tournaments.hub.stream_plan_invite_selected"), class: "btn btn-primary" %>
|
||
<%= button_tag t("tournaments.hub.stream_plan_invite_court"), type: "submit", name: "whole_court", value: "1", class: "btn btn-secondary" %>
|
||
</div>
|
||
<% end %>
|
||
|
||
<% if flash[:invite_url].present? %>
|
||
<div class="team-invite-link" id="invito-generato" style="margin-top:16px">
|
||
<p><%= t("team.invite.share_hint") %></p>
|
||
<code id="tournament-invite-url"><%= flash[:invite_url] %></code>
|
||
</div>
|
||
<% end %>
|
||
</div>
|
||
<% end %>
|
||
</div>
|