@@ -68,8 +68,7 class Issue < ActiveRecord::Base | |||||
68 | :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] |
|
68 | :conditions => ["#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"] | |
69 | named_scope :for_gantt, lambda { |
|
69 | named_scope :for_gantt, lambda { | |
70 | { |
|
70 | { | |
71 |
:include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version] |
|
71 | :include => [:tracker, :status, :assigned_to, :priority, :project, :fixed_version] | |
72 | :order => "#{Issue.table_name}.due_date ASC, #{Issue.table_name}.start_date ASC, #{Issue.table_name}.id ASC" |
|
|||
73 | } |
|
72 | } | |
74 | } |
|
73 | } | |
75 |
|
74 |
@@ -178,6 +178,7 module Redmine | |||||
178 |
|
178 | |||
179 | # Second, Issues without a version |
|
179 | # Second, Issues without a version | |
180 | issues = project.issues.for_gantt.without_version.with_query(@query) |
|
180 | issues = project.issues.for_gantt.without_version.with_query(@query) | |
|
181 | sort_issues!(issues) | |||
181 | if issues |
|
182 | if issues | |
182 | issue_rendering = render_issues(issues, options) |
|
183 | issue_rendering = render_issues(issues, options) | |
183 | output << issue_rendering if options[:format] == :html |
|
184 | output << issue_rendering if options[:format] == :html | |
@@ -237,6 +238,7 module Redmine | |||||
237 |
|
238 | |||
238 | issues = version.fixed_issues.for_gantt.with_query(@query) |
|
239 | issues = version.fixed_issues.for_gantt.with_query(@query) | |
239 | if issues |
|
240 | if issues | |
|
241 | sort_issues!(issues) | |||
240 | # Indent issues |
|
242 | # Indent issues | |
241 | options[:indent] += options[:indent_increment] |
|
243 | options[:indent] += options[:indent_increment] | |
242 | output << render_issues(issues, options) |
|
244 | output << render_issues(issues, options) | |
@@ -952,6 +954,17 module Redmine | |||||
952 |
|
954 | |||
953 | private |
|
955 | private | |
954 |
|
956 | |||
|
957 | # Sorts a collection of issues by start_date, due_date, id for gantt rendering | |||
|
958 | def sort_issues!(issues) | |||
|
959 | issues.sort! do |a, b| | |||
|
960 | cmp = 0 | |||
|
961 | cmp = (a.start_date <=> b.start_date) if a.start_date? && b.start_date? | |||
|
962 | cmp = (a.due_date <=> b.due_date) if cmp == 0 && a.due_date? && b.due_date? | |||
|
963 | cmp = (a.id <=> b.id) if cmp == 0 | |||
|
964 | cmp | |||
|
965 | end | |||
|
966 | end | |||
|
967 | ||||
955 | # Renders both the subjects and lines of the Gantt chart for the |
|
968 | # Renders both the subjects and lines of the Gantt chart for the | |
956 | # PDF format |
|
969 | # PDF format | |
957 | def pdf_subjects_and_lines(pdf, options = {}) |
|
970 | def pdf_subjects_and_lines(pdf, options = {}) |
General Comments 0
You need to be logged in to leave comments.
Login now