Permalink
Browse files

more parts for reuse

  • Loading branch information...
1 parent 761ef55 commit ea3d6edd72849f7929ab4e7c3492fe9c0721e2f3 @geraldb geraldb committed Oct 3, 2012
View
@@ -19,6 +19,18 @@ def render_play_teams( play, opts={} )
:pool => play.pool
}
end
+
+ def render_play_team1( play, opts={} )
+ render :partial => 'shared/td_play_team1', :locals => { :play => play }
+ end
+
+ def render_play_team2( play, opts={} )
+ render :partial => 'shared/td_play_team2', :locals => { :play => play }
+ end
+
+ def render_play_team3( play, opts={} )
+ render :partial => 'shared/td_play_team3', :locals => { :play => play }
+ end
def render_play_teams_for_form( play, form, opts={} )
@@ -35,6 +47,10 @@ def render_game_date( game, opts={} )
render :partial => 'shared/td_game_date', :locals => { :game => game }
end
+ def render_game_toto12x( game, opts={} )
+ render :partial => 'shared/td_game_toto12x', :locals => { :game => game }
+ end
+
def render_game_score( game, opts={} )
render :partial => 'shared/td_game_score', :locals => { :game => game }
end
@@ -60,13 +76,24 @@ def render_tip_bingo( tip, opts={} )
def render_tip_score( tip, opts={} )
render :partial => 'shared/td_tip_score', :locals => { :tip => tip }
end
-
+
+ def render_tip_score_v2( tip, opts={} )
+ show_tips = opts[:show_tips].present? ? opts[:show_tips] : true # default true
+ show_pts = opts[:show_pts].present? ? opts[:show_pts] : false # default false
+
+ render :partial => 'shared/td_tip_score_v2',
+ :locals => { :tip => tip,
+ :game => tip.game,
+ :show_tips => show_tips,
+ :show_pts => show_pts }
+ end
+
def render_tip_toto12x( tip, opts={} )
render :partial => 'shared/td_tip_toto12x', :locals => { :tip => tip }
end
def render_tip_score_input_for_form( tip, form, opts={} )
- tabindex = opts[:tabindex] ||= 1000
+ tabindex = opts[:tabindex] || 1000
render :partial => 'shared/td_tip_score_input',
:locals => { :tip => tip,
@@ -55,48 +55,9 @@
<%= link_to user.name, play_path(play.id) %>
</span>
</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 %>
-
- <% 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 %>
-
-
- <% if @pool.team3? %>
- <% 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 %>
- <% end %>
+ <%= render_play_team1( play ) %>
+ <%= render_play_team2( play ) %>
+ <%= render_play_team3( play ) if @pool.team3? %>
</tr>
<% end %><!-- users.each -->
</table>
@@ -133,65 +94,24 @@
<td colspan='<%= 3+@users.count %>' class='game-round-title'><%= round.title %></td>
</tr>
- <% if @pool.flex? && round.calc? %>
- <tr>
- <td></td>
- <td colspan='<%= 3+@users.count %>' class='game-no-fixtures'>
- Spielaufstellungen noch nicht bekannt.
- </td>
- </tr>
- <% else %>
<% round.games.each do |game| %>
- <tr>
- <td class='game-toto12x'>
- <% if game.toto12x.present? %>
- <span class='toto12x'>
- <%= game.toto12x %>
- </span>
- <% end %>
- </td>
-
+ <tr>
+
+ <%= render_game_toto12x( game ) %>
+
<%= render_game_team1( game ) %>
<% @users.each do |user| %>
<% tip = Tip.find_by_user_and_pool_and_game( user, @pool, game ) %>
-
-<% if tip.present? %>
- <td class='tip-score'>
-
- <% if @show_tips %>
- <span class='<%= tip.bingo_style_class %>'>
- <%= tip.public_score_str %>
- </span>
- <% end %>
-
- <% if @show_pts %>
- <% if tip.calc_points > 0 %>
- <span class='<%= tip.bingo_style_class %>'>
- <%= tip.calc_points_str %> <%= tip.calc_points %>
- </span>
- <% elsif game.toto12x.present? %>
- ×
- <% else %>
- <!-- no game results (toto12x) yet available -->
- <% end %>
- <% end %>
- </td>
-<% else %>
- <td class='tip-score'>
- ♦<!-- fehler: datensatz fehlt! -->
- </td>
-<% end %>
-
+ <%= render_tip_score_v2( tip, :show_tips => @show_tips, :show_pts => @show_pts ) %>
<% end %><!-- users.each -->
<%= render_game_score( game ) %>
<%= render_game_team2( game ) %>
<%= render_game_date( game ) %>
</tr>
<% end %> <!-- games.each -->
- <% end %> <!-- if pool.flex? && round.calc? -->
<% end %> <!-- rounds.each -->
<tr>
@@ -5,56 +5,16 @@
<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 %>
+ <%= render_play_team1( play ) %>
</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 %>
+ <%= render_play_team2( play ) %>
</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 %>
+ <%= render_play_team3( play ) %>
</tr>
-<% end %>
+ <% end %>
</table>
@@ -0,0 +1,11 @@
+<!-- paras: required game -->
+
+<td class='game-toto12x'>
+ <% if game.toto12x.present? %>
+ <span class='toto12x'>
+ <%= game.toto12x %>
+ </span>
+ <% end %>
+</td>
+
+
@@ -0,0 +1,17 @@
+<!-- paras: requires play -->
+
+
+<% 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 %>
@@ -0,0 +1,16 @@
+<!-- paras: requires play -->
+
+<% 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 %>
@@ -0,0 +1,16 @@
+<!-- paras: requires play -->
+
+<% 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 %>
@@ -0,0 +1,30 @@
+<!-- paras requires tip;
+ calculated: game -> tip.game
+ -->
+
+<% if tip.present? %>
+ <td class='tip-score'>
+
+ <% if show_tips %>
+ <span class='<%= tip.bingo_style_class %>'>
+ <%= tip.public_score_str %>
+ </span>
+ <% end %>
+
+ <% if show_pts %>
+ <% if tip.calc_points > 0 %>
+ <span class='<%= tip.bingo_style_class %>'>
+ <%= tip.calc_points_str %> <%= tip.calc_points %>
+ </span>
+ <% elsif game.toto12x.present? %>
+ ×
+ <% else %>
+ <!-- no game results (toto12x) yet available -->
+ <% end %>
+ <% end %>
+ </td>
+<% else %>
+ <td class='tip-score'>
+ ♦<!-- fehler: datensatz fehlt! -->
+ </td>
+<% end %>
@@ -1,5 +1,7 @@
<td class='tip-toto12x'>
<% if tip.present? && tip.toto12x.present? %>
- <span class='toto12x'><%= tip.public_toto12x_str %></span>
+ <span class='toto12x'>
+ <%= tip.public_toto12x_str %>
+ </span>
<% end %>
</td>

0 comments on commit ea3d6ed

Please sign in to comment.