fix table with multiple top column groups

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1335 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
rkh 15 years ago
parent 6ba4766cea
commit dcde19daf4
  1. 2
      app/models/cost_query/operator.rb
  2. 11
      app/models/cost_query/walker.rb
  3. 21
      app/views/cost_reports/_cost_report_table.rhtml
  4. 1
      app/views/cost_reports/_filters.rhtml

@ -115,7 +115,7 @@ class CostQuery::Operator
new "t", :arg_count => 0 do new "t", :arg_count => 0 do
include DateRange include DateRange
def modify(query, field, value=nil) def modify(query, field, *value)
super query, field, 0, 0 super query, field, 0, 0
end end
end end

@ -30,14 +30,17 @@ class CostQuery::Walker
cell ? for_cell[cell] : for_empty_cell[nil] cell ? for_cell[cell] : for_empty_cell[nil]
end end
def headers(result = nil, &block) def headers(result = nil, first_in_col = true, last_in_col = true, &block)
result, wrapper = nil, wrapper if result.respond_to? "%"
result = nil if reverse = (result == :reverse) result = nil if reverse = (result == :reverse)
first = result.nil? first = result.nil?
result ||= query.column_first result ||= query.column_first
return unless result.column? and not result.final_column? return unless result.column? and not result.final_column?
yield result, first unless reverse
result.each { |r| headers(r, &block) } yield result, first, first_in_col, last_in_col unless reverse
yield result, first if reverse size = result.size - 1
result.each_with_index { |r,i| headers(r, (first_in_col && i == 0), (last_in_col && i == size), &block) }
yield result, first, first_in_col, last_in_col if reverse
end end
def body(result = nil) def body(result = nil)

@ -15,7 +15,7 @@
subrows subrows
end end
walker.for_empty_cell { "<td></td>" } walker.for_empty_cell { "<td>&nbsp;</td>" }
walker.for_cell do |result| walker.for_cell do |result|
"<td>#{number_to_currency result.real_costs}</td>" "<td>#{number_to_currency result.real_costs}</td>"
@ -23,27 +23,30 @@
%> %>
<table style='text-align: center' border='1'> <table style='text-align: center' border='1'>
<% walker.headers do |list, first| %> <% walker.headers do |list, first, first_in_col, last_in_col| %>
<tr> <%= '<tr>' if first_in_col %>
<%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first %> <%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first %>
<% list.each do |column| %> <% list.each do |column| %>
<td colspan="<%= column.final_number(:column) %>"><%= show_row column %></td> <td colspan="<%= column.final_number(:column) %>"><%= show_row column %></td>
<% end %> <% end %>
<%= "<td rowspan='#{@query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first %> <%= "<td rowspan='#{@query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first %>
</tr> <%= '</tr>' if last_in_col %>
<% end %> <% end %>
<% walker.body do |line| %> <% walker.body do |line| %>
<tr><%= line %></tr> <tr><%= line %></tr>
<% end %> <% end %>
<% walker.headers(:reverse) do |list, final| %> <% walker.headers(:reverse) do |list, final, first_in_col, last_in_col| %>
<% first = list.first.final_column? %> <% first = list.first.final_column? %>
<tr> <%= '<tr>' if first_in_col %>
<%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first %> <%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'></td>" if first && first_in_col %>
<% list.each do |column| %> <% list.each do |column| %>
<td colspan="<%= column.final_number(:column) %>"><%= number_to_currency column.real_costs %></td> <td colspan="<%= column.final_number(:column) %>"><%= number_to_currency column.real_costs %></td>
<% end %> <% end %>
<%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'>#{number_to_currency query.real_costs}</td>" if first %> <% if first && last_in_col %>
</tr> <%= "<td rowspan='#{query.depth_of(:column)}' colspan='#{query.depth_of(:row) - 1}'>#{number_to_currency query.real_costs}</td>" %>
<% end %>
<%= '</tr>' if last_in_col %>
<% end %> <% end %>
</table> </table>

@ -18,7 +18,6 @@ function set_filters() {
<% end %> <% end %>
<% end %> <% end %>
} }
document.observe("dom:loaded", set_filters()); document.observe("dom:loaded", set_filters());
//]]> //]]>
</script> </script>

Loading…
Cancel
Save