gantt-sort-r10713.diff

Toshi MARUYAMA, 2012-10-24 15:32

Download (1.16 KB)

View differences:

lib/redmine/helpers/gantt.rb
643 643

  
644 644
      # TODO: top level issues should be sorted by start date
645 645
      def gantt_issue_compare(x, y)
646
        if x.root_id == y.root_id
647
          x.lft <=> y.lft
646
        gantt_issue_compare_param(x) <=> gantt_issue_compare_param(y)
647
      end
648

  
649
      def gantt_issue_compare_param(issue)
650
        issue_start = issue.start_date || Date.new
651
        if issue.leaf? && issue.parent.present?
652
          identifying_id    = issue.parent_id         || issue.id
653
          identifying_start = issue.parent.start_date || issue_start
654
          root_start        = issue.root.start_date   || issue_start
648 655
        else
649
          x.root_id <=> y.root_id
656
          identifying_id    = issue.id
657
          identifying_start = issue_start
658
          root_start        = issue_start
650 659
        end
660
        [root_start, issue.root_id, identifying_start, issue_start, issue.lft]
651 661
      end
652 662

  
653 663
      def current_limit