Project

General

Profile

Defect #7335 » sort_issues_from_start_date.diff

Felipe Ribeiro, 2011-12-05 20:03

View differences:

lib/redmine/helpers/gantt.rb (working copy)
678 678
        if x.root_id == y.root_id
679 679
          x.lft <=> y.lft
680 680
        else
681
          x.root_id <=> y.root_id
681
	  if x.start_date != nil and y.start_date != nil
682
		x.start_date <=> y.start_date
683
	  elsif x.start_date != nil
684
		-1
685
	  elsif y.start_date != nil
686
		1
687
	  else
688
	        x.root_id <=> y.root_id
689
          end
682 690
        end
683 691
      end
684 692

  
app/models/issue.rb (working copy)
766 766
      # update former parent
767 767
      recalculate_attributes_for(former_parent_id) if former_parent_id
768 768
    end
769

  
770
    if self.parent != nil and self.start_date
771
      lesser_sibling_found = false
772
      last_visited = nil
773
      self.parent.children.reverse.each do |sibling|
774
        if (sibling != self and sibling.start_date and sibling.start_date < self.start_date)
775
          if last_visited != self
776
            move_to_right_of sibling
777
          end
778
          lesser_sibling_found = true
779
          break
780
        end
781
        last_visited = sibling
782
      end
783

  
784
      if self.parent.children[0] != self and not lesser_sibling_found
785
        move_to_left_of(self.parent.children[0])
786
      end
787
    end
788

  
769 789
    remove_instance_variable(:@parent_issue) if instance_variable_defined?(:@parent_issue)
770 790
  end
771 791

  
(1-1/13)