Distributes WP attributes over two tables

pull/802/head
Hagen Schink 11 years ago
parent aeaf8a6909
commit 310492dd4f
  1. 47
      app/helpers/work_packages_helper.rb
  2. 28
      app/views/work_packages/show.html.erb

@ -329,19 +329,42 @@ module WorkPackagesHelper
end
def work_package_show_attributes(work_package)
main_attributes = work_package_show_main_attributes(work_package)
custom_field_attributes = work_package_show_custom_fields(work_package)
hook_attributes = YAML::load(call_hook(:view_work_packages_show_details_bottom, :issue => work_package))
ordered = { left: [], right: [] }
[main_attributes, custom_field_attributes, hook_attributes].each_with_object(ordered) do |list, h|
h[:left] << list[0..list.count / 2]
h[:right] << list[list.count / 2 + 1..list.count]
end
(ordered[:left] + ordered[:right]).flatten.compact
end
def work_package_show_main_attributes(work_package)
[
work_package_show_status_attribute(work_package),
work_package_show_start_date_attribute(work_package),
work_package_show_priority_attribute(work_package),
work_package_show_due_date_attribute(work_package),
work_package_show_assigned_to_attribute(work_package),
work_package_show_progress_attribute(work_package),
work_package_show_responsible_attribute(work_package),
work_package_show_category_attribute(work_package),
work_package_show_spent_time_attribute(work_package),
work_package_show_fixed_version_attribute(work_package),
work_package_show_estimated_hours_attribute(work_package)
].compact
work_package_show_status_attribute(work_package),
work_package_show_priority_attribute(work_package),
work_package_show_assigned_to_attribute(work_package),
work_package_show_responsible_attribute(work_package),
work_package_show_category_attribute(work_package),
work_package_show_estimated_hours_attribute(work_package),
work_package_show_start_date_attribute(work_package),
work_package_show_due_date_attribute(work_package),
work_package_show_progress_attribute(work_package),
work_package_show_spent_time_attribute(work_package),
work_package_show_fixed_version_attribute(work_package)
]
end
def work_package_show_custom_fields(work_package)
work_package.custom_field_values.each_with_object([]) do |v, a|
a << work_package_show_table_row(v.custom_field.name, '') do
simple_format_without_paragraph(h(show_value(v)))
end
end
end
def work_package_show_table_row(attribute, klass = nil, &block)

@ -49,20 +49,22 @@ See doc/COPYRIGHT.rdoc for more details.
<div class="issue details">
<div class="meta">
<table class="attributes">
<% work_package_show_attributes(work_package).each_slice(2) do |attributes| %>
<tr>
<% attributes.each do |attribute| %>
<%= attribute.field %>
<% attribute_slices = work_package_show_attributes(work_package) %>
<div id="left" style="float:left; width:50%;">
<table class="attributes">
<% (0..attribute_slices.count / 2).each do |index| %>
<tr><%= attribute_slices[index].field.html_safe %> </tr>
<% end %>
</tr>
<% end %>
<%= render_custom_fields_rows(work_package) %>
<%= call_hook(:view_work_packages_show_details_bottom, :issue => work_package) %>
</table>
</table>
</div>
<div id="right" style="float:left; width:50%;">
<table class="attributes">
<% (attribute_slices.count / 2 + 1..attribute_slices.count - 1).each do |index| %>
<tr><%= attribute_slices[index].field.html_safe %> </tr>
<% end %>
</table>
<br style="clear:both;" />
</div>
</div>
</div>
<% if work_package.description? %>

Loading…
Cancel
Save