summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-29 20:21:39 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2010-12-29 20:21:39 +0000
commitf2ae2e923946ee9d27e7232cafcd0505dfb52118 (patch)
treed81045e5a56526764cb87fcfd9797a3cac36806f /lib
parentd2cc2861de766d1c0f1e38f9d1b48c16e46b2e1c (diff)
downloadredmine-f2ae2e923946ee9d27e7232cafcd0505dfb52118.tar.gz
redmine-f2ae2e923946ee9d27e7232cafcd0505dfb52118.zip
Simple issue sort method to make sure subtasks appear under their parent on the gantt (#7128).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@4581 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'lib')
-rw-r--r--lib/redmine/helpers/gantt.rb27
1 files changed, 4 insertions, 23 deletions
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index 4954434ce..fbdf09411 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -676,31 +676,12 @@ module Redmine
issues.sort! { |a, b| gantt_issue_compare(a, b, issues) }
end
+ # TODO: top level issues should be sorted by start date
def gantt_issue_compare(x, y, issues)
- if x.parent_id == y.parent_id
- gantt_start_compare(x, y)
- elsif x.is_ancestor_of?(y)
- -1
- elsif y.is_ancestor_of?(x)
- 1
+ if x.root_id == y.root_id
+ x.lft <=> y.lft
else
- ax = issues.select {|i| i.is_a?(Issue) && i.is_ancestor_of?(x) && !i.is_ancestor_of?(y) }.sort_by(&:lft).first
- ay = issues.select {|i| i.is_a?(Issue) && i.is_ancestor_of?(y) && !i.is_ancestor_of?(x) }.sort_by(&:lft).first
- if ax.nil? && ay.nil?
- gantt_start_compare(x, y)
- else
- gantt_issue_compare(ax || x, ay || y, issues)
- end
- end
- end
-
- def gantt_start_compare(x, y)
- if x.start_date.nil?
- -1
- elsif y.start_date.nil?
- 1
- else
- x.start_date <=> y.start_date
+ x.root_id <=> y.root_id
end
end