Add basic zone info to simpler item previews

We're missing the feature where we enumerate the exact species in
ambiguous cases, though!
This commit is contained in:
Emi Matchu 2024-08-31 13:07:18 -07:00
parent 5cbab5a766
commit bd62476722
3 changed files with 43 additions and 1 deletions

View file

@ -160,3 +160,26 @@ body.items-show
select
border-color: $error-border-color
color: $error-color
.item-zones-info
margin-top: .5em
h3
display: inline
font: inherit
font-weight: bold
&:after
content: ": "
ul
list-style-type: none
display: inline
li
display: inline
&:not(:last-of-type):after
content: ", "
.no-zones
font-style: italic
opacity: .85

View file

@ -287,7 +287,7 @@ class Item < ApplicationRecord
options[:scope] ||= Zone.all
all_body_ids = []
zone_body_ids = {}
selected_assets = swf_assets.select('body_id, zone_id').each do |swf_asset|
selected_assets = swf_assets.each do |swf_asset|
zone_body_ids[swf_asset.zone_id] ||= []
body_ids = zone_body_ids[swf_asset.zone_id]
body_ids << swf_asset.body_id unless body_ids.include?(swf_asset.body_id)

View file

@ -33,6 +33,25 @@
"id", "human_name", @selected_preview_pet_type.species_id)
= submit_tag "Go", name: nil
.item-zones-info
%section
%h3 Occupies
- if @item.occupied_zones.present?
%ul
- @item.occupied_zones.sort_by(&:label).each do |zone|
%li= zone.label
- else
%span.no-zones (None)
%section
%h3 Restricts
- if @item.restricted_zones.present?
%ul
- @item.restricted_zones.sort_by(&:label).each do |zone|
%li= zone.label
- else
%span.no-zones (None)
- unless @contributors_with_counts.empty?
#item-contributors
%header #{t '.contributors.header'}: