Add "No data yet" to species face tooltip when needed, in item previews
This commit is contained in:
parent
4c44f8d6a4
commit
9f44fd47e4
3 changed files with 21 additions and 12 deletions
|
@ -33,7 +33,9 @@ module ItemsHelper
|
|||
def standard_species_search_links
|
||||
all_species = Species.alphabetical.map(&:id)
|
||||
PetType.random_basic_per_species(all_species).map do |pet_type|
|
||||
image = pet_type_image(pet_type, :happy, :zoom)
|
||||
human_name = pet_type.species.human_name
|
||||
image = pet_type_image pet_type, :happy, :zoom,
|
||||
alt: human_name, title: human_name
|
||||
query = "species:#{pet_type.species.name}"
|
||||
link_to(image, items_path(:q => query))
|
||||
end.join.html_safe
|
||||
|
@ -222,8 +224,16 @@ module ItemsHelper
|
|||
cookies["DTIOutfitViewerIsPlaying"] == "true"
|
||||
end
|
||||
|
||||
def item_fits?(pet_type, all_appearances)
|
||||
all_appearances.any? { |a| a.fits? pet_type }
|
||||
def item_fits?(item, pet_type)
|
||||
item.appearances.any? { |a| a.fits? pet_type }
|
||||
end
|
||||
|
||||
def species_face_tooltip(pet_type, item)
|
||||
if item_fits?(item, pet_type)
|
||||
"#{pet_type.species.human_name}"
|
||||
else
|
||||
"#{pet_type.species.human_name}: No data yet"
|
||||
end
|
||||
end
|
||||
|
||||
def item_zone_partial_fit?(appearances_in_zone, all_appearances)
|
||||
|
@ -234,12 +244,9 @@ module ItemsHelper
|
|||
appearances_in_zone.map(&:species).uniq.map(&:human_name).sort.join(", ")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def pet_type_image(pet_type, emotion, size)
|
||||
def pet_type_image(pet_type, emotion, size, **options)
|
||||
src = pet_type_image_url(pet_type, emotion:, size:)
|
||||
human_name = pet_type.species.name.humanize
|
||||
image_tag(src, :alt => human_name, :title => human_name)
|
||||
image_tag(src, **options)
|
||||
end
|
||||
|
||||
def item_header_user_lists_form_state
|
||||
|
|
|
@ -502,7 +502,7 @@ class Item < ApplicationRecord
|
|||
Appearance = Struct.new(:item, :body, :swf_assets) do
|
||||
include ActiveModel::Serializers::JSON
|
||||
delegate :present?, :empty?, to: :swf_assets
|
||||
delegate :species, :fits?, to: :body
|
||||
delegate :species, :fits?, :fits_all?, to: :body
|
||||
|
||||
def attributes
|
||||
{item:, body:, swf_assets:}
|
||||
|
|
|
@ -42,12 +42,14 @@
|
|||
"aria-hidden": true, # waits for JS to remove
|
||||
}
|
||||
- @preview_pet_type_options.each do |pet_type|
|
||||
%label
|
||||
%label{
|
||||
title: species_face_tooltip(pet_type, @item),
|
||||
}
|
||||
= radio_button_tag "species_face_id", pet_type.species_id,
|
||||
checked: pet_type == @preview_outfit.pet_type,
|
||||
disabled: !item_fits?(pet_type, @all_appearances)
|
||||
disabled: !item_fits?(@item, pet_type)
|
||||
= pet_type_image pet_type,
|
||||
item_fits?(pet_type, @all_appearances) ? :happy : :sad,
|
||||
item_fits?(@item, pet_type) ? :happy : :sad,
|
||||
:face
|
||||
|
||||
.item-zones-info
|
||||
|
|
Loading…
Reference in a new issue