Project

General

Profile

Feature #26642 » query_humanize_attribute.patch

Dmitry Lisichkin, 2021-05-13 12:37

View differences:

app/models/query.rb
def initialize(field, options)
@field = field.to_s
@options = options
@options[:name] ||= l(options[:label] || "field_#{field}".gsub(/_id$/, ''))
# 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
field_name = field.gsub(/_id$/, '')
options[:name] ||= l(options[:label], default: queried_class.human_attribute_name(field_name))
@available_filters[field] = QueryFilter.new(field, options)
@available_filters
end
(2-2/2)