Include the Project name when sorting versions.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@3761 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
f3cc84b343
commit
1a4b23731f
|
@ -124,13 +124,25 @@ class Version < ActiveRecord::Base
|
||||||
|
|
||||||
def to_s; name end
|
def to_s; name end
|
||||||
|
|
||||||
# Versions are sorted by effective_date and name
|
# Versions are sorted by effective_date and "Project Name - Version name"
|
||||||
# Those with no effective_date are at the end, sorted by name
|
# Those with no effective_date are at the end, sorted by "Project Name - Version name"
|
||||||
def <=>(version)
|
def <=>(version)
|
||||||
if self.effective_date
|
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
|
else
|
||||||
version.effective_date ? 1 : (self.name <=> version.name)
|
self.effective_date <=> version.effective_date
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if version.effective_date
|
||||||
|
1
|
||||||
|
else
|
||||||
|
"#{self.project.name} - #{self.name}" <=> "#{version.project.name} - #{version.name}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue