Refactor: use an ordered hash to store available filters and remove :order option (#13154).

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@11372 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang
2013-02-14 20:37:17 +00:00
parent f77edce621
commit 0be82ea2c4
6 changed files with 158 additions and 167 deletions
+1 -22
View File
@@ -24,28 +24,7 @@ module QueriesHelper
def filters_options(query)
options = [[]]
sorted_options = query.available_filters.sort do |a, b|
ord = 0
if !(a[1][:order] == 20 && b[1][:order] == 20)
ord = a[1][:order] <=> b[1][:order]
else
cn = (CustomField::CUSTOM_FIELDS_NAMES.index(a[1][:field].class.name) <=>
CustomField::CUSTOM_FIELDS_NAMES.index(b[1][:field].class.name))
if cn != 0
ord = cn
else
f = (a[1][:field] <=> b[1][:field])
if f != 0
ord = f
else
# assigned_to or author
ord = (a[0] <=> b[0])
end
end
end
ord
end
options += sorted_options.map do |field, field_options|
options += query.available_filters.map do |field, field_options|
[field_options[:name], field]
end
end