Better ordering for NC Styles in the outfit editor
Previously, when opening the pose picker and looking at Styles, the Cybunny options were sorted like this: - Default - Celebratory 25th Anniversary - Festive Christmas - Nostalgic Baby - Nostalgic Blue - Nostalgic Christmas - Nostalgic Darigan - Nostalgic Faerie - Nostalgic Grey - Nostalgic Maraquan - Nostalgic Mutant - Nostalgic Plushie - Nostalgic Robot - Nostalgic Royalboy - Nostalgic Royalgirl - Nostalgic Snow - Nostalgic Tyrannian - Prismatic Cocoa: Festive Christmas - Prismatic Cocoa: Nostalgic Christmas - Prismatic Tinsel: Festive Christmas - Prismatic Tinsel: Nostalgic Christmas - Spooky Halloween Now, they're sorted like this: - Default - Celebratory 25th Anniversary - Nostalgic Baby - Nostalgic Blue - Festive Christmas - Prismatic Cocoa: Festive Christmas - Prismatic Tinsel: Festive Christmas - Nostalgic Christmas - Prismatic Cocoa: Nostalgic Christmas - Prismatic Tinsel: Nostalgic Christmas - Nostalgic Darigan - Nostalgic Faerie - Nostalgic Grey - Spooky Halloween - Nostalgic Maraquan - Nostalgic Mutant - Nostalgic Plushie - Nostalgic Robot - Nostalgic Royalboy - Nostalgic Royalgirl - Nostalgic Snow - Nostalgic Tyrannian Note especially the Christmas case, which is all together now! I think it's also more in line with people's expectations for Halloween to be alphabetically among the rest, instead of being at the bottom for being "Spooky". There's enough styles now that I'm starting to wonder if there's other UI affordances worth having here, like e.g. only showing (or at least prioritizing) styles that match the chosen color? But I don't want to mislead people about compatibility, either.
This commit is contained in:
parent
6ced72e10a
commit
a385a5b962
2 changed files with 22 additions and 5 deletions
app
|
@ -27,8 +27,7 @@ class AltStylesController < ApplicationController
|
||||||
render
|
render
|
||||||
}
|
}
|
||||||
format.json {
|
format.json {
|
||||||
@alt_styles = @alt_styles.includes(swf_assets: [:zone]).
|
@alt_styles = @alt_styles.includes(swf_assets: [:zone]).by_name_grouped
|
||||||
sort_by(&:full_name)
|
|
||||||
render json: @alt_styles.as_json(
|
render json: @alt_styles.as_json(
|
||||||
only: [:id, :species_id, :color_id, :body_id, :series_name,
|
only: [:id, :species_id, :color_id, :body_id, :series_name,
|
||||||
:adjective_name, :thumbnail_url],
|
:adjective_name, :thumbnail_url],
|
||||||
|
|
|
@ -26,6 +26,24 @@ class AltStyle < ApplicationRecord
|
||||||
# created around midnight.
|
# created around midnight.
|
||||||
order(Arel.sql("DATE(CONVERT_TZ(created_at, '+00:00', '-08:00')) DESC"))
|
order(Arel.sql("DATE(CONVERT_TZ(created_at, '+00:00', '-08:00')) DESC"))
|
||||||
}
|
}
|
||||||
|
scope :by_series_main_name, -> {
|
||||||
|
# The main part of the series name, like "Nostalgic".
|
||||||
|
order(Arel.sql("SUBSTRING_INDEX(series_name, ': ', -1)"))
|
||||||
|
}
|
||||||
|
scope :by_series_variant_name, -> {
|
||||||
|
# The variant part of the series name, like "Prismatic Cyan".
|
||||||
|
order(Arel.sql("SUBSTRING_INDEX(series_name, ': ', 1)"))
|
||||||
|
}
|
||||||
|
scope :by_color_name, -> {
|
||||||
|
joins(:color).order(Color.arel_table[:name])
|
||||||
|
}
|
||||||
|
scope :by_name_grouped, -> {
|
||||||
|
# Sort by the color name, then the main part of the series name, then the
|
||||||
|
# variant part of the series name. This way, all the, say, Christmas colors
|
||||||
|
# and their Prismatic variants will be together, including both Festive and
|
||||||
|
# Nostalgic cases.
|
||||||
|
by_color_name.by_series_main_name.by_series_variant_name
|
||||||
|
}
|
||||||
scope :unlabeled, -> { where(series_name: nil) }
|
scope :unlabeled, -> { where(series_name: nil) }
|
||||||
scope :newest, -> { order(created_at: :desc) }
|
scope :newest, -> { order(created_at: :desc) }
|
||||||
|
|
||||||
|
@ -106,9 +124,9 @@ class AltStyle < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all_series_names
|
def self.all_series_names
|
||||||
# Sort by the part *after* the colon, then before (if any).
|
distinct.where.not(series_name: nil).
|
||||||
distinct.where.not(series_name: nil).pluck(:series_name).
|
by_series_main_name.by_series_variant_name.
|
||||||
sort_by { |series_name| series_name.split(': ', 2).reverse }
|
pluck(:series_name)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.all_supported_colors
|
def self.all_supported_colors
|
||||||
|
|
Loading…
Reference in a new issue