From 701d2eaeacdfc18ede147702522f4325528b37bb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 25 Jul 2010 11:43:19 +0000 Subject: [PATCH] Display project names in cross-project gantt PNG (#5904). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3885 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/gantts_controller.rb | 2 +- lib/redmine/helpers/gantt.rb | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/app/controllers/gantts_controller.rb b/app/controllers/gantts_controller.rb index bc2d6350..e762c19c 100644 --- a/app/controllers/gantts_controller.rb +++ b/app/controllers/gantts_controller.rb @@ -37,7 +37,7 @@ class GanttsController < ApplicationController respond_to do |format| format.html { render :action => "show", :layout => !request.xhr? } - format.png { send_data(@gantt.to_image, :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') + format.png { send_data(@gantt.to_image(@project), :disposition => 'inline', :type => 'image/png', :filename => "#{basename}.png") } if @gantt.respond_to?('to_image') format.pdf { send_data(gantt_to_pdf(@gantt, @project), :type => 'application/pdf', :filename => "#{basename}.pdf") } end end diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 330b58ee..96ba4db7 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -91,12 +91,12 @@ module Redmine # Generates a gantt image # Only defined if RMagick is avalaible - def to_image(format='PNG') + def to_image(project, format='PNG') date_to = (@date_from >> @months)-1 show_weeks = @zoom > 1 show_days = @zoom > 2 - subject_width = 320 + subject_width = 400 header_heigth = 18 # width of one day in pixels zoom = @zoom*2 @@ -115,7 +115,14 @@ module Redmine gc.stroke('transparent') gc.stroke_width(1) events.each do |i| - gc.text(4, top + 2, (i.is_a?(Issue) ? i.subject : i.name)) + text = "" + if i.is_a? Issue + text = "#{i.tracker} #{i.id}: #{i.subject}" + else + text = i.name + end + text = "#{i.project} - #{text}" unless project && project == i.project + gc.text(4, top + 2, text) top = top + 20 end