diff options
Diffstat (limited to 'app/views/matches')
-rw-r--r-- | app/views/matches/_form.html.erb | 23 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 14 | ||||
-rw-r--r-- | app/views/matches/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/matches/new.html.erb | 2 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 34 | ||||
-rw-r--r-- | app/views/matches/show.json.jbuilder | 2 |
6 files changed, 30 insertions, 47 deletions
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 727c002..015aed0 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,20 +1,5 @@ -<%= form_for(@match) do |f| %> - <% if @match.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2> - - <ul> - <% @match.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - - <div class="field"> - <%= f.label :status %><br> - <%= f.number_field :status %> - </div> +<%= form_for([@tournament, @tournament.matches.build]) do |f| %> + <div class="field"> <%= f.label :tournament_id %><br> <%= f.text_field :tournament_id %> @@ -23,10 +8,6 @@ <%= f.label :name %><br> <%= f.text_field :name %> </div> - <div class="field"> - <%= f.label :winner_id %><br> - <%= f.text_field :winner_id %> - </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 400efb4..60df1b5 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -3,7 +3,6 @@ <table> <thead> <tr> - <th>Status</th> <th>Tournament</th> <th>Name</th> <th>Winner</th> @@ -14,15 +13,14 @@ </thead> <tbody> - <% @matches.each do |match| %> + <% @tournament.matches.each do |match| %> <tr> - <td><%= match.status %></td> - <td><%= match.tournament %></td> + <td><%= match.tournament.id %></td> <td><%= match.name %></td> <td><%= match.winner %></td> - <td><%= link_to 'Show', match %></td> - <td><%= link_to 'Edit', edit_match_path(match) %></td> - <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td> + <td><%= link_to 'Show', tournament_match_path(@tournament, match) %></td> + <td><%= link_to 'Edit', edit_tournament_match_path(@tournament, match) %></td> + <td><%= link_to 'Destroy', tournament_match_path(@tournament, match), method: :delete, data: { confirm: 'Are you sure?' } %></td> </tr> <% end %> </tbody> @@ -30,4 +28,4 @@ <br> -<%= link_to 'New Match', new_match_path %> +<%= link_to 'New Match', new_tournament_match_path %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 1a63f5f..0b2bfcd 100644 --- a/app/views/matches/index.json.jbuilder +++ b/app/views/matches/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@matches) do |match| - json.extract! match, :id, :status, :tournament_id, :name, :winner_id + json.extract! match, :id, :tournament_id, :name, :winner_id json.url match_url(match, format: :json) end diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb index bd4c78c..74e7e3a 100644 --- a/app/views/matches/new.html.erb +++ b/app/views/matches/new.html.erb @@ -1,5 +1,3 @@ <h1>New match</h1> <%= render 'form' %> - -<%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index f3fc822..b6930ea 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,13 +1,6 @@ -<p id="notice"><%= notice %></p> - -<p> - <strong>Status:</strong> - <%= @match.status %> -</p> - <p> <strong>Tournament:</strong> - <%= @match.tournament %> + <%= @match.tournament.id %> </p> <p> @@ -15,10 +8,23 @@ <%= @match.name %> </p> -<p> - <strong>Winner:</strong> - <%= @match.winner %> -</p> +<% if (@tournament.hosts.include?(current_user) and @match.winner.nil?) %> + <%= form_for([@tournament, @match], method: "put") do |f| %> + <ul> + <% @match.teams.each do |team| %> + <li><label><%= f.radio_button(:winner, team.id) %> + <%= team.users.collect{|u| u.user_name}.join(", ") %></label></li> + <% end %> + </ul> + <%= f.submit("Select winner") %> + <% end %> +<% end %> + +<% unless @match.winner.nil? %> + <p> + <strong>Winner:</strong> + <%= @match.winner.users.collect{|u| u.user_name}.join(", ") %> + </p> +<% end %> -<%= link_to 'Edit', edit_match_path(@match) %> | -<%= link_to 'Back', matches_path %> +<%= link_to 'Back', tournament_matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index a3ef588..fe14010 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at |