choose table partitial depending on query

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1466 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
rkh 14 years ago
parent cc6f32cb38
commit 8fbf20bf02
  1. 14
      app/controllers/cost_reports_controller.rb
  2. 4
      app/helpers/reporting_helper.rb
  3. 0
      app/views/cost_reports/_cost_entry_table.rhtml
  4. 4
      app/views/cost_reports/_cost_report_table.rhtml
  5. 0
      app/views/cost_reports/_simple_cost_report_table.rhtml

@ -7,7 +7,13 @@ class CostReportsController < ApplicationController
def index
CostQuery::QueryUtils.cache.clear
@table_partial = "cost_report_table"
if @query.group_bys.empty?
@table_partial = "cost_entry_table"
elsif @query.depth_of(:column) == 0 or @query.depth_of(:row) == 0
@table_partial = "simple_cost_report_table"
else
@table_partial = "cost_report_table"
end
render :layout => !request.xhr?
end
@ -24,7 +30,7 @@ class CostReportsController < ApplicationController
filters ||= session[:cost_query].try(:[], :filters)
filters ||= default_filter_parameters
end
def group_params
groups = http_group_parameters if set_filter?
groups ||= session[:cost_query].try(:[], :groups)
@ -40,7 +46,7 @@ class CostReportsController < ApplicationController
hash
end
end
def http_group_parameters
if params[:groups]
rows = params[:groups][:rows]
@ -53,7 +59,7 @@ class CostReportsController < ApplicationController
# Set a default query to cut down initial load time
def default_filter_parameters
{:operators => {:user_id => "=", :created_on => ">d"},
:values => {:user_id => [User.current.id], :created_on => [30.days.ago.strftime('%Y-%m-%d')]}
:values => {:user_id => [User.current.id], :created_on => [30.days.ago.strftime('%Y-%m-%d')]}
}.tap do |hash|
if @project
hash[:operators].merge! :project_id => "="

@ -41,6 +41,10 @@ module ReportingHelper
klass.find(id).name
end
def debug_fields(result, prefix = ", ")
prefix << result.fields.inspect << ", " << result.key.inspect if params[:debug]
end
##
# For a given row, determine how to render it's contents according to usability and
# localization rules

@ -4,10 +4,6 @@
<%
def debug_fields(result, prefix = ", ")
prefix << result.fields.inspect << ", " << result.key.inspect if params[:debug]
end
walker.for_final_row do |row, cells|
html = "<th class='normal inner left'>#{show_row row}#{debug_fields(row)}</th>"
html << cells.join

Loading…
Cancel
Save