Skip to content

Commit

Permalink
Fix for Redmine 3.2
Browse files Browse the repository at this point in the history
Backported from backlogs#1113
  • Loading branch information
danielvijge committed Jun 24, 2016
1 parent c520625 commit de26815
Showing 1 changed file with 22 additions and 23 deletions.
45 changes: 22 additions & 23 deletions lib/backlogs_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
module BacklogsPlugin
module Hooks
class LayoutHook < Redmine::Hook::ViewListener

include IssuesHelper
# this ought to be view_issues_sidebar_queries_bottom, but
# the entire queries toolbar is disabled if you don't have
# custom queries
Expand Down Expand Up @@ -86,35 +88,34 @@ def view_issues_show_details_bottom(context={ })

return '' unless Backlogs.configured?(issue.project)

snippet = ''

project = context[:project]

if issue.is_story?
snippet += "<tr><th>#{l(:field_story_points)}</th><td>#{RbStory.find(issue.id).points_display}</td>"
unless issue.remaining_hours.nil?
snippet += "<th>#{l(:field_remaining_hours)}</th><td>#{l_hours(issue.remaining_hours)}</td>"
issue_fields_rows do |rows|

if issue.is_story?
rows.left l(:field_story_points), RbStory.find(issue.id).points_display, :class => 'story-points'
unless issue.remaining_hours.nil?
rows.right l(:field_remaining_hours), l_hours(issue.remaining_hours), :class => 'remaining-hours'
end

vbe = issue.velocity_based_estimate
rows.left l(:field_velocity_based_estimate), vbe ? vbe.to_s + ' days' : '-', :class => 'velocity-based-estimate'

unless issue.release_id.nil?
release = RbRelease.find(issue.release_id)
rows.left l(:field_release), link_to(release.name, url_for_prefix_in_hooks + url_for({:controller => 'rb_releases', :action => 'show', :release_id => release})), :class => 'release'
relation_translate = l("label_release_relationship_#{RbStory.find(issue.id).release_relationship}")
rows.right l(:field_release_relationship), relation_translate, :class => 'release-relationship'
end
end
snippet += "</tr>"
vbe = issue.velocity_based_estimate
snippet += "<tr><th>#{l(:field_velocity_based_estimate)}</th><td>#{vbe ? vbe.to_s + ' days' : '-'}</td></tr>"

unless issue.release_id.nil?
release = RbRelease.find(issue.release_id)
snippet += "<tr><th>#{l(:field_release)}</th><td>#{link_to(release.name, url_for_prefix_in_hooks + url_for({:controller => 'rb_releases', :action => 'show', :release_id => release}))}</td>"
relation_translate = l("label_release_relationship_#{RbStory.find(issue.id).release_relationship}")
snippet += "<th>#{l(:field_release_relationship)}</th><td>#{relation_translate}</td></tr>"

if issue.is_task? && User.current.allowed_to?(:update_remaining_hours, project) != nil
rows.left l(:field_remaining_hours), issue.remaining_hours, :class => 'remaining-hours'
end
end

if issue.is_task? && User.current.allowed_to?(:update_remaining_hours, project) != nil
snippet += "<tr><th>#{l(:field_remaining_hours)}</th><td>#{issue.remaining_hours}</td></tr>"
end

return snippet
rescue => e
exception(context, e)
return ''
end
end

Expand Down Expand Up @@ -154,7 +155,6 @@ def view_issues_form_details_bottom(context={ })

if issue.descendants.length != 0 && !issue.new_record?
snippet += <<-generatedscript
<script type="text/javascript">
var $j = RB.$ || $;
$j(function($) {
Expand Down Expand Up @@ -279,7 +279,6 @@ def view_versions_show_bottom(context={ })
# this wouldn't be necesary if the schedules plugin
# didn't disable the contextual hook
snippet += <<-generatedscript
<script type="text/javascript">
var $j = RB.$ || $;
$j(function($) {
Expand Down

0 comments on commit de26815

Please sign in to comment.