Permalink
Browse files

use partial helpers for reuse cont.

  • Loading branch information...
1 parent 126bb1f commit 41519b2100e0965a64abfbd4508489b0dcac9e86 @geraldb geraldb committed Oct 2, 2012
View
@@ -8,6 +8,29 @@ module PartHelper
# by convention all start w/ render_
+ def render_event_quotes( event, opts={} )
+ render :partial => 'shared/table_event_quotes', :locals => { :event => event }
+ end
+
+
+ def render_play_teams( play, opts={} )
+ render :partial => 'shared/table_play_teams',
+ :locals => { :play => play,
+ :pool => play.pool
+ }
+ end
+
+ def render_play_teams_for_form( play, form, opts={} )
+
+ render :partial => 'shared/table_play_teams_input',
+ :locals => { :play => play,
+ :f => form,
+ :event => play.pool.event,
+ :pool => play.pool
+ }
+ end
+
+
def render_game_date( game, opts={} )
render :partial => 'shared/td_game_date', :locals => { :game => game }
end
@@ -23,6 +46,10 @@ def render_game_team1( game, opts={} )
def render_game_team2( game, opts={} )
render :partial => 'shared/td_game_team2', :locals => { :game => game }
end
+
+ def render_game_quotes( game, opts={} )
+ render :partial => 'shared/table_game_quotes', :locals => { :game => game }
+ end
@@ -34,25 +34,7 @@
<td>
-<% if show_odds && game.quotes.count > 0 %>
- <table class='odds'>
- <tr>
- <td class='center'>1</td>
- <td class='center'>X</td>
- <td class='center'>2</td>
- <td></td>
- </tr>
-<% game.quotes.each do |quote| %>
-<tr>
- <td><%= fmt_quote( quote.odds1 ) %></td>
- <td><%= fmt_quote( quote.oddsx ) %></td>
- <td><%= fmt_quote( quote.odds2 ) %></td>
- <td>(<%= quote.service.title %>)</td>
- <!-- add last updated? -->
-</tr>
-<% end %><!-- each quote -->
- </table>
-<% end %><!-- show odds? -->
+ <%= render_game_quotes( game ) if show_odds %>
</td>
@@ -116,6 +116,14 @@
<%= form_for @play, :url => play_path( @play ), :html => { :method => 'put' } do |f| %>
+
+<!-- todo/fix:
+
+ break into two partials
+ - _edit_flex.html.erb
+ - _edit_fix.html.erb
+ -->
+
<% if @pool.locked? %>
<% if @pool.flex? %>
<p class='flash notice'><b>Hinweis.</b> Team Abgabefrist abgelaufen. Team Bonustipps gesperrt.</p>
@@ -125,54 +133,15 @@
<%= f.hidden_field :team1_id %>
<%= f.hidden_field :team2_id %>
-<table>
- <tr>
- <td>1. Platz</td>
- <!-- fix: use helper or partial -->
- <% if @play.team1.present? %>
- <td>
- <%= image_tag( @play.team1.img ) if @play.team1.img.present? %>
- <%= @play.team1.title %>
- </td>
- <% else %>
- <td style='text-align: center;'>
- <span class='missing'>?</span>
- </td>
- <% end %>
- </tr>
- <tr>
- <td>2. Platz</td>
- <% if @play.team2.present? %>
- <td>
- <%= image_tag( @play.team2.img ) if @play.team2.img.present? %>
- <%= @play.team2.title %>
- </td>
- <% else %>
- <td style='text-align: center;'>
- <span class='missing'>?</span>
- </td>
- <% end %>
- </tr>
-</table>
+
+ <%= render_play_teams( @play ) %>
+
+
<% else %><!-- pool.locked? clause -->
<% if @pool.flex? %>
<!-- NB: only needed for flex - in fixed winner gets calculated automatically -->
-<table>
- <tr>
- <td><%= f.label :team1_id, '1. Platz' %></td>
- <td><%= f.select :team1_id, Lookup.team_options_for_event( @pool.event ) %></td>
- </tr>
- <tr>
- <td><%= f.label :team2_id, '2. Platz' %></td>
- <td><%= f.select :team2_id, Lookup.team_options_for_event( @pool.event ) %></td>
- </tr>
- <% if @pool.team3? %>
- <tr>
- <td><%= f.label :team3_id, '3. Platz' %></td>
- <td><%= f.select :team3_id, Lookup.team_options_for_event( @pool.event ) %></td>
- </tr>
- <% end %><!-- if pool.team3? -->
-</table>
+
+ <%= render_play_teams_for_form( @play, f ) %>
<% else %><!-- pool fix clause -->
<%= f.hidden_field :team1_id %>
@@ -182,21 +151,7 @@
-<% if @show_odds %>
-<table class='odds'>
- <tr>
-<% Service.all.each do |srv| %>
- <td>
- <%= srv.title %><br>
- <% srv.event_quotes.where( :event_id => @pool.event.id ).each do |quote| %>
- <%= quote.team.tag %> <%= fmt_quote( quote.odds ) %><br>
- <% end %><!-- each qoute -->
- </td>
-<% end %><!-- each service -->
-</tr>
-</table>
-<% end %><!-- show odds? -->
-
+ <%= render_event_quotes( @pool.event ) if @show_odds %>
@@ -151,7 +151,7 @@
<% end %>
</td>
- <%= render :partial => 'shared/td_game_team1', :locals => { :game => game } %>
+ <%= render_game_team1( game ) %>
<% @users.each do |user| %>
<% tip = Tip.find_by_user_and_pool_and_game( user, @pool, game ) %>
@@ -186,9 +186,9 @@
<% end %><!-- users.each -->
- <%= render :partial => 'shared/td_game_score', :locals => { :game => game } %>
- <%= render :partial => 'shared/td_game_team2', :locals => { :game => game } %>
- <%= render :partial => 'shared/td_game_date', :locals => { :game => game } %>
+ <%= render_game_score( game ) %>
+ <%= render_game_team2( game ) %>
+ <%= render_game_date( game ) %>
</tr>
<% end %> <!-- games.each -->
<% end %> <!-- if pool.flex? && round.calc? -->
@@ -22,62 +22,8 @@
</table>
-<table>
- <tr>
- <td>1. Platz</td>
- <!-- fix: use helper or partial -->
- <% if @play.team1.present? %>
- <td>
- <% if @play.public? %>
- <%= image_tag( @play.team1.img ) if @play.team1.img.present? %>
- <%= @play.team1.title %>
- <% else %>
- Team Anonym
- <% end %>
- </td>
- <% else %>
- <td style='text-align: center;'>
- <span class='missing'>?</span>
- </td>
- <% end %>
- </tr>
- <tr>
- <td>2. Platz</td>
- <% if @play.team2.present? %>
- <td>
- <% if @play.public? %>
- <%= image_tag( @play.team2.img ) if @play.team2.img.present? %>
- <%= @play.team2.title %>
- <% else %>
- Team Anonym
- <% end %>
- </td>
- <% else %>
- <td style='text-align: center;'>
- <span class='missing'>?</span>
- </td>
- <% end %>
- </tr>
- <% if @pool.team3? %>
- <tr>
- <td>3. Platz</td>
- <% if @play.team3.present? %>
- <td>
- <% if @play.public? %>
- <%= image_tag( @play.team3.img ) if @play.team3.img.present? %>
- <%= @play.team3.title %>
- <% else %>
- Team Anonym
- <% end %>
- </td>
- <% else %>
- <td style='text-align: center;'>
- <span class='missing'>?</span>
- </td>
- <% end %>
- </tr>
-<% end %>
-</table>
+ <%= render_play_teams( @play ) %>
+
<!-- table columns:
@@ -111,13 +57,13 @@
%>
<tr>
- <%= render :partial => 'shared/td_tip_toto12x', :locals => { :tip => tip } %>
- <%= render :partial => 'shared/td_tip_bingo', :locals => { :tip => tip } %>
- <%= render :partial => 'shared/td_game_team1', :locals => { :game => game } %>
- <%= render :partial => 'shared/td_tip_score', :locals => { :tip => tip } %>
- <%= render :partial => 'shared/td_game_score', :locals => { :game => game } %>
- <%= render :partial => 'shared/td_game_team2', :locals => { :game => game } %>
- <%= render :partial => 'shared/td_game_date', :locals => { :game => game } %>
+ <%= render_tip_toto12x( tip ) %>
+ <%= render_tip_bingo( tip ) %>
+ <%= render_game_team1( game ) %>
+ <%= render_tip_score( tip ) %>
+ <%= render_game_score( game ) %>
+ <%= render_game_team2( game ) %>
+ <%= render_game_date( game ) %>
</tr>
<% end %> <!-- games -->
@@ -59,7 +59,11 @@
<%= link_to t(:edit), edit_pool_player_path( tip.pool_id, tip.user.id), :class => 'btn' %>
</td>
<% end %><!-- each tip -->
- </td>
+
+ <td>
+ <%= render_game_quotes( game ) %>
+ </td>
+
</tr>
<% last_play_at = game.play_at
end %><!-- each game -->
@@ -0,0 +1,14 @@
+<!-- paras: requires event -->
+
+<table class='odds'>
+ <tr>
+<% Service.all.each do |srv| %>
+ <td>
+ <%= srv.title %><br>
+ <% srv.event_quotes.where( event.id ).each do |quote| %>
+ <%= quote.team.tag %> <%= fmt_quote( quote.odds ) %><br>
+ <% end %><!-- each qoute -->
+ </td>
+<% end %><!-- each service -->
+</tr>
+</table>
@@ -0,0 +1,24 @@
+
+<% if game.quotes.count > 0 %>
+
+<table class='odds'>
+ <tr>
+ <td class='center'>1</td>
+ <td class='center'>X</td>
+ <td class='center'>2</td>
+ <td><!-- service --></td>
+ </tr>
+<% game.quotes.each do |quote| %>
+<tr>
+ <td><%= fmt_quote( quote.odds1 ) %></td>
+ <td><%= fmt_quote( quote.oddsx ) %></td>
+ <td><%= fmt_quote( quote.odds2 ) %></td>
+ <td>(<%= quote.service.title %>)</td>
+ <!-- add last updated? -->
+</tr>
+<% end %><!-- each quote -->
+</table>
+
+<% else %>
+ <!-- no quotes -->
+<% end %>
@@ -0,0 +1,60 @@
+<!-- paras: required play
+ calculated: pool from play
+ -->
+
+<table>
+ <tr>
+ <td>1. Platz</td>
+ <!-- fix: use helper or partial -->
+ <% if play.team1.present? %>
+ <td>
+ <% if play.public? %>
+ <%= image_tag( play.team1.img ) if play.team1.img.present? %>
+ <%= play.team1.title %>
+ <% else %>
+ Team Anonym
+ <% end %>
+ </td>
+ <% else %>
+ <td style='text-align: center;'>
+ <span class='missing'>?</span>
+ </td>
+ <% end %>
+ </tr>
+ <tr>
+ <td>2. Platz</td>
+ <% if play.team2.present? %>
+ <td>
+ <% if play.public? %>
+ <%= image_tag( play.team2.img ) if play.team2.img.present? %>
+ <%= play.team2.title %>
+ <% else %>
+ Team Anonym
+ <% end %>
+ </td>
+ <% else %>
+ <td style='text-align: center;'>
+ <span class='missing'>?</span>
+ </td>
+ <% end %>
+ </tr>
+ <% if pool.team3? %>
+ <tr>
+ <td>3. Platz</td>
+ <% if play.team3.present? %>
+ <td>
+ <% if play.public? %>
+ <%= image_tag( play.team3.img ) if play.team3.img.present? %>
+ <%= play.team3.title %>
+ <% else %>
+ Team Anonym
+ <% end %>
+ </td>
+ <% else %>
+ <td style='text-align: center;'>
+ <span class='missing'>?</span>
+ </td>
+ <% end %>
+ </tr>
+<% end %>
+</table>
Oops, something went wrong.

0 comments on commit 41519b2

Please sign in to comment.