From 3992a2e52a950c644cfe56bc23991e3a03166568 Mon Sep 17 00:00:00 2001 From: tkimia Date: Mon, 28 Apr 2014 20:03:29 -0400 Subject: prediction view now done. used Jquery --- app/models/bracket.rb | 2 +- app/views/brackets/show.html.erb | 77 ++++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/app/models/bracket.rb b/app/models/bracket.rb index 7e22f0d..acd33ca 100644 --- a/app/models/bracket.rb +++ b/app/models/bracket.rb @@ -4,7 +4,7 @@ class Bracket < ActiveRecord::Base has_many :bracket_matches def create_matches - tournament.stages.first.matches_ordered.each do |m| + tournament.stages.first.matches.each do |m| bracket_matches.create(match: m) end end diff --git a/app/views/brackets/show.html.erb b/app/views/brackets/show.html.erb index 75446f5..64e6e6a 100644 --- a/app/views/brackets/show.html.erb +++ b/app/views/brackets/show.html.erb @@ -2,14 +2,11 @@

Make your prediction for the tournament by clicking on the teams you think will win

-<% @bracket.bracket_matches.each do |m| %> -

<%= m.match.id %>

-<% end %> -> + width="100%" height=<%= "#{@height * 0.66}"%>> @@ -17,8 +14,39 @@ @@ -36,34 +64,23 @@ y="<%= ry = 100/(@logBase**(matchDepth-1)+1) * (i-@base+1) - rh/2 %>%" fill="url(#gradMatch)" rx="5px" - stroke-width="2" - <% case @matches[i].status %> - <% when 0 %> - <% if @matches[i].teams.count < @tournament.min_teams_per_match %> - stroke="red" - fill-opacity="0.6" - <% else %> - stroke="green" - <% end %> - <% when 1 %> - stroke="orange" - <% when 2 %> - stroke="yellow" - <% when 3 %> - stroke="grey" - <% end %> + stroke="black" /> <% t = 1 while t <= @numTeams %> - " onclick="chooseWinner(<%= @matches[i].id, %>)" /> - + + + onclick="chooseWinner(<%= @matches[i].id%>, <%= @matches[i].teams[t-1].id %>)" + <% end %> + > <% if @matches[i].teams[t-1] %> Team <%= @matches[i].teams[t-1].id %> <% end %> <% if (t < @numTeams) %> - VS + VS <% end %> <% t = t + 1 %> <% end %> @@ -80,4 +97,12 @@ <% end %> +<%= form_tag(tournament_bracket_path(@tournament, @bracket), method: 'put') do %> + + <% for i in 1..@matches.length %> + <%= hidden_field_tag('match-'+@matches[i].id.to_s+'-pred', value = nil) %> + <% end %> + <%= submit_tag("Sumit Prediction", disabled: true, id: "bracket-submit") %> +<% end %> + <%= link_to 'Back', tournaments_path %> -- cgit v1.2.3