summaryrefslogtreecommitdiff
path: root/app/views/matches/index.html.erb
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/matches/index.html.erb')
-rw-r--r--app/views/matches/index.html.erb38
1 files changed, 18 insertions, 20 deletions
diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb
index 78c97bb..15b59f4 100644
--- a/app/views/matches/index.html.erb
+++ b/app/views/matches/index.html.erb
@@ -4,32 +4,30 @@
<table class="table">
<thead>
<tr>
- <th>Status</th>
<th>Name</th>
+ <th>Status</th>
<th>Winner</th>
<th></th>
</tr>
</thead>
- <tbody class="table-hover">
- <% @tournament.matches.each do |match| %>
- <tr>
- <td><%= match.status %></td>
- <td><%= match.id%></td>
- <td><%= match.name %></td>
- <td><%= link_to "Show", tournament_match_path(@tournament, match) %>
- <td> <%# If user is the host, let them start the tournment %>
- <% if @tournament.hosts.include?(current_user) %>
-
- <%= form_tag(tournament_match_path(@tournament, match), method: "put") do %>
- <input type="hidden" name="update_action" value="start">
- <%= submit_tag("Start Match") %>
- <% end %>
- <% end %>
-</div></td>
- </tr>
- <% end %>
- </tbody>
+ <tbody class="table-hover">
+ <% @tournament.matches.order(:id).reverse.each do |match| %><tr>
+ <td><%= match.name %></td>
+ <td><%= match.status %></td>
+ <td><%= (match.winner.nil? ? "-" : "Team #{match.winner.id}") %></td>
+ <td><%= link_to "Show", tournament_match_path(@tournament, match) %>
+ <td> <%# If user is the host, let them start the tournment %>
+ <% if @tournament.hosts.include?(current_user) %>
+ <%= form_tag(tournament_match_path(@tournament, match), method: "put") do %>
+ <input type="hidden" name="update_action" value="start">
+ <% @startable = (match.status == 0) and (match.teams.count >= @tournament.min_teams_per_match) %>
+ <%= submit_tag("Start Match", :disabled => ! @startable) %>
+ <% end %>
+ <% end %>
+ </td>
+ </tr><% end %>
+ </tbody>
</table>
<br>