Show precedes/follows and blocks/blocked relations on the Gantt diagram (#3436).
Based on Toshi MARUYAMA's patch. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11118 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
9adb0c61a9
commit
601148c5b1
4 files changed
+193
-5
No files matched your search
@@ -23,6 +23,12 @@ module Redmine
|
||||
include Redmine::I18n
|
||||
include Redmine::Utils::DateCalculation
|
||||
|
||||
# Relation types that are rendered
|
||||
DRAW_TYPES = {
|
||||
IssueRelation::TYPE_BLOCKS => { :landscape_margin => 16, :color => '#F34F4F' },
|
||||
IssueRelation::TYPE_PRECEDES => { :landscape_margin => 20, :color => '#628FEA' }
|
||||
}.freeze
|
||||
|
||||
# :nodoc:
|
||||
# Some utility methods for the PDF export
|
||||
class PDF
|
||||
@@ -136,6 +142,20 @@ module Redmine
|
||||
)
|
||||
end
|
||||
|
||||
# Returns a hash of the relations between the issues that are present on the gantt
|
||||
# and that should be displayed, grouped by issue ids.
|
||||
def relations
|
||||
return @relations if @relations
|
||||
if issues.any?
|
||||
issue_ids = issues.map(&:id)
|
||||
@relations = IssueRelation.
|
||||
where(:issue_from_id => issue_ids, :issue_to_id => issue_ids, :relation_type => DRAW_TYPES.keys).
|
||||
group_by(&:issue_from_id)
|
||||
else
|
||||
@relations = {}
|
||||
end
|
||||
end
|
||||
|
||||
# Return all the project nodes that will be displayed
|
||||
def projects
|
||||
return @projects if @projects
|
||||
@@ -705,6 +725,16 @@ module Redmine
|
||||
params[:image].text(params[:indent], params[:top] + 2, subject)
|
||||
end
|
||||
|
||||
def issue_relations(issue)
|
||||
rels = {}
|
||||
if relations[issue.id]
|
||||
relations[issue.id].each do |relation|
|
||||
(rels[relation.relation_type] ||= []) << relation.issue_to_id
|
||||
end
|
||||
end
|
||||
rels
|
||||
end
|
||||
|
||||
def html_task(params, coords, options={})
|
||||
output = ''
|
||||
# Renders the task bar, with progress and late
|
||||
@@ -714,9 +744,18 @@ module Redmine
|
||||
style << "top:#{params[:top]}px;"
|
||||
style << "left:#{coords[:bar_start]}px;"
|
||||
style << "width:#{width}px;"
|
||||
output << view.content_tag(:div, ' '.html_safe,
|
||||
:style => style,
|
||||
:class => "#{options[:css]} task_todo")
|
||||
html_id = "task-todo-issue-#{options[:issue].id}" if options[:issue]
|
||||
content_opt = {:style => style,
|
||||
:class => "#{options[:css]} task_todo",
|
||||
:id => html_id}
|
||||
if options[:issue]
|
||||
rels_hash = {}
|
||||
issue_relations(options[:issue]).each do |k, v|
|
||||
rels_hash[k] = v.join(',')
|
||||
end
|
||||
content_opt[:data] = {"rels" => rels_hash}
|
||||
end
|
||||
output << view.content_tag(:div, ' '.html_safe, content_opt)
|
||||
if coords[:bar_late_end]
|
||||
width = coords[:bar_late_end] - coords[:bar_start] - 2
|
||||
style = ""
|
||||
|
||||
Reference in new issue
Block a user