diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-05 12:28:34 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2013-01-05 12:28:34 +0000 |
commit | 601148c5b11dd53a834e4dc738d33668970f9193 (patch) | |
tree | 41da71fb73027b0cd02acaa4246d47cb2a660322 /lib/redmine/helpers | |
parent | 9adb0c61a903eae9930a84510b25a8ed156ed4f8 (diff) | |
download | redmine-601148c5b11dd53a834e4dc738d33668970f9193.tar.gz redmine-601148c5b11dd53a834e4dc738d33668970f9193.zip |
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
Diffstat (limited to 'lib/redmine/helpers')
-rw-r--r-- | lib/redmine/helpers/gantt.rb | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index db88b7902..5bf0a1e98 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -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 = "" |