forked from OpenNeo/impress
Use fits:nostalgic-faerie-draik
filter format when we can
This only *really* shows up right now in the case where you construct an Advanced Search form query (which only the wardrobe-2020 app does now, and in limited form), and we return the query back (which only gets used by the HTML view for item search, which doesn't have any way to build one of these requests against it). This is because, if you just type in `fits:alt-style-87305`, we always keep your search string the same when outputting it back to you, to avoid the weirdness of canonicalizing it and changing it up on you in surprising ways! But idk, this is just looking forward a bit, and keeping the system's semantics in place. I hope someday we can bring robust text filter and Advanced Search stuff back into the main app again, maybe!
This commit is contained in:
parent
18c7a34b8f
commit
421f2ce39f
1 changed files with 13 additions and 1 deletions
|
@ -63,6 +63,7 @@ class Item
|
||||||
is_positive ? Filter.restricts(value) : Filter.not_restricts(value)
|
is_positive ? Filter.restricts(value) : Filter.not_restricts(value)
|
||||||
when 'fits'
|
when 'fits'
|
||||||
# First, try the `fits:blue-acara` case.
|
# First, try the `fits:blue-acara` case.
|
||||||
|
# NOTE: This will also work for `fits:"usuki girl-usul"`!
|
||||||
match = value.match(/^([^-]+)-([^-]+)$/)
|
match = value.match(/^([^-]+)-([^-]+)$/)
|
||||||
if match.present?
|
if match.present?
|
||||||
color_name, species_name = match.captures
|
color_name, species_name = match.captures
|
||||||
|
@ -83,6 +84,7 @@ class Item
|
||||||
end
|
end
|
||||||
|
|
||||||
# Next, try the `fits:nostalgic-faerie-draik` case.
|
# Next, try the `fits:nostalgic-faerie-draik` case.
|
||||||
|
# NOTE: This will also work for `fits:"nostalgic-usuki girl-usul"`!
|
||||||
match = value.match(/^([^-]+)-([^-]+)-([^-]+)$/)
|
match = value.match(/^([^-]+)-([^-]+)-([^-]+)$/)
|
||||||
if match.present?
|
if match.present?
|
||||||
series_name, color_name, species_name = match.captures
|
series_name, color_name, species_name = match.captures
|
||||||
|
@ -362,8 +364,18 @@ class Item
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.alt_style_to_filter_text(alt_style)
|
def self.alt_style_to_filter_text(alt_style)
|
||||||
|
# If the real series name has been set in the database by support
|
||||||
|
# staff, use that for the canonical filter text for this alt style.
|
||||||
|
# Otherwise, represent this alt style by ID.
|
||||||
|
if alt_style.has_real_series_name?
|
||||||
|
series_name = alt_style.series_name.downcase
|
||||||
|
color_name = alt_style.color.name.downcase
|
||||||
|
species_name = alt_style.species.name.downcase
|
||||||
|
"#{series_name}-#{color_name}-#{species_name}"
|
||||||
|
else
|
||||||
"alt-style-#{alt_style.id}"
|
"alt-style-#{alt_style.id}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue