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_')
|
if key_str.start_with?('is_')
|
||||||
is_label = I18n.translate("items.search.flag_keywords.is")
|
is_label = I18n.translate("items.search.flag_keywords.is")
|
||||||
"#{sign}#{is_label}:#{label}"
|
"#{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
|
else
|
||||||
if Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY.include?(@key)
|
if Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY.include?(@key)
|
||||||
resource_type = Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY[@key]
|
resource_type = Query::TEXT_QUERY_RESOURCE_TYPES_BY_KEY[@key]
|
||||||
|
@ -35,7 +39,6 @@ class Item
|
||||||
if @key == :name
|
if @key == :name
|
||||||
"#{sign}#{quoted_value}"
|
"#{sign}#{quoted_value}"
|
||||||
else
|
else
|
||||||
|
|
||||||
"#{sign}#{label}:#{quoted_value}"
|
"#{sign}#{label}:#{quoted_value}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -170,7 +170,8 @@ class Item
|
||||||
Zone.find(id).plain_label
|
Zone.find(id).plain_label
|
||||||
},
|
},
|
||||||
ownership: lambda { |owned|
|
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)
|
if filter_params.has_key?(:key)
|
||||||
key = filter_params[:key].to_sym
|
key = filter_params[:key].to_sym
|
||||||
if FIELD_KEYS.include?(key)
|
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'
|
is_positive = filter_params[:is_positive] == 'true'
|
||||||
Filter.new(key, filter_params[:value], is_positive)
|
Filter.new(key, value, is_positive)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
}.compact
|
}.compact
|
||||||
|
|
Loading…
Reference in a new issue