handle user filters
This commit is contained in:
parent
1d11cf6edc
commit
f4c435c3cd
2 changed files with 12 additions and 3 deletions
|
@ -19,6 +19,10 @@ class Item
|
|||
if key_str.start_with?('is_')
|
||||
is_label = I18n.translate("items.search.flag_keywords.is")
|
||||
"#{sign}#{is_label}:#{label}"
|
||||
elsif key_str.start_with?('user_')
|
||||
user_label = I18n.translate("items.search.labels.user_closet_hanger_ownership")
|
||||
value = Query::REVERSE_RESOURCE_FINDERS[:ownership].call(@value)
|
||||
"#{sign}#{user_label}:#{value}"
|
||||
else
|
||||
if Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY.include?(@key)
|
||||
resource_type = Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY[@key]
|
||||
|
@ -35,7 +39,6 @@ class Item
|
|||
if @key == :name
|
||||
"#{sign}#{quoted_value}"
|
||||
else
|
||||
|
||||
"#{sign}#{label}:#{quoted_value}"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -170,7 +170,8 @@ class Item
|
|||
Zone.find(id).plain_label
|
||||
},
|
||||
ownership: lambda { |owned|
|
||||
I18n.translate("items.search.labels.user_#{owned}")
|
||||
owned_key = owned ? 'owns' : 'wants'
|
||||
I18n.translate("items.search.labels.user_#{owned_key}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -243,8 +244,13 @@ class Item
|
|||
if filter_params.has_key?(:key)
|
||||
key = filter_params[:key].to_sym
|
||||
if FIELD_KEYS.include?(key)
|
||||
value = filter_params[:value]
|
||||
# Ugh, this bit feels so hacky :P
|
||||
if key == :user_closet_hanger_ownership
|
||||
value = (value == 'true')
|
||||
end
|
||||
is_positive = filter_params[:is_positive] == 'true'
|
||||
Filter.new(key, filter_params[:value], is_positive)
|
||||
Filter.new(key, value, is_positive)
|
||||
end
|
||||
end
|
||||
}.compact
|
||||
|
|
Loading…
Reference in a new issue