summaryrefslogtreecommitdiff
path: root/app/views/tournaments
diff options
context:
space:
mode:
Diffstat (limited to 'app/views/tournaments')
-rw-r--r--app/views/tournaments/_form.html.erb89
-rw-r--r--app/views/tournaments/standings.html.erb20
2 files changed, 68 insertions, 41 deletions
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index cb4c175..e322601 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -3,11 +3,11 @@
method: (@tournament.game.nil? ? "get" : "post")) do |f| %>
<%= render "common/error_messages", :target => @tournament %>
- <fieldset><legend>Attributes</legend>
+ <fieldset><legend style="color:rgb(221, 145, 37)">Attributes</legend>
<p>
<%= f.label :game_id, "Select a game type" %>
<%= f.select(:game_id, Game.all.map{|game| [game.name, game.id]}) %>
- <%= submit_tag("Select", :class => "btn") %>
+ <%= f.submit("Select") %>
</p>
<% if @tournament.game.nil? %>
@@ -18,23 +18,33 @@
<%= f.label :name %>
<%= f.text_field :name %>
</p>
-
- <table><tbody>
- <tr>
- <td></td>
- <th>Minimum</th>
- <th>Maximum</th></tr>
- <tr>
- <th>Players per team</th>
- <td><%= f.text_field(:min_players_per_team, type: :number, min: 1) %></td>
- <td><%= f.text_field(:max_players_per_team, type: :number, min: 1) %></td>
- </tr>
- <tr>
- <th>Teams per match</th>
- <td><%= f.text_field(:min_teams_per_match, type: :number, min: 1) %></td>
- <td><%= f.text_field(:max_teams_per_match, type: :number, min: 1) %></td>
- </tr>
- </tbody></table>
+ <div>
+ <p>
+ <table><tbody>
+ <tr>
+ <td></td>
+ <th style="padding:5px">Minimum</th>
+ <th style="padding:5px">Maximum</th></tr>
+ <tr>
+ <th>Players per team: </th>
+ <td style="padding:5px"><%= f.text_field(:min_players_per_team, type: :number, min: 1) %></td>
+ <td style="padding:5px"><%= f.text_field(:max_players_per_team, type: :number, min: 1) %></td>
+ </tr>
+ </tbody></table>
+ </p>
+ </div>
+
+ <div id="teams-table">
+ <p>
+ <table><tbody>
+ <tr>
+ <th>Teams per match: </th>
+ <td style="padding:5px"><%= f.text_field(:min_teams_per_match, type: :number, min: 1) %></td>
+ <td style="padding:5px"><%= f.text_field(:max_teams_per_match, type: :number, min: 1) %></td>
+ </tr>
+ </tbody></table>
+ </P>
+ </div>
<p>
<%= f.label :scoring_method %>
@@ -48,50 +58,51 @@
</fieldset>
- <fieldset><legend>Settings</legend>
+ <fieldset><legend style="color:rgb(221, 145, 37)">Settings</legend>
<%= f.fields_for :settings do |setting_fields| %>
- <% (@tournament.settings.empty? ? @tournament.game.settings : @tournament.settings).each do |setting| %><p>
- <% name = setting.name.parameterize.underscore %>
- <%= setting_fields.label name %>
+ <% @tournament.tournament_settings.each do |setting| %><p>
+ <%= setting_fields.label setting.name %>
<br>
<% case setting.vartype %>
<% when 0 %>
- <%= setting_fields.text_field( name ) %>
+ <%= setting_fields.text_field( setting.name ) %>
<% when 1 %>
- <%= setting_fields.text_area( name ) %>
+ <%= setting_fields.text_area( setting.name ) %>
<% when 2 %>
<ul>
<% setting.type_opt.split(',').each do |option|%>
- <li><label><%= setting_fields.radio_button( name, option ) %><%= option %></label></li>
+ <li><label><%= setting_fields.radio_button( setting.name, option ) %><%= option.humanize %></label></li>
<% end %>
</ul>
<% when 3 %>
<ul>
<% setting.type_opt.split(',').each do |option|%>
- <li><label><%= check_box_tag(name, value = option, checked = false, options = {}) %><%= option %></label></li>
+ <li><label><%= check_box_tag("tournament[settings][#{setting.name}][]", option, setting.value.split(',').include?(option)) %><%= option.humanize %></label></li>
<% end %>
</ul>
<% when 4 %>
- <%= setting_fields.radio_button( name, "true" ) %> True
- <%= setting_fields.radio_button( name, "false" ) %> False
+ <%= setting_fields.radio_button( setting.name, "true" ) %> True
+ <%= setting_fields.radio_button( setting.name, "false" ) %> False
<% when 5 %>
- <%= setting_fields.select( name, setting.type_opt.split(',') ) %>
+ <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %>
<% end %>
</p><% end %>
<% end %>
</fieldset>
- <%= f.fields_for :stages do |stages_fields| %><fieldset><legend>Stages</legend>
+ <%= f.fields_for :stages do |stages_fields| %><fieldset><legend style="color:rgb(221, 145, 37)">Stages</legend>
<label for="num_stages">Number of tournament stages</label>
- <input type="number" name="num_stages" min="1" value="<%= params[:num_stages] ? params[:num_stages].to_i : 1 %>">
- <%# submit_tag("Set Stages", :class => "btn") %>
+ <input type="number" name="num_stages" min="1" value="<%= params[:num_stages].to_i %>">
+ <%# stage_fields.submit("Set Stages") %>
<% for i in 1..(params[:num_stages].to_i) do %>
- <%= stages_fields.fields_for i.to_s do |stage_fields| %><fieldset><legend>Stage <%= i %></legend>
- <%= stage_fields.label :scheduling_method %>
- <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %>
- <%= stage_fields.label :seeding_method %>
- <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %>
- </fieldset><% end %>
+ <p>
+ <%= stages_fields.fields_for i.to_s do |stage_fields| %><fieldset><legend style="color:rgb(221, 145, 37)">Stage <%= i %></legend>
+ <%= stage_fields.label :scheduling_method %>
+ <%= stage_fields.select(:scheduling_method, @tournament.scheduling_methods.map{|method| [method.humanize, method]}) %>
+ <%= stage_fields.label :seeding_method %>
+ <%= stage_fields.select(:seeding_method, @tournament.seeding_methods.map{|method| [method.humanize, method]}) %>
+ </fieldset><% end %>
+ </p>
<% end %>
</fieldset><% end %>
diff --git a/app/views/tournaments/standings.html.erb b/app/views/tournaments/standings.html.erb
index 28d3c22..b8739de 100644
--- a/app/views/tournaments/standings.html.erb
+++ b/app/views/tournaments/standings.html.erb
@@ -1,4 +1,7 @@
-<% playerscores = @tournament.players.collect {|player| player => tournament.statistics.getStatistic(player.matches.last, player, :score) } %>
+<% playerscores = @tournament.players.collect {|player| player => @tournament.statistics.getStatistic(player.matches.last, player, :score) } %>
+<% teams = tournament_stage.matches.collect
+{ |match| match.teams.collect { |team| team.id => team.players.collect
+{ |player| player.user_name => @tournament.statistics.getStatistic(player.matches.last, player, :score } } } %>
<table>
<tr>
@@ -9,4 +12,17 @@
<% place += 1%>
<% end %>
</tr>
-</table> \ No newline at end of file
+</table>
+
+<% teams.each do |team| %>
+ <table>
+ <tr>
+ <td>Standings:</td>
+ <% place = 0 %>
+ <% team.values.sort {|player1, player2| playerscores[player1] <=> playerscores[player2] }.each |player| %>
+ <td><%= place.to_s + ":" %> <%= player.user_name %></td>
+ <% place += 1%>
+ <% end %>
+ </tr>
+ </table>
+<% end %> \ No newline at end of file