summaryrefslogtreecommitdiff
path: root/app/views/tournaments/show.html.erb
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/tournaments/show.html.erb')
-rw-r--r--app/views/tournaments/show.html.erb143
1 files changed, 99 insertions, 44 deletions
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index ca65ac6..07c1c6b 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -1,44 +1,99 @@
-<p id="notice"><%= notice %></p>
-
-<p>
- <strong>Game:</strong>
- <%= @tournament.game %>
-</p>
-
-<p>
- <strong>Status:</strong>
- <%= @tournament.status %>
-</p>
-
-<p>
- <strong>Name:</strong>
- <%= @tournament.name %>
-</p>
-
-<p>
- <strong>Min players per team:</strong>
- <%= @tournament.min_players_per_team %>
-</p>
-
-<p>
- <strong>Max players per team:</strong>
- <%= @tournament.max_players_per_team %>
-</p>
-
-<p>
- <strong>Min teams per match:</strong>
- <%= @tournament.min_teams_per_match %>
-</p>
-
-<p>
- <strong>Max teams per match:</strong>
- <%= @tournament.max_teams_per_match %>
-</p>
-
-<p>
- <strong>Scoring method:</strong>
- <%= @tournament.scoring_method %>
-</p>
-
-<%= link_to 'Edit', edit_tournament_path(@tournament) %> |
-<%= link_to 'Back', tournaments_path %>
+<%= link_to '« Back to all tournaments', tournaments_path, class: :breadcrumb %>
+
+<h2 id="tournament-name">
+ <%= @tournament.name %>
+</h2>
+
+<div class="progress">
+ <%# FIXME: What's up with this? Hardcoded 60%? %>
+ <%= tag("div", {:id => "prog-bar", :class => "progress-bar progress-bar-warning", :style => "width: " +(@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s + "%", "aria-valuemax" => "100", "aria-valuemin" => "0", "aria-valuenow" => (@tournament.players.count * 100 / (@tournament.min_players_per_team * @tournament.min_teams_per_match)).to_s, "role" => "progressbar"}) %>
+ <span class="sr-only">60% Complete (warning)</span>
+ </div>
+</div>
+
+<p id="players-needed"><%= pluralize(@tournament.players.count, "player has", "players have") %> signed up. <%= @tournament.min_players_per_team * @tournament.min_teams_per_match %> needed. </p>
+
+<div id="tournament-side-params">
+ <p>
+ <strong>Status:</strong>
+ <% if @tournament.status == 0 %>
+ Waiting for players...
+ <% else %>
+ Started
+ <% end %>
+ </p>
+
+ <p>
+ <strong>Name:</strong>
+ <%= @tournament.name %>
+ </p>
+
+ <p>
+ <strong>Min players per team:</strong>
+ <%= @tournament.min_players_per_team %>
+ </p>
+
+ <p>
+ <strong>Max players per team:</strong>
+ <%= @tournament.max_players_per_team %>
+ </p>
+
+ <p>
+ <strong>Min teams per match:</strong>
+ <%= @tournament.min_teams_per_match %>
+ </p>
+
+ <p>
+ <strong>Max teams per match:</strong>
+ <%= @tournament.max_teams_per_match %>
+ </p>
+
+ <p>
+ <strong>Scoring method:</strong>
+ <%= @tournament.scoring_method.titleize %>
+ </p>
+
+ <% @tournament.settings.each do |setting| %>
+ <p>
+ <strong><%= setting.name %></strong>
+ <%= setting.value %>
+ </p>
+ <% end %>
+</div>
+
+<div>
+ <% if @tournament.players.length > 0 %>
+ <h3>Players Here:</h3>
+ <ul id="tournament-users">
+ <% @tournament.players.each do |p| %>
+ <li><%= p.user_name %></li>
+ <% end %>
+ </ul>
+ <% else %>
+ <h3 div="players-needed">Hmmm.... nobody's here yet! You and your friends should join the tournament.</h3>
+ <% end %>
+</div>
+
+<div class="actions">
+ <%# If user can join, and user hasn't joined already, show a join tournment button %>
+ <% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %>
+ <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <input type="hidden" name="update_action" value="join">
+ <%= submit_tag("Join Tournament") %>
+ <% end %>
+ <% elsif @tournament.players.include?(current_user) %>
+ <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <input type="hidden" name="update_action" value="leave">
+ <%= submit_tag("Leave Tournament") %>
+ <% end %>
+ <% end %>
+ <%# If user is the host, let them start the tournment %>
+ <% if @tournament.check_permission(current_user, :edit) %>
+ <%= form_tag(tournament_path(@tournament), method: "put", role: :button) do %>
+ <input type="hidden" name="update_action" value="start">
+ <%= submit_tag("Start Tournament", disabled: (@tournament.players.count < @tournament.min_players_per_team * @tournament.min_teams_per_match)) %>
+ <% end %>
+ <%= link_to 'Edit Tournament', edit_tournament_path(@tournament), role: :button %>
+ <%= link_to 'Cancel Tournament', @tournament, method: :delete, data: { confirm: 'Are you sure?' }, role: :button %>
+ <% end %>
+</div>