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 | 12 | ||||
-rw-r--r-- | app/views/tournaments/new.html.erb | 18 | ||||
-rw-r--r-- | app/views/tournaments/show.html.erb | 2 |
4 files changed, 53 insertions, 10 deletions
diff --git a/app/views/tournaments/_selected.html.erb b/app/views/tournaments/_selected.html.erb new file mode 100644 index 0000000..4277d8e --- /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 ad2b7cf..26d0643 100644 --- a/app/views/tournaments/index.html.erb +++ b/app/views/tournaments/index.html.erb @@ -3,17 +3,17 @@ <table> <thead> <tr> - <th>Game</th> - <th></th> - <th></th> - <th></th> + <th>Tournament ID</th> + <th>Show Tournament</th> + <th>Edit Tournament</th> + <th>Delete Tournament</th> </tr> </thead> <tbody> <% @tournaments.each do |tournament| %> <tr> - <td><%= tournament.game %></td> + <td><%= tournament.id %></td> <td><%= link_to 'Show', tournament %></td> <td><%= link_to 'Edit', edit_tournament_path(tournament) %></td> <td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td> @@ -24,4 +24,4 @@ <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..428487a 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-warning btn-lg" %> + + + +<br /> +<div id='ajax-form'> + <% if not @game.nil? %> + <%= render 'selected' %> + <% end %> +</div> +<br /><br /> + +<%= link_to 'Select', 'selected', :class => "btn btn-warning btn-lg" %> <%= link_to 'Back', tournaments_path %> diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb index 30df788..0d9dd10 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 %> |