diff options
author | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-10-04 04:48:48 +0000 |
---|---|---|
committer | Toshi MARUYAMA <marutosijp2@yahoo.co.jp> | 2012-10-04 04:48:48 +0000 |
commit | 88e1587b08507e984d7ecb08e4e296c00a53df99 (patch) | |
tree | 5e08e1f5bd2428ddcfab32c850c520e59b808056 /app/helpers/queries_helper.rb | |
parent | fb4210b6d969c50de2c4f676124d26820a337377 (diff) | |
download | redmine-88e1587b08507e984d7ecb08e4e296c00a53df99.tar.gz redmine-88e1587b08507e984d7ecb08e4e296c00a53df99.zip |
sort custom field issue filter by type and position (#12018)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@10555 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/queries_helper.rb')
-rw-r--r-- | app/helpers/queries_helper.rb | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb index c85e014e0..6ea879a35 100644 --- a/app/helpers/queries_helper.rb +++ b/app/helpers/queries_helper.rb @@ -24,7 +24,28 @@ module QueriesHelper def filters_options(query) options = [[]] - options += query.available_filters.sort {|a,b| a[1][:order] <=> b[1][:order]}.map do |field, field_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| [field_options[:name], field] end end |