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. 27
      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
include DateRange
def modify(query, field, value=nil)
def modify(query, field, *value)
super query, field, 0, 0
end
end

@ -30,14 +30,17 @@ class CostQuery::Walker
cell ? for_cell[cell] : for_empty_cell[nil]
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)
first = result.nil?
result ||= query.column_first
return unless result.column? and not result.final_column?
yield result, first unless reverse
result.each { |r| headers(r, &block) }
yield result, first if reverse
yield result, first, first_in_col, last_in_col unless 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
def body(result = nil)

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

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

Loading…
Cancel
Save