Merge pull request #72 from finnlabs/fix/accessibility_work_package_attribute_list_2258

[FIX] Accessibility work package attribute list 2258
pull/6827/head
Till Breuer 11 years ago
commit ecfd329cda
  1. 1
      CHANGELOG.md
  2. 27
      app/views/hooks/costs/_view_work_packages_show_details_bottom.html.erb
  3. 21
      lib/open_project/costs/patches/work_packages_helper_patch.rb

@ -2,6 +2,7 @@
## 5.0.1.pre11 ## 5.0.1.pre11
* `#2258` [Accessibility] linearisation of issue show form
* removed not needed require of core css files * removed not needed require of core css files
* firxed cuke * firxed cuke

@ -1,27 +0,0 @@
<% if @project.module_enabled?(:costs_module) && issue %>
<%# Only render this partial, if the plugin is enabled for the current project %>
<style>
<%# disables core's spent-time as it is not displayed if the user has just the view_own_time_entries permission %>
.spent-time { display: none }
</style>
<% attributes_array = cost_work_package_attributes(issue) %>
<% (0..(attributes_array.size - 1)).step(2) do |i| %>
<tr>
<th>
<%= attributes_array[i].first %>:
</th>
<td>
<%= attributes_array[i].to_a.last %>
</td>
<% if i + 1 < attributes_array.size %>
<th>
<%= attributes_array[i + 1].first %>:
</th>
<td>
<%= attributes_array[i + 1].to_a.last %>
</td>
<% end %>
</tr>
<% end %>
<% end %>

@ -9,7 +9,7 @@ module OpenProject::Costs::Patches::WorkPackagesHelperPatch
attributes << work_package_show_table_row(:cost_object) do attributes << work_package_show_table_row(:cost_object) do
work_package.cost_object ? work_package.cost_object ?
link_to_cost_object(work_package.cost_object) : link_to_cost_object(work_package.cost_object) :
"-" empty_element_tag
end end
if User.current.allowed_to?(:view_time_entries, @project) || if User.current.allowed_to?(:view_time_entries, @project) ||
User.current.allowed_to?(:view_own_time_entries, @project) User.current.allowed_to?(:view_own_time_entries, @project)
@ -20,13 +20,13 @@ module OpenProject::Costs::Patches::WorkPackagesHelperPatch
summed_hours > 0 ? summed_hours > 0 ?
link_to(l_hours(summed_hours), work_package_time_entries_path(work_package)) : link_to(l_hours(summed_hours), work_package_time_entries_path(work_package)) :
"-" empty_element_tag
end end
end end
attributes << work_package_show_table_row(:overall_costs) do attributes << work_package_show_table_row(:overall_costs) do
@overall_costs.nil? ? @overall_costs.nil? ?
"-" : empty_element_tag :
number_to_currency(@overall_costs) number_to_currency(@overall_costs)
end end
@ -44,7 +44,7 @@ module OpenProject::Costs::Patches::WorkPackagesHelperPatch
def summarized_cost_entries(cost_entries, work_package, create_link=true) def summarized_cost_entries(cost_entries, work_package, create_link=true)
last_cost_type = "" last_cost_type = ""
return "-" if cost_entries.blank? return empty_element_tag if cost_entries.blank?
result = cost_entries.sort_by(&:id).inject(Hash.new) do |result, entry| result = cost_entries.sort_by(&:id).inject(Hash.new) do |result, entry|
if entry.cost_type == last_cost_type if entry.cost_type == last_cost_type
result[last_cost_type][:units] += entry.units result[last_cost_type][:units] += entry.units
@ -78,17 +78,14 @@ module OpenProject::Costs::Patches::WorkPackagesHelperPatch
end end
def work_package_show_attributes_with_costs(work_package) def work_package_show_attributes_with_costs(work_package)
original = work_package_show_attributes_without_costs(work_package) attributes = work_package_show_attribute_list(work_package)
if @project.module_enabled? :costs_module if @project.module_enabled? :costs_module
original_without_spent_time = original.reject{ |a| a.attribute == :spent_time } attributes.reject!{ |a| a.attribute == :spent_time }
attributes += cost_work_package_attributes(work_package)
additions = cost_work_package_attributes(work_package)
original_without_spent_time + additions
else
original
end end
group_work_package_attributes attributes
end end
alias_method_chain :work_package_show_attributes, :costs alias_method_chain :work_package_show_attributes, :costs

Loading…
Cancel
Save