Feature #26642 » query_humanize.patch
| app/models/query.rb (revision ) | ||
|---|---|---|
|
class QueryFilter
|
||
|
include Redmine::I18n
|
||
|
def initialize(field, options)
|
||
|
def initialize(queried_class, field, options)
|
||
|
@field = field.to_s
|
||
|
@options = options
|
||
|
@options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
|
||
|
field_name = field.gsub(/_id$/, '')
|
||
|
@options[:name] ||= l(options[:label], default: queried_class.human_attribute_name(field_name))
|
||
|
# Consider filters with a Proc for values as remote by default
|
||
|
@remote = options.key?(:remote) ? options[:remote] : options[:values].is_a?(Proc)
|
||
|
end
|
||
| ... | ... | |
|
# Adds an available filter
|
||
|
def add_available_filter(field, options)
|
||
|
@available_filters ||= ActiveSupport::OrderedHash.new
|
||
|
@available_filters[field] = QueryFilter.new(field, options)
|
||
|
@available_filters[field] = QueryFilter.new(queried_class, field, options)
|
||
|
@available_filters
|
||
|
end
|
||