From 6c615c4eaa973d83778fc6d34157f823880765f1 Mon Sep 17 00:00:00 2001
From: Luke Shumaker
Date: Sun, 27 Apr 2014 02:46:11 -0400
Subject: Work on the tournament creation page
---
app/views/tournaments/_form.html.erb | 161 +++++++++++++++++++------------
app/views/tournaments/_selected.html.erb | 23 -----
app/views/tournaments/_stages.html.erb | 36 -------
app/views/tournaments/new.html.erb | 19 +---
4 files changed, 102 insertions(+), 137 deletions(-)
delete mode 100644 app/views/tournaments/_selected.html.erb
delete mode 100644 app/views/tournaments/_stages.html.erb
(limited to 'app/views')
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 7127d38..78ceca4 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -1,61 +1,102 @@
-<%= form_for(@tournament) do |f| %>
- <% if @tournament.errors.any? %>
-
-
<%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:
-
-
- <% @tournament.errors.full_messages.each do |msg| %>
- - <%= msg %>
- <% end %>
-
-
- <% end %>
-
-
- <%= f.label :game_id %>
- <%= f.text_field :game_id %>
-
-
- <%= f.label :status %>
- <%= f.number_field :status %>
-
-
- <%= f.label :name %>
- <%= f.text_field :name %>
-
-
- <%= f.label :min_players_per_team %>
- <%= f.number_field :min_players_per_team %>
-
-
- <%= f.label :max_players_per_team %>
- <%= f.number_field :max_players_per_team %>
-
-
- <%= f.label :min_teams_per_match %>
- <%= f.number_field :min_teams_per_match %>
-
-
- <%= f.label :max_teams_per_match %>
- <%= f.number_field :max_teams_per_match %>
-
-
- <%= f.label :set_rounds %>
- <%= f.number_field :set_rounds %>
-
-
- <%= f.label :randomized_teams %>
- <%= f.check_box :randomized_teams %>
-
-
- <%= f.label :sampling_method %>
- <%= f.text_field :sampling_method %>
-
-
- <%= f.label :scoring_method %>
- <%= f.text_field :scoring_method %>
-
-
- <%= f.submit %>
-
+<%= form_for(@tournament,
+ url: (@tournament.game.nil? ? new_tournament_path : tournaments_path),
+ method: (@tournament.game.nil? ? "get" : "post")) do |f| %>
+ <%= render "common/error_messages", :target => @tournament %>
+
+
+ <% else %>
+
+
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+
+
+
+
+ |
+ Minimum |
+ Maximum |
+
+ Players per team |
+ <%= f.text_field(:min_players_per_team, type: :number, min: 1) %> |
+ <%= f.text_field(:max_players_per_team, type: :number, min: 1) %> |
+
+
+ Teams per match |
+ <%= f.text_field(:min_teams_per_match, type: :number, min: 1) %> |
+ <%= f.text_field(:max_teams_per_match, type: :number, min: 1) %> |
+
+
+
+
+ <%= f.label :scoring_method %>
+ <%= f.select(:scoring_method, @tournament.scoring_methods.map{|method| [method.humanize, method]}) %>
+
+
+
+ <%= f.label :sampling_method %>
+ <%= f.select(:sampling_method, @tournament.sampling_methods.map{|method| [method.humanize, method]}) %>
+
+
+
+
+
<% end %>
+ <% end %>
+
+
+
+ <%= f.submit %>
+
+ <%# render 'stages' %>
+ <% end %>
<% end %>
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb
deleted file mode 100644
index e89550e..0000000
--- a/app/views/tournaments/_selected.html.erb
+++ /dev/null
@@ -1,23 +0,0 @@
-<%= form_for(@tournament) do |f| %>
- <%= render "common/error_messages", :target => @tournament %>
- <%= f.hidden_field(:game_id) %>
-
- <% @tournament.attributes.each do |name, value| %>
- <% if (name == "randomized_teams") or(name == "max_teams_per_match") or (name == "max_players_per_team") or (name == "id") or (name =~ /.*_at$/) or (name == "game_id") or (name == "status") or (name == "set_rounds") %>
- <% next %>
- <% end %>
-
- <%= f.label name %>
- <% unless @tournament.game.attributes[name].nil? %>
- <% if name == "sampling_method" %>
- <%= f.select( name, Tournament.sampling_methods) %>
- <% else %>
- <%= f.text_field(name, :value => @tournament.game.attributes[name] ) %>
- <% end %>
- <% else %>
- <%= f.select( name, Tournament.scoring_methods) %>
- <% end %>
-
- <% end %>
- <%= f.submit %>
-<% end %>
diff --git a/app/views/tournaments/_stages.html.erb b/app/views/tournaments/_stages.html.erb
deleted file mode 100644
index 20c7b3f..0000000
--- a/app/views/tournaments/_stages.html.erb
+++ /dev/null
@@ -1,36 +0,0 @@
- <%= form_for(@tournament) do |f| %>
- <%= render "common/error_messages", :target => @tournament %>
- <%= f.hidden_field(:game_id) %>
- <%= fields_for "tournament[settings]", @tournament.settings do |setting_fields| %>
-
- <% @tournament.game.settings.each do |setting| %>
-
- <%= setting_fields.label setting.name %>
-
- <% case setting.vartype %>
- <% when 0 %>
- <%= setting_fields.text_field( setting.name ) %>
- <% when 1 %>
- <%= setting_fields.text_area( setting.name ) %>
- <% when 2 %>
- <% setting.type_opt.split(',').each do |option|%>
- <%= setting_fields.radio_button( setting.name, option ) %> <%= option %>
- <% end %>
- <% when 3 %>
- <% setting.type_opt.split(',').each do |option|%>
- <%= check_box_tag(setting.name, value = option, checked = false, options = {}) %> <%= option %>
- <% end %>
- <% when 4 %>
- <%# setting_fields.label "true" %>
- <%= setting_fields.radio_button( setting.name, "true" ) %> True
- <%# setting_fields.label "false" %>
- <%= setting_fields.radio_button( setting.name, "false" ) %> False
- <% when 5 %>
- <%= setting_fields.select( setting.name, setting.type_opt.split(',') ) %>
- <% end %>
- <% end %>
-
- <% end %>
-
- <%= f.submit %>
-<% end %>
diff --git a/app/views/tournaments/new.html.erb b/app/views/tournaments/new.html.erb
index af74ea8..9c741e0 100644
--- a/app/views/tournaments/new.html.erb
+++ b/app/views/tournaments/new.html.erb
@@ -1,22 +1,5 @@
New Tournament
-<%= form_tag(new_tournament_path, method: "get") do %>
- <%= select_tag('tournament[game_id]',
- options_from_collection_for_select(@games, 'id', 'name', @tournament.game.nil? || @tournament.game.id),
- :prompt => "Select a Game Type") %>
- <%= submit_tag("Select", :class => "btn") %>
-<% end %>
-
-
- <% if not @tournament.game.nil? %>
- <%= render 'selected' %>
- <% end %>
-
-
-
- <% if not @tournament.game.nil? %>
- <%= render 'stages' %>
- <% end %>
-
+<%= render 'form' %>
<%= link_to 'Back', tournaments_path %>
--
cgit v1.2.3-54-g00ecf