diff options
Diffstat (limited to 'app/views/tournaments/show.html.erb')
-rw-r--r-- | app/views/tournaments/show.html.erb | 116 |
1 files changed, 62 insertions, 54 deletions
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 1f24f39..acff3d4 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,75 +1,83 @@ -<% if @tournament.joinable_by?(current_user) %> - <%= form_tag(tournament_path(@tournament), method: "put") do %> - <input type="hidden" name="update_action" value="join"> - <%= current_user.name %><%= submit_tag("Join") %> - <% end %> -<% end %> - <div class="progress"> <%= tag("div", {: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><%= @tournament.players.count %> have signed up. <%= @tournament.min_players_per_team * @tournament.min_teams_per_match %> needed. </p> +<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> -<% if current_user.in_group?(:host) %> -<p> - <strong>Game:</strong> - <%= @tournament.id %> -</p> +<div id="tournament-side-params"> + <p> + <strong>Game:</strong> + <%= @tournament.id %> + </p> -<p> - <strong>Status:</strong> - <%= @tournament.status %> -</p> + <p> + <strong>Status:</strong> + <%= @tournament.status %> + </p> -<p> - <strong>Min players per team:</strong> - <%= @tournament.min_players_per_team %> -</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>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>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>Max teams per match:</strong> + <%= @tournament.max_teams_per_match %> + </p> -<p> - <strong>Set rounds:</strong> - <%= @tournament.set_rounds %> -</p> + <p> + <strong>Set rounds:</strong> + <%= @tournament.set_rounds %> + </p> -<p> - <strong>Randomized teams:</strong> - <%= @tournament.randomized_teams %> -</p> + <p> + <strong>Randomized teams:</strong> + <%= @tournament.randomized_teams %> + </p> +</div> -<p> - <strong>Status:</strong> - <%= @tournament.status %> -</p> +<%# Show all players in the tournament %> +<% if @tournament.players.length > 0 %> + <ul id="tournament-users"> + <% @tournament.players.each do |p| %> + <li><span class="black"> <%= p.user_name %> </span> </li> + <% end %> + </ul> +<% end %> -<%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> - <input type="hidden" name="close_action" value="close"> - <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> - <%= submit_tag("Close Tournament Registration") %> - <% else %> - <%= submit_tag("Close Tournament Registration", disabled: true) %> +<%# If user can join, and user hasn't joined already, show the join tournment tag %> +<% if @tournament.joinable_by?(current_user) && !@tournament.players.include?(current_user) %> + <%= form_tag(tournament_path(@tournament), method: "put") do %> + <input type="hidden" name="update_action" value="join"> + <%= submit_tag("Join Tournamnet") %> <% end %> <% end %> -<%= link_to 'Edit', edit_tournament_path(@tournament) %> | -<%= link_to 'Back', tournaments_path %> - +<%# If user is the host, let them start the tournment %> +<% if @tournament.hosts.include?(current_user) %> + <%= form_tag(tournaments_path.to_s + "/" + @tournament.id.to_s + "/edit", method: "get") do %> + <input type="hidden" name="close_action" value="close"> + <% if @tournament.players.count >= @tournament.min_players_per_team * @tournament.min_teams_per_match %> + <%= submit_tag("Start Tournament") %> + <% else %> + <%= submit_tag("Start Tournament", disabled: true) %> + <% end %> + <br /> + <%= link_to 'Edit', edit_tournament_path(@tournament) %> | + <%= link_to 'Back', tournaments_path %> <% end %> +<%end %> + |