From bd6247672257a9bc8b44577b704c8d7f262a3346 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sat, 31 Aug 2024 13:07:18 -0700 Subject: [PATCH] Add basic zone info to simpler item previews We're missing the feature where we enumerate the exact species in ambiguous cases, though! --- app/assets/stylesheets/items/_show.sass | 23 +++++++++++++++++++++++ app/models/item.rb | 2 +- app/views/items/show.html.haml | 19 +++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/items/_show.sass b/app/assets/stylesheets/items/_show.sass index f9a07739..1eb0500a 100644 --- a/app/assets/stylesheets/items/_show.sass +++ b/app/assets/stylesheets/items/_show.sass @@ -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 diff --git a/app/models/item.rb b/app/models/item.rb index 2eb2aa31..28660e96 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -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) diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index dbdc788e..bf40971c 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -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'}: