Only show *relevant* colors in Alt Styles filters
That is, there is no 8-bit alt style, so don't bother including it in the filter form; same for most other colors.
This commit is contained in:
parent
a99fb3ec02
commit
86e1f31231
2 changed files with 11 additions and 4 deletions
|
@ -1,15 +1,22 @@
|
|||
class AltStylesController < ApplicationController
|
||||
def index
|
||||
@alt_styles = AltStyle.includes(:species, :color, :swf_assets).
|
||||
@all_alt_styles = AltStyle.includes(:species, :color).
|
||||
order(:species_id, :color_id)
|
||||
|
||||
@all_colors = @all_alt_styles.map(&:color).uniq.sort_by(&:name)
|
||||
@all_species = @all_alt_styles.map(&:species).uniq.sort_by(&:name)
|
||||
|
||||
@all_color_names = @all_colors.map(&:human_name)
|
||||
@all_species_names = @all_species.map(&:human_name)
|
||||
|
||||
@color = find_color
|
||||
@species = find_species
|
||||
|
||||
@alt_styles = @all_alt_styles.includes(:swf_assets)
|
||||
@alt_styles.merge!(@color.alt_styles) if @color
|
||||
@alt_styles.merge!(@species.alt_styles) if @species
|
||||
|
||||
# We're going to link to the HTML5 image URL, so make sure we have all the
|
||||
# We're using the HTML5 image for our preview, so make sure we have all the
|
||||
# manifests ready!
|
||||
SwfAsset.preload_manifests @alt_styles.map(&:swf_assets).flatten
|
||||
|
||||
|
|
|
@ -18,9 +18,9 @@
|
|||
class: "rainbow-pool-filters" do |f|
|
||||
%fieldset
|
||||
%legend Filter by:
|
||||
= f.select :color, Color.order(:name).map(&:human_name),
|
||||
= f.select :color, @all_color_names,
|
||||
selected: @color&.human_name, include_blank: "Color…"
|
||||
= f.select :species, Species.order(:name).map(&:human_name),
|
||||
= f.select :species, @all_species_names,
|
||||
selected: @species&.human_name, include_blank: "Species…"
|
||||
= f.submit "Go"
|
||||
|
||||
|
|
Loading…
Reference in a new issue