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
|
def standard_species_search_links
|
||||||
all_species = Species.alphabetical.map(&:id)
|
all_species = Species.alphabetical.map(&:id)
|
||||||
PetType.random_basic_per_species(all_species).map do |pet_type|
|
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}"
|
query = "species:#{pet_type.species.name}"
|
||||||
link_to(image, items_path(:q => query))
|
link_to(image, items_path(:q => query))
|
||||||
end.join.html_safe
|
end.join.html_safe
|
||||||
|
@ -222,8 +224,16 @@ module ItemsHelper
|
||||||
cookies["DTIOutfitViewerIsPlaying"] == "true"
|
cookies["DTIOutfitViewerIsPlaying"] == "true"
|
||||||
end
|
end
|
||||||
|
|
||||||
def item_fits?(pet_type, all_appearances)
|
def item_fits?(item, pet_type)
|
||||||
all_appearances.any? { |a| a.fits? 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
|
end
|
||||||
|
|
||||||
def item_zone_partial_fit?(appearances_in_zone, all_appearances)
|
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(", ")
|
appearances_in_zone.map(&:species).uniq.map(&:human_name).sort.join(", ")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def pet_type_image(pet_type, emotion, size, **options)
|
||||||
|
|
||||||
def pet_type_image(pet_type, emotion, size)
|
|
||||||
src = pet_type_image_url(pet_type, emotion:, size:)
|
src = pet_type_image_url(pet_type, emotion:, size:)
|
||||||
human_name = pet_type.species.name.humanize
|
image_tag(src, **options)
|
||||||
image_tag(src, :alt => human_name, :title => human_name)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def item_header_user_lists_form_state
|
def item_header_user_lists_form_state
|
||||||
|
|
|
@ -502,7 +502,7 @@ class Item < ApplicationRecord
|
||||||
Appearance = Struct.new(:item, :body, :swf_assets) do
|
Appearance = Struct.new(:item, :body, :swf_assets) do
|
||||||
include ActiveModel::Serializers::JSON
|
include ActiveModel::Serializers::JSON
|
||||||
delegate :present?, :empty?, to: :swf_assets
|
delegate :present?, :empty?, to: :swf_assets
|
||||||
delegate :species, :fits?, to: :body
|
delegate :species, :fits?, :fits_all?, to: :body
|
||||||
|
|
||||||
def attributes
|
def attributes
|
||||||
{item:, body:, swf_assets:}
|
{item:, body:, swf_assets:}
|
||||||
|
|
|
@ -42,12 +42,14 @@
|
||||||
"aria-hidden": true, # waits for JS to remove
|
"aria-hidden": true, # waits for JS to remove
|
||||||
}
|
}
|
||||||
- @preview_pet_type_options.each do |pet_type|
|
- @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,
|
= radio_button_tag "species_face_id", pet_type.species_id,
|
||||||
checked: pet_type == @preview_outfit.pet_type,
|
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,
|
= pet_type_image pet_type,
|
||||||
item_fits?(pet_type, @all_appearances) ? :happy : :sad,
|
item_fits?(@item, pet_type) ? :happy : :sad,
|
||||||
:face
|
:face
|
||||||
|
|
||||||
.item-zones-info
|
.item-zones-info
|
||||||
|
|
Loading…
Reference in a new issue