Compare commits
No commits in common. "341869fb177be051be5684d6b5fe583803449df4" and "e1c598e591c56a18e5ed207fadb6968ea67138e3" have entirely different histories.
341869fb17
...
e1c598e591
4 changed files with 11 additions and 28 deletions
|
@ -134,10 +134,10 @@ class ItemsController < ApplicationController
|
||||||
# Also, PB items have some special handling: we group them by color, then
|
# Also, PB items have some special handling: we group them by color, then
|
||||||
# load example pet types for the colors that don't have paint brushes.
|
# load example pet types for the colors that don't have paint brushes.
|
||||||
@pb_items_by_color = @pb_items.group_by(&:pb_color).
|
@pb_items_by_color = @pb_items.group_by(&:pb_color).
|
||||||
sort_by { |color, items| color&.name }.to_h
|
sort_by { |color, items| color.name }.to_h
|
||||||
|
|
||||||
colors_without_thumbnails = @pb_items_by_color.keys.
|
colors_without_thumbnails =
|
||||||
select(&:present?).reject(&:pb_item_thumbnail_url?)
|
@pb_items_by_color.keys.reject(&:pb_item_thumbnail_url?)
|
||||||
|
|
||||||
@pb_color_pet_types = colors_without_thumbnails.map do |color|
|
@pb_color_pet_types = colors_without_thumbnails.map do |color|
|
||||||
# Infer the ideal species from the first item we can, then try to find a
|
# Infer the ideal species from the first item we can, then try to find a
|
||||||
|
|
|
@ -21,8 +21,7 @@ class Color < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def example_pet_type(preferred_species: nil)
|
def example_pet_type(preferred_species: Species.first)
|
||||||
preferred_species ||= Species.first
|
|
||||||
pet_types.order([Arel.sql("species_id = ? DESC"), preferred_species.id],
|
pet_types.order([Arel.sql("species_id = ? DESC"), preferred_species.id],
|
||||||
"species_id ASC").first
|
"species_id ASC").first
|
||||||
end
|
end
|
||||||
|
|
|
@ -208,11 +208,7 @@ class Item < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# If this is a PB item, return the corresponding Color, inferred from the
|
# If this is a PB item, return the corresponding Color, inferred from the
|
||||||
# item name. If it's not a PB item, or we fail to infer a specific color,
|
# item name. If it's not a PB item, or we fail to infer, return nil.
|
||||||
# return nil. (This is expected to be nil for some PB items, like the "Aisha
|
|
||||||
# Collar", which belong to many colors. It can also be nil for PB items for
|
|
||||||
# new colors we haven't manually added to the database yet, or if a PB item
|
|
||||||
# is named strangely in the future.)
|
|
||||||
def pb_color
|
def pb_color
|
||||||
return nil unless pb?
|
return nil unless pb?
|
||||||
|
|
||||||
|
@ -230,10 +226,7 @@ class Item < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
# If this is a PB item, return the corresponding Species, inferred from the
|
# If this is a PB item, return the corresponding Species, inferred from the
|
||||||
# item name. If it's not a PB item, or we fail to infer a specific species,
|
# item name. If it's not a PB item, or we fail to infer, return nil.
|
||||||
# return nil. (This is not expected to be nil in general, but could be for PB
|
|
||||||
# items for new species we haven't manually added to the database yet, or if
|
|
||||||
# a PB item is named strangely in the future.)
|
|
||||||
def pb_species
|
def pb_species
|
||||||
return nil unless pb?
|
return nil unless pb?
|
||||||
normalized_name = name.downcase
|
normalized_name = name.downcase
|
||||||
|
|
|
@ -64,36 +64,27 @@
|
||||||
%table.item-list{"data-group-type": "bundle"}
|
%table.item-list{"data-group-type": "bundle"}
|
||||||
%thead
|
%thead
|
||||||
%td.thumbnail-cell
|
%td.thumbnail-cell
|
||||||
- if color&.pb_item_thumbnail_url?
|
- if color.pb_item_thumbnail_url?
|
||||||
= image_tag color.pb_item_thumbnail_url,
|
= image_tag color.pb_item_thumbnail_url,
|
||||||
alt: "Item thumbnail for #{color.pb_item_name}"
|
alt: "Item thumbnail for #{color.pb_item_name}"
|
||||||
- elsif color
|
- else
|
||||||
= image_tag pet_type_image_url(@pb_color_pet_types[color], size: :face),
|
= image_tag pet_type_image_url(@pb_color_pet_types[color], size: :face),
|
||||||
srcset: ["#{pet_type_image_url(@pb_color_pet_types[color], size: :face_2x)} 2x"],
|
srcset: ["#{pet_type_image_url(@pb_color_pet_types[color], size: :face_2x)} 2x"],
|
||||||
alt: @pb_color_pet_types[color].human_name
|
alt: @pb_color_pet_types[color].human_name
|
||||||
- else
|
|
||||||
= image_tag "https://images.neopets.com/items/starter_red_pb.gif",
|
|
||||||
alt: "Item thumbnail for Starter Red Paint Brush"
|
|
||||||
%th
|
%th
|
||||||
- if color
|
|
||||||
#{color.pb_item_name || color.name.humanize}
|
#{color.pb_item_name || color.name.humanize}
|
||||||
- else
|
|
||||||
Basic colors
|
|
||||||
(#{pluralize items.size, "item"})
|
(#{pluralize items.size, "item"})
|
||||||
%td.actions-cell
|
%td.actions-cell
|
||||||
- if color&.pb_item_name?
|
- if color.pb_item_name?
|
||||||
= button_link_to "Shops",
|
= button_link_to "Shops",
|
||||||
shop_wizard_url_for(color.pb_item_name),
|
shop_wizard_url_for(color.pb_item_name),
|
||||||
target: "_blank", icon: search_icon
|
target: "_blank", icon: search_icon
|
||||||
= button_link_to "Trades",
|
= button_link_to "Trades",
|
||||||
trading_post_url_for(color.pb_item_name),
|
trading_post_url_for(color.pb_item_name),
|
||||||
target: "_blank", icon: search_icon
|
target: "_blank", icon: search_icon
|
||||||
- elsif color
|
|
||||||
.special-color-explanation
|
|
||||||
Get via Lab Ray, morphing potions, etc.
|
|
||||||
- else
|
- else
|
||||||
.special-color-explanation
|
.special-color-explanation
|
||||||
Many colors, like Red, will grant these items.
|
Get via Lab Ray, morphing potions, etc.
|
||||||
%tbody
|
%tbody
|
||||||
- items.each do |item|
|
- items.each do |item|
|
||||||
= render "item_list_row", item:
|
= render "item_list_row", item:
|
||||||
|
|
Loading…
Reference in a new issue