diff options
Diffstat (limited to 'app/views/tournaments')
-rw-r--r-- | app/views/tournaments/_selected.html.erb | 31 | ||||
-rw-r--r-- | app/views/tournaments/index.html.erb | 11 | ||||
-rw-r--r-- | app/views/tournaments/new.html.erb | 18 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 2 |
4 files changed, 54 insertions, 8 deletions
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb new file mode 100644 index 0000000..5058c56 --- /dev/null +++ b/app/views/tournaments/_selected.html.erb @@ -0,0 +1,31 @@ +<%= form_for(@tournament) do |f| %> + <% if @tournament.errors.any? %> + <div id="error_explanation"> + <h2><%= pluralize(@tournament.errors.count, "error") %> prohibited this tournament from being saved:</h2> + + <ul> + <% @tournament.errors.full_messages.each do |msg| %> + <li><%= msg %></li> + <% end %> + </ul> + </div> + <% end %> + + <%# this is the dynamic script to output fields to the form %> + <% @chosen = Game.find(@game) %> + <% @chosen.attributes.each do |name, value| %> + <% if name == "id" %> + <% next %> + <% end %> + <% if name == "created_at" %> + <% break %> + <% end %> + <p> + <label for=<%= name %>><%= name.capitalize.gsub('_', ' ') %></label> + <br /> + <input type="text" id=<%= name %> value=<%= value %>> + </p> + <% end %> + + <%= f.submit %> +<% end %> diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb index dec16d1..80d68a3 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -1,6 +1,7 @@ -<h1>Listing tournaments</h1> +<h1>Listing Tournaments</h1> -<table> +<% if @tournaments.length > 0 %> +<table class="table table-hover"> <thead> <tr> <th>Game</th> @@ -35,7 +36,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/new.html.erb b/app/views/tournaments/new.html.erb index 2a60539..3d6d142 100644 --- a/app/views/tournaments/new.html.erb +++ b/app/views/tournaments/new.html.erb @@ -1,5 +1,19 @@ -<h1>New tournament</h1> +<%= javascript_include_tag :defaults %> -<%= render 'form' %> +<h1>New Tournament</h1> + +<%= select_tag 'tournament_id', options_for_select(["Select a Game Type"] + Game.all.collect {|game| game.name}), :onchange => 'populate()' %> <%= link_to 'Select', 'new?game=1', :class => "btn btn-success btn-xs" %> + + + +<br /> +<div id='ajax-form'> + <% if not @game.nil? %> + <%= render 'selected' %> + <% end %> +</div> +<br /><br /> + +<%= link_to 'Select', 'selected', :class => "btn btn-success btn-xs" %> <%= link_to 'Back', tournaments_path %> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 355bc90..4f97c7c 100644 --- a/app/views/tournaments/show.html.erb +++ b/app/views/tournaments/show.html.erb @@ -1,5 +1,3 @@ -<p id="notice"><%= notice %></p> - <p> <strong>Game:</strong> <%= @tournament.game %> |