Index: lib/redmine/helpers/gantt.rb =================================================================== --- lib/redmine/helpers/gantt.rb (revision 4732) +++ lib/redmine/helpers/gantt.rb (working copy) @@ -98,19 +98,30 @@ common_params.merge({:year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months }) end - ### Extracted from the HTML view/helpers + # Returns the list of projects to render + def project_list + if @project + projects = [@project] + else + projects = Project.roots.visible.has_module('issue_tracking') + + if @query && @query.has_filter?('project_id') + project_filter = @query.filters['project_id'] + projects.delete_if { |project| (project_filter[:operator] == '=') ^ !project_filter[:values].index(project.id.to_s).nil? } + end + end + projects + end + + ### Extracted from the HTML view/helpers # Returns the number of rows that will be rendered on the Gantt chart def number_of_rows return @number_of_rows if @number_of_rows - - rows = if @project - number_of_rows_on_project(@project) - else - Project.roots.visible.has_module('issue_tracking').inject(0) do |total, project| - total += number_of_rows_on_project(project) - end + + rows = project_list().each do |total, project| + total += number_of_rows_on_project(project) end - + rows > @max_rows ? @max_rows : rows end @@ -161,14 +172,10 @@ @subjects = '' unless options[:only] == :lines @lines = '' unless options[:only] == :subjects @number_of_rows = 0 - - if @project - render_project(@project, options) - else - Project.roots.visible.has_module('issue_tracking').each do |project| - render_project(project, options) - break if abort? - end + + project_list().each do |project| + render_project(project, options) + break if abort? end @subjects_rendered = true unless options[:only] == :lines