From 1a4b23731fc45e528fee7a3fb3e741efa8d5d273 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Thu, 27 May 2010 17:16:15 +0000 Subject: [PATCH] Include the Project name when sorting versions. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3761 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/version.rb | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/app/models/version.rb b/app/models/version.rb index e8a41600..07e66434 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -124,13 +124,25 @@ class Version < ActiveRecord::Base def to_s; name end - # Versions are sorted by effective_date and name - # Those with no effective_date are at the end, sorted by name + # Versions are sorted by effective_date and "Project Name - Version name" + # Those with no effective_date are at the end, sorted by "Project Name - Version name" def <=>(version) if self.effective_date - version.effective_date ? (self.effective_date == version.effective_date ? self.name <=> version.name : self.effective_date <=> version.effective_date) : -1 + if version.effective_date + if self.effective_date == version.effective_date + "#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}" + else + self.effective_date <=> version.effective_date + end + else + -1 + end else - version.effective_date ? 1 : (self.name <=> version.name) + if version.effective_date + 1 + else + "#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}" + end end end