Project

General

Profile

Defect #7352 » gantt.rb.patch

v2 - Etienne Massip, 2011-01-18 14:17

View differences:

lib/redmine/helpers/gantt.rb (working copy)
98 98
        common_params.merge({:year => (date_from >> months).year, :month => (date_from >> months).month, :zoom => zoom, :months => months })
99 99
      end
100 100

  
101
            ### Extracted from the HTML view/helpers
101
      # Returns the list of projects to render
102
      def project_list
103
        if @project
104
          projects = [@project]
105
        else
106
          projects = Project.roots.visible.has_module('issue_tracking')
107

  
108
          if @query && @query.has_filter?('project_id')
109
            project_filter = @query.filters['project_id']
110
            projects.delete_if { |project| (project_filter[:operator] == '=') ^ !project_filter[:values].index(project.id.to_s).nil? }
111
          end
112
        end
113
        projects
114
      end
115

  
116
      ### Extracted from the HTML view/helpers
102 117
      # Returns the number of rows that will be rendered on the Gantt chart
103 118
      def number_of_rows
104 119
        return @number_of_rows if @number_of_rows
105
        
106
        rows = if @project
107
          number_of_rows_on_project(@project)
108
        else
109
          Project.roots.visible.has_module('issue_tracking').inject(0) do |total, project|
110
            total += number_of_rows_on_project(project)
111
          end
120

  
121
        rows = project_list().each do |total, project|
122
          total += number_of_rows_on_project(project)
112 123
        end
113
        
124

  
114 125
        rows > @max_rows ? @max_rows : rows
115 126
      end
116 127

  
......
161 172
        @subjects = '' unless options[:only] == :lines
162 173
        @lines = '' unless options[:only] == :subjects
163 174
        @number_of_rows = 0
164
        
165
        if @project
166
          render_project(@project, options)
167
        else
168
          Project.roots.visible.has_module('issue_tracking').each do |project|
169
            render_project(project, options)
170
            break if abort?
171
          end
175

  
176
        project_list().each do |project|
177
          render_project(project, options)
178
          break if abort?
172 179
        end
173 180
        
174 181
        @subjects_rendered = true unless options[:only] == :lines
(2-2/2)