add a map to the reporting helper sporting the sortable representation of a field and use that for raw-data for the JS sort

git-svn-id: https://dev.finn.de/svn/cockpit/branches/reporting_merge@1918 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
t.felgentreff 14 years ago committed by jwollert
parent 26617f4a8c
commit 71ad2153eb
  1. 14
      app/helpers/reporting_helper.rb
  2. 10
      app/views/cost_reports/_cost_entry_table.rhtml
  3. 4
      app/views/cost_reports/_simple_cost_report_table.rhtml

@ -66,6 +66,11 @@ module ReportingHelper
@show_row[key][value] ||= field_representation_map(key, value)
end
def raw_field(key, value)
@raw_row ||= Hash.new { |h,k| h[k] = {}}
@raw_row[key][value] ||= field_sort_map(key, value)
end
def cost_object_link(cost_object_id)
co = CostObject.find(cost_object_id)
if User.current.allowed_to_with_inheritance?(:view_cost_objects, co.project)
@ -98,6 +103,15 @@ module ReportingHelper
end
end
def field_sort_map(key, value)
return "" if value.blank?
case key.to_sym
when :issue_id, :tweek, :tmonth, :week then value.to_i
when :spent_on then value.to_date.mjd
else field_representation_map(key, value)
end
end
def show_result(row, unit_id = @unit_id)
case unit_id
when -1 then l_hours(row.units)

@ -23,9 +23,13 @@
<tbody>
<% @query.each_direct_result do |result| %>
<tr class='<%= cycle("odd", "even") %>'>
<% list.each do |field| %><td><%= show_field field, result.fields[field.to_s] %></td><% end %>
<td raw-data=<%= result.units %>><%= show_result(result, result.fields['cost_type_id'].to_i) %></td>
<td class="right currency" raw-data=<%= result.real_costs %>><%= show_result(result, 0) %></td>
<% list.each do |field| %>
<td raw-data=<%= raw_field field, result.fields[field.to_s] %>>
<%= show_field field, result.fields[field.to_s] %>
</td>
<% end %>
<td class="units" raw-data=<%= result.units %>><%= show_result(result, result.fields['cost_type_id'].to_i) %></td>
<td class="currency" raw-data=<%= result.real_costs %>><%= show_result(result, 0) %></td>
<td style="width: 40px">
<%= link_to_if_authorized image_tag('edit.png'),
action_for(result, :action => 'edit'), :title => l(:button_edit) %>

@ -28,7 +28,9 @@ show_units = list.include? "cost_type_id"
<tbody>
<% @query.each do |result| %>
<tr class='<%= cycle("odd", "even") %>'>
<td><%= show_row result %></td>
<td raw-data=<%= raw_field result.fields.first, result.fields.first.last %>>
<%= show_row result %>
</td>
<td><%= result.count %></td>
<% if show_units %>
<td raw-data=<%= result.units %>><%= show_result result, result.fields[:cost_type_id].to_i %></td>

Loading…
Cancel
Save