diff options
author | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-25 17:30:10 -0400 |
---|---|---|
committer | guntasgrewal <guntasgrewal@gmail.com> | 2014-03-25 17:30:10 -0400 |
commit | 0c22c4bd9a0b4a0b0ff5840c1af41c0b320e3529 (patch) | |
tree | 2fc2082814e513ec5d68b22e7fa07d268df6d788 /app/views/matches | |
parent | 8435c0a5ec9889a9da6ede2e24c044d64b279095 (diff) |
added match status
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, 47 insertions, 30 deletions
diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index 015aed0..727c002 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,5 +1,20 @@ -<%= form_for([@tournament, @tournament.matches.build]) do |f| %> - +<%= 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> <div class="field"> <%= f.label :tournament_id %><br> <%= f.text_field :tournament_id %> @@ -8,6 +23,10 @@ <%= 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 60df1b5..400efb4 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -3,6 +3,7 @@ <table> <thead> <tr> + <th>Status</th> <th>Tournament</th> <th>Name</th> <th>Winner</th> @@ -13,14 +14,15 @@ </thead> <tbody> - <% @tournament.matches.each do |match| %> + <% @matches.each do |match| %> <tr> - <td><%= match.tournament.id %></td> + <td><%= match.status %></td> + <td><%= match.tournament %></td> <td><%= match.name %></td> <td><%= match.winner %></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> + <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> </tr> <% end %> </tbody> @@ -28,4 +30,4 @@ <br> -<%= link_to 'New Match', new_tournament_match_path %> +<%= link_to 'New Match', new_match_path %> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 0b2bfcd..1a63f5f 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, :tournament_id, :name, :winner_id + json.extract! match, :id, :status, :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 74e7e3a..bd4c78c 100644 --- a/app/views/matches/new.html.erb +++ b/app/views/matches/new.html.erb @@ -1,3 +1,5 @@ <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 b6930ea..f3fc822 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -1,6 +1,13 @@ +<p id="notice"><%= notice %></p> + +<p> + <strong>Status:</strong> + <%= @match.status %> +</p> + <p> <strong>Tournament:</strong> - <%= @match.tournament.id %> + <%= @match.tournament %> </p> <p> @@ -8,23 +15,10 @@ <%= @match.name %> </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 %> +<p> + <strong>Winner:</strong> + <%= @match.winner %> +</p> -<%= link_to 'Back', tournament_matches_path %> +<%= link_to 'Edit', edit_match_path(@match) %> | +<%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index fe14010..a3ef588 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at +json.extract! @match, :id, :status, :tournament_id, :name, :winner_id, :created_at, :updated_at |