# Adds a filter for the given custom field
def add_custom_field_filter(field, assoc=nil)
options = field.query_filter_options(self)
- if field.format.target_class && field.format.target_class <= User
- if options[:values].is_a?(Array) && User.current.logged?
- options[:values].unshift ["<< #{l(:label_me)} >>", "me"]
- end
- end
filter_id = "cf_#{field.id}"
filter_name = field.name
end
def query_filter_options(custom_field, query)
- {:type => :list_optional, :values => query_filter_values(custom_field, query)}
+ {:type => :list_optional, :values => lambda { query_filter_values(custom_field, query) }}
end
protected
custom_field.user_role.map!(&:to_s).reject!(&:blank?)
end
end
+
+ def query_filter_values(*args)
+ [["<< #{l(:label_me)} >>", "me"]] + super
+ end
end
class VersionFormat < RecordList
query = Query.new(:project => project)
assert_not_include version.name, field.possible_values_options(project).map(&:first)
- assert_include version.name, field.query_filter_options(query)[:values].map(&:first)
+ assert_include version.name, field.query_filter_options(query)[:values].call.map(&:first)
end
end