From dcde19daf452b61d253fc97e9c852285b3c61069 Mon Sep 17 00:00:00 2001 From: rkh Date: Thu, 8 Jul 2010 08:11:36 +0000 Subject: [PATCH] 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 --- app/models/cost_query/operator.rb | 2 +- app/models/cost_query/walker.rb | 11 +++++--- .../cost_reports/_cost_report_table.rhtml | 27 ++++++++++--------- app/views/cost_reports/_filters.rhtml | 1 - 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/app/models/cost_query/operator.rb b/app/models/cost_query/operator.rb index e537f7dccc..1badd004c6 100644 --- a/app/models/cost_query/operator.rb +++ b/app/models/cost_query/operator.rb @@ -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 diff --git a/app/models/cost_query/walker.rb b/app/models/cost_query/walker.rb index 7712a3250d..d8f0939162 100644 --- a/app/models/cost_query/walker.rb +++ b/app/models/cost_query/walker.rb @@ -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) diff --git a/app/views/cost_reports/_cost_report_table.rhtml b/app/views/cost_reports/_cost_report_table.rhtml index 115688ad80..851752f14a 100644 --- a/app/views/cost_reports/_cost_report_table.rhtml +++ b/app/views/cost_reports/_cost_report_table.rhtml @@ -15,7 +15,7 @@ subrows end - walker.for_empty_cell { "" } + walker.for_empty_cell { " " } walker.for_cell do |result| "#{number_to_currency result.real_costs}" @@ -23,27 +23,30 @@ %> - <% walker.headers do |list, first| %> - + <% walker.headers do |list, first, first_in_col, last_in_col| %> + <%= '' if first_in_col %> <%= "" if first %> <% list.each do |column| %> <% end %> <%= "" if first %> - + <%= '' if last_in_col %> <% end %> + <% walker.body do |line| %> <%= line %> <% end %> - <% walker.headers(:reverse) do |list, final| %> + <% walker.headers(:reverse) do |list, final, first_in_col, last_in_col| %> <% first = list.first.final_column? %> - - <%= "" if first %> - <% list.each do |column| %> - - <% end %> - <%= "" if first %> - + <%= '' if first_in_col %> + <%= "" if first && first_in_col %> + <% list.each do |column| %> + + <% end %> + <% if first && last_in_col %> + <%= "" %> + <% end %> + <%= '' if last_in_col %> <% end %>
<%= show_row column %>
<%= number_to_currency column.real_costs %>#{number_to_currency query.real_costs}
<%= number_to_currency column.real_costs %>#{number_to_currency query.real_costs}
\ No newline at end of file diff --git a/app/views/cost_reports/_filters.rhtml b/app/views/cost_reports/_filters.rhtml index 52b876d326..ee25fef8d9 100644 --- a/app/views/cost_reports/_filters.rhtml +++ b/app/views/cost_reports/_filters.rhtml @@ -18,7 +18,6 @@ function set_filters() { <% end %> <% end %> } - document.observe("dom:loaded", set_filters()); //]]>