From 28cdef29d095a7b7496e5a6c8dfcef3ae51c7d14 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Thu, 2 Jan 2025 19:26:11 -0800 Subject: [PATCH] Combine zones with the same label on the item page For example, the "Red Knitted Beanie with Wig" occupies two different "Hat" zones: one for behind the head, and one for in front. It's not useful to split them up! --- app/controllers/items_controller.rb | 5 +++-- app/views/items/show.html.haml | 12 ++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 43384d85..179343e1 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -98,8 +98,9 @@ class ItemsController < ApplicationController @preview_error = validate_preview @all_appearances = @item.appearances - @appearances_by_occupied_zone = @item.appearances_by_occupied_zone. - sort_by { |z, a| z.label } + @appearances_by_occupied_zone_label = + @item.appearances_by_occupied_zone. + transform_keys(&:label).sort_by { |l, a| l } @selected_item_appearance = @preview_outfit.item_appearances.first @preview_pet_type_options = PetType.where(color: @preview_outfit.color). diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 3b57d896..37879734 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -64,17 +64,17 @@ .item-zones-info %section %h3 Occupies - - if @appearances_by_occupied_zone.present? + - if @appearances_by_occupied_zone_label.present? %ul - - @appearances_by_occupied_zone.each do |zone, appearances_in_zone| + - @appearances_by_occupied_zone_label.each do |label, appearances| %li< - = zone.label - - if item_zone_partial_fit? appearances_in_zone, @all_appearances + = label + - if item_zone_partial_fit? appearances, @all_appearances = " " %span.zone-species-info{ - title: item_zone_species_list(appearances_in_zone) + title: item_zone_species_list(appearances) }< - (#{appearances_in_zone.size} species) + (#{appearances.size} species) - else %span.no-zones (None)