mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-03-25 01:14:43 +00:00
Added a turbo stream for the current and next match on mat stats page.
This commit is contained in:
37
app/views/mats/_current_match.html.erb
Normal file
37
app/views/mats/_current_match.html.erb
Normal file
@@ -0,0 +1,37 @@
|
||||
<% @mat = mat %>
|
||||
<% @match = local_assigns[:match] || mat.unfinished_matches.first %>
|
||||
<% @next_match = local_assigns[:next_match] || mat.unfinished_matches.second %>
|
||||
<% @show_next_bout_button = local_assigns.key?(:show_next_bout_button) ? local_assigns[:show_next_bout_button] : true %>
|
||||
|
||||
<% @wrestlers = [] %>
|
||||
<% if @match %>
|
||||
<% if @match.w1 %>
|
||||
<% @wrestler1_name = @match.wrestler1.name %>
|
||||
<% @wrestler1_school_name = @match.wrestler1.school.name %>
|
||||
<% @wrestler1_last_match = @match.wrestler1.last_match %>
|
||||
<% @wrestlers.push(@match.wrestler1) %>
|
||||
<% else %>
|
||||
<% @wrestler1_name = "Not assigned" %>
|
||||
<% @wrestler1_school_name = "N/A" %>
|
||||
<% @wrestler1_last_match = nil %>
|
||||
<% end %>
|
||||
|
||||
<% if @match.w2 %>
|
||||
<% @wrestler2_name = @match.wrestler2.name %>
|
||||
<% @wrestler2_school_name = @match.wrestler2.school.name %>
|
||||
<% @wrestler2_last_match = @match.wrestler2.last_match %>
|
||||
<% @wrestlers.push(@match.wrestler2) %>
|
||||
<% else %>
|
||||
<% @wrestler2_name = "Not assigned" %>
|
||||
<% @wrestler2_school_name = "N/A" %>
|
||||
<% @wrestler2_last_match = nil %>
|
||||
<% end %>
|
||||
|
||||
<% @tournament = @match.tournament %>
|
||||
<% end %>
|
||||
|
||||
<% if @match %>
|
||||
<%= render "matches/matchstats" %>
|
||||
<% else %>
|
||||
<p>No matches assigned to this mat.</p>
|
||||
<% end %>
|
||||
@@ -1,9 +1,12 @@
|
||||
<h3>Mat <%= @mat.name %></h3>
|
||||
<h3>Tournament: <%= @mat.tournament.name %></h3>
|
||||
|
||||
<% if @match %>
|
||||
<%= render 'matches/matchstats' %>
|
||||
<% else %>
|
||||
<p>No matches assigned to this mat.</p>
|
||||
<% end %>
|
||||
<%= turbo_stream_from @mat %>
|
||||
|
||||
<%= turbo_frame_tag dom_id(@mat, :current_match) do %>
|
||||
<%= render "mats/current_match",
|
||||
mat: @mat,
|
||||
match: @match,
|
||||
next_match: @next_match,
|
||||
show_next_bout_button: @show_next_bout_button %>
|
||||
<% end %>
|
||||
|
||||
@@ -33,4 +33,7 @@
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</table>
|
||||
<br>
|
||||
<p>Total matches without byes: <%= @matches.select{|m| m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||
<p>Unfinished matches: <%= @matches.select{|m| m.finished != 1 and m.loser1_name != 'BYE' and m.loser2_name != 'BYE'}.size %></p>
|
||||
Reference in New Issue
Block a user