From b76b681428c642b4dce51c42a9d198ac4351ba99 Mon Sep 17 00:00:00 2001 From: "t.felgentreff" Date: Wed, 8 Sep 2010 14:41:52 +0000 Subject: [PATCH] split the field mapping to be able to hook into it git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1679 7926756e-e54e-46e6-9721-ed318f58905e --- app/helpers/reporting_helper.rb | 42 +++++++++++++++++---------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/app/helpers/reporting_helper.rb b/app/helpers/reporting_helper.rb index 931688267c..44c806655b 100644 --- a/app/helpers/reporting_helper.rb +++ b/app/helpers/reporting_helper.rb @@ -55,26 +55,28 @@ module ReportingHelper def show_field(key, value) @show_row ||= Hash.new { |h,k| h[k] = {}} - @show_row[key][value] ||= begin - return l(:label_none) if value.blank? - case key.to_sym - when :activity_id then mapped value, Enumeration, "#{l(:caption_material_costs)}" - when :project_id then link_to_project Project.find(value.to_i) - when :user_id, :assigned_to_id then link_to_user User.find(value.to_i) - when :tyear, :units then value - when :tweek then "#{l(:label_week)} ##{value}" - when :tmonth then month_name(value.to_i) - when :category_id then IssueCategory.find(value.to_i).name - when :cost_type_id then mapped value, CostType, l(:caption_labor) - when :cost_object then CostObject.find(value.to_i).subject - when :issue_id then link_to_issue Issue.find(value.to_i) - when :spent_on then format_date(value.to_date) - when :tracker_id then Tracker.find(value.to_i) - when :week then "#{l(:label_week)} #%s" % value.to_i.modulo(100) - when :priority_id then IssuePriority.find(value.to_i).name - when :fixed_version_id then Version.find(value.to_i).name - else value.inspect - end + @show_row[key][value] ||= field_representation_map(key, value) + end + + def field_representation_map(key, value) + return l(:label_none) if value.blank? + case key.to_sym + when :activity_id then mapped value, Enumeration, "#{l(:caption_material_costs)}" + when :project_id then link_to_project Project.find(value.to_i) + when :user_id, :assigned_to_id then link_to_user User.find(value.to_i) + when :tyear, :units then value + when :tweek then "#{l(:label_week)} ##{value}" + when :tmonth then month_name(value.to_i) + when :category_id then IssueCategory.find(value.to_i).name + when :cost_type_id then mapped value, CostType, l(:caption_labor) + when :cost_object then CostObject.find(value.to_i).subject + when :issue_id then link_to_issue Issue.find(value.to_i) + when :spent_on then format_date(value.to_date) + when :tracker_id then Tracker.find(value.to_i) + when :week then "#{l(:label_week)} #%s" % value.to_i.modulo(100) + when :priority_id then IssuePriority.find(value.to_i).name + when :fixed_version_id then Version.find(value.to_i).name + else value.inspect end end