diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2013-05-21 13:42:19 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2013-05-21 13:42:19 +0000 |
commit | 8ea4e79964163187354a48172ee6afd1648396e2 (patch) | |
tree | ad7edd689872f354290798ccbe8f7e99631abad8 /lib | |
parent | 596366b062863ea8654536493480437208fcc965 (diff) | |
download | redmine-8ea4e79964163187354a48172ee6afd1648396e2.tar.gz redmine-8ea4e79964163187354a48172ee6afd1648396e2.zip |
gantt: sort issues by start date (#7335)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11897 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r-- | lib/redmine/helpers/gantt.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb index 7538c48dc..e8e7ac458 100644 --- a/lib/redmine/helpers/gantt.rb +++ b/lib/redmine/helpers/gantt.rb @@ -675,18 +675,19 @@ module Redmine start_date + (end_date - start_date + 1) * (progress / 100.0) end - # TODO: Sorts a collection of issues by start_date, due_date, id for gantt rendering def self.sort_issues!(issues) - issues.sort! { |a, b| gantt_issue_compare(a, b) } - end - - # TODO: top level issues should be sorted by start date - def self.gantt_issue_compare(x, y) - if x.root_id == y.root_id - x.lft <=> y.lft - else - x.root_id <=> y.root_id - end + issues.sort! {|a, b| sort_issue_logic(a) <=> sort_issue_logic(b)} + end + + def self.sort_issue_logic(issue) + julian_date = Date.new() + ancesters_start_date = [] + current_issue = issue + begin + ancesters_start_date.unshift([current_issue.start_date || julian_date, current_issue.id]) + current_issue = current_issue.parent + end while (current_issue) + ancesters_start_date end def current_limit |