Feature #26642 » query_humanize.patch
| app/models/query.rb (revision ) | ||
|---|---|---|
| 163 | 163 |
class QueryFilter |
| 164 | 164 |
include Redmine::I18n |
| 165 | 165 | |
| 166 |
def initialize(field, options) |
|
| 166 |
def initialize(queried_class, field, options)
|
|
| 167 | 167 |
@field = field.to_s |
| 168 | 168 |
@options = options |
| 169 |
@options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
|
|
| 169 |
field_name = field.gsub(/_id$/, '') |
|
| 170 |
@options[:name] ||= l(options[:label], default: queried_class.human_attribute_name(field_name)) |
|
| 170 | 171 |
# Consider filters with a Proc for values as remote by default |
| 171 | 172 |
@remote = options.key?(:remote) ? options[:remote] : options[:values].is_a?(Proc) |
| 172 | 173 |
end |
| ... | ... | |
| 579 | 580 |
# Adds an available filter |
| 580 | 581 |
def add_available_filter(field, options) |
| 581 | 582 |
@available_filters ||= ActiveSupport::OrderedHash.new |
| 582 |
@available_filters[field] = QueryFilter.new(field, options) |
|
| 583 |
@available_filters[field] = QueryFilter.new(queried_class, field, options)
|
|
| 583 | 584 |
@available_filters |
| 584 | 585 |
end |
| 585 | 586 | |