fixes patching the work_package#show page

pull/6827/head
Jens Ulferts 11 years ago
parent f39f10d60c
commit fb5cb3bc13
  1. 2
      app/views/hooks/_view_issues_show_details_bottom.html.erb
  2. 13
      lib/open_project/costs/patches/issues_helper_patch.rb

@ -4,7 +4,7 @@
<%# 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_issues_attributes %>
<% attributes_array = cost_issues_attributes(controller.work_package) %>
<% (0..(attributes_array.size - 1)).step(2) do |i| %>
<tr>
<th>

@ -42,13 +42,13 @@ module OpenProject::Costs::Patches::IssuesHelperPatch
str_array.join(", ").html_safe
end
def cost_issues_attributes
def cost_issues_attributes(work_package)
attributes = []
object_value = if @work_package.cost_object.nil?
object_value = if work_package.cost_object.nil?
"-"
else
link_to_cost_object(@work_package.cost_object)
link_to_cost_object(work_package.cost_object)
end
attributes << [CostObject.model_name.human, object_value]
@ -56,8 +56,11 @@ module OpenProject::Costs::Patches::IssuesHelperPatch
if User.current.allowed_to?(:view_time_entries, @project) ||
User.current.allowed_to?(:view_own_time_entries, @project)
value = @work_package.spent_hours > 0 ?
link_to(l_hours(@work_package.spent_hours), issue_time_entries_path(@work_package)) : "-"
#TODO: put inside controller or model
summed_hours = @time_entries.sum(&:hours)
value = summed_hours > 0 ?
link_to(l_hours(summed_hours), issue_time_entries_path(work_package)) : "-"
attributes << [Issue.human_attribute_name(:spent_hours), value]
end

Loading…
Cancel
Save