summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-10-04 04:48:48 +0000
committerToshi MARUYAMA <marutosijp2@yahoo.co.jp>2012-10-04 04:48:48 +0000
commit88e1587b08507e984d7ecb08e4e296c00a53df99 (patch)
tree5e08e1f5bd2428ddcfab32c850c520e59b808056 /app
parentfb4210b6d969c50de2c4f676124d26820a337377 (diff)
downloadredmine-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')
-rw-r--r--app/helpers/queries_helper.rb23
-rw-r--r--app/models/custom_field.rb2
-rw-r--r--app/models/query.rb6
3 files changed, 29 insertions, 2 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
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index a934cc877..86227a4cf 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -51,6 +51,8 @@ class CustomField < ActiveRecord::Base
:label => DocumentCategory::OptionName}
]
+ CUSTOM_FIELDS_NAMES = CUSTOM_FIELDS_TABS.collect{|v| v[:name]}
+
def set_searchable
# make sure these fields are not searchable
self.searchable = false if %w(int float date bool).include?(field_format)
diff --git a/app/models/query.rb b/app/models/query.rb
index 12a46c73f..dfb00825d 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -993,7 +993,11 @@ class Query < ActiveRecord::Base
filter_id = "#{assoc}.#{filter_id}"
filter_name = l("label_attribute_of_#{assoc}", :name => filter_name)
end
- @available_filters[filter_id] = options.merge({ :name => filter_name, :format => field.field_format })
+ @available_filters[filter_id] = options.merge({
+ :name => filter_name,
+ :format => field.field_format,
+ :field => field
+ })
end
end