summaryrefslogtreecommitdiff
path: root/app/views/tournaments
diff options
context:
space:
mode:
authorAndrewMurrell <amurrel@purdue.edu>2014-03-25 17:38:38 -0400
committerAndrewMurrell <amurrel@purdue.edu>2014-03-25 17:38:38 -0400
commit53b4f8028fc987b0cf26a7a073fec7064b4b6d8a (patch)
treed277b31519df83e8a1c060b04c6ea6cf50b5c361 /app/views/tournaments
parent0c22c4bd9a0b4a0b0ff5840c1af41c0b320e3529 (diff)
revert Guntas
Diffstat (limited to 'app/views/tournaments')
-rw-r--r--app/views/tournaments/_selected.html.erb21
-rw-r--r--app/views/tournaments/index.html.erb47
-rw-r--r--app/views/tournaments/join.html.erb2
-rw-r--r--app/views/tournaments/new.html.erb15
-rw-r--r--app/views/tournaments/show.html.erb35
5 files changed, 100 insertions, 20 deletions
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
new file mode 100644
index 0000000..8734b14
--- /dev/null
+++ b/app/views/tournaments/_selected.html.erb
@@ -0,0 +1,21 @@
+<%= form_for(@tournament) do |f| %>
+ <%= render "common/error_messages", :target => @tournament %>
+ <%= f.hidden_field(:game_id) %>
+
+ <% @chosen = Game.find_by(params[:game]) %>
+ <% @tournament.attributes.each do |name, value| %>
+ <% if (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") %>
+ <% next %>
+ <% end %>
+ <p>
+ <%= f.label name %><br>
+ <% if !@chosen.attributes[name].nil? %>
+ <%= f.text_field(name, :value => @chosen.attributes[name] ) %>
+ <% else %>
+ <%= f.text_field name %>
+ <% end %>
+ </p>
+ <% end %>
+
+ <%= f.submit %>
+<% end %>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index f8f21e7..90c3d7a 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -1,16 +1,14 @@
-<h1>Listing tournaments</h1>
+<h1>Listing Tournaments</h1>
-<table>
+<% if @tournaments.length > 0 %>
+<table class="table table-hover">
<thead>
<tr>
<th>Name</th>
<th>Game</th>
<th>Status</th>
- <th>Min players per team</th>
- <th>Max players per team</th>
- <th>Min teams per match</th>
- <th>Max teams per match</th>
- <th>Set rounds</th>
+ <th>Players per team</th>
+ <th>Teams per match</th>
<th>Randomized teams</th>
<th></th>
<th></th>
@@ -22,13 +20,28 @@
<% @tournaments.each do |tournament| %>
<tr>
<td><%= tournament.name %></td>
- <td><%= tournament.game %></td>
- <td><%= tournament.status %></td>
- <td><%= tournament.min_players_per_team %></td>
- <td><%= tournament.max_players_per_team %></td>
- <td><%= tournament.min_teams_per_match %></td>
- <td><%= tournament.max_teams_per_match %></td>
- <td><%= tournament.set_rounds %></td>
+ <td><% case tournament.status
+ when 0 %>
+ <%= form_tag(tournament_path(tournament), method: "put") do %>
+ <input type="hidden" name="update_action" value="join">
+ <%= submit_tag("Join") %>
+ <% end %>
+ <% when 1 %>
+ Ongoing
+ <% else %>
+ Closed
+ <%end %>
+ </td>
+ <td><%= tournament.min_players_per_team %>
+ <% if tournament.min_players_per_team != tournament.max_players_per_team %>
+ to <%= tournament.max_players_per_team %>
+ <% end %>
+ </td>
+ <td><%= tournament.min_teams_per_match %>
+ <% if tournament.min_teams_per_match != tournament.max_teams_per_match %>
+ to <%= tournament.max_teams_per_match %>
+ <% end %>
+ </td>
<td><%= tournament.randomized_teams %></td>
<td><%= link_to 'Show', tournament %></td>
<td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>
@@ -37,7 +50,9 @@
<% end %>
</tbody>
</table>
-
+<% else %>
+ <p class="no-entries"> No tournaments going on right now... Why not start your own? </p>
+<% end %>
<br>
-<%= link_to 'New Tournament', new_tournament_path %>
+<%= link_to 'New Tournament', new_tournament_path, :class => "btn btn-warning btn-lg" %>
diff --git a/app/views/tournaments/join.html.erb b/app/views/tournaments/join.html.erb
new file mode 100644
index 0000000..1d38d68
--- /dev/null
+++ b/app/views/tournaments/join.html.erb
@@ -0,0 +1,2 @@
+ <%= @user.name %>
+
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index 2a60539..8c74068 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,5 +1,16 @@
-<h1>New tournament</h1>
+<h1>New Tournament</h1>
-<%= render 'form' %>
+<%= form_tag(new_tournament_path, method: "get") do %>
+ <%= select_tag('game',
+ options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id),
+ :prompt => "Select a Game Type") %>
+ <%= submit_tag("Select", :class => "btn btn-success btn-xs") %>
+<% end %>
+
+<div id='ajax-form'>
+ <% if not @tournament.game.nil? %>
+ <%= render 'selected' %>
+ <% end %>
+</div>
<%= link_to 'Back', tournaments_path %>
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 3cb6179..3de0623 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -1,5 +1,19 @@
-<p id="notice"><%= notice %></p>
+<% 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>
+
+<% if current_user.in_group?(:host) %>
<p>
<strong>Name:</strong>
<%= @tournament.name %>
@@ -7,7 +21,7 @@
<p>
<strong>Game:</strong>
- <%= @tournament.game %>
+ <%= @tournament.id %>
</p>
<p>
@@ -45,5 +59,22 @@
<%= @tournament.randomized_teams %>
</p>
+<p>
+ <strong>Status:</strong>
+ <%= @tournament.status %>
+</p>
+
+<%= 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) %>
+ <% end %>
+<% end %>
+
<%= link_to 'Edit', edit_tournament_path(@tournament) %> |
<%= link_to 'Back', tournaments_path %>
+
+<% end %>
+