diff --git a/app/controllers/wardrobe_controller.rb b/app/controllers/wardrobe_controller.rb index bff57393..30bbadf0 100644 --- a/app/controllers/wardrobe_controller.rb +++ b/app/controllers/wardrobe_controller.rb @@ -105,6 +105,12 @@ class WardrobeController < ApplicationController ) @query = Item::Search::Query.from_params(query_params, current_user) @search_results = @query.results.paginate(page: params.dig(:q, :page), per_page: 30) + + # Load appearances for search results to get zone information + target = @alt_style || @pet_type + if target + @appearances_by_item_id = Item.appearances_for(@search_results, target, swf_asset_includes: [:zone]) + end end render layout: false diff --git a/app/views/wardrobe/items/_item_card.html.haml b/app/views/wardrobe/items/_item_card.html.haml index 73691680..dab6bd2f 100644 --- a/app/views/wardrobe/items/_item_card.html.haml +++ b/app/views/wardrobe/items/_item_card.html.haml @@ -4,11 +4,11 @@ - if defined?(zone_id) && zone_id %label.item-card-label %input.visually-hidden{type: "radio", name: "zone_#{zone_id}", checked: is_worn || nil, "aria-label": item.name} - = render "wardrobe/items/item_card_content", item: item + = render "wardrobe/items/item_card_content", item: item, appearance: local_assigns[:appearance] - else %label.item-card-label %input.visually-hidden{type: "checkbox", checked: is_worn || nil, "aria-label": item.name} - = render "wardrobe/items/item_card_content", item: item + = render "wardrobe/items/item_card_content", item: item, appearance: local_assigns[:appearance] - if is_worn = button_to @wardrobe_path, method: :get, class: "item-hide-button", title: "Hide #{item.name}", "aria-label": "Hide #{item.name}" do đŸ‘ī¸â€đŸ—¨ī¸ diff --git a/app/views/wardrobe/items/_item_card_content.html.haml b/app/views/wardrobe/items/_item_card_content.html.haml index 284498a3..2ff1cc03 100644 --- a/app/views/wardrobe/items/_item_card_content.html.haml +++ b/app/views/wardrobe/items/_item_card_content.html.haml @@ -7,4 +7,6 @@ %span{aria: {label: "Item info"}} â„šī¸ .item-badges = render "items/badges/kind", item: item + - if local_assigns[:appearance] + = render "wardrobe/items/badges/zones", appearance: appearance = render "items/badges/first_seen", item: item diff --git a/app/views/wardrobe/items/_search_results.html.haml b/app/views/wardrobe/items/_search_results.html.haml index 45352010..00d3f0d9 100644 --- a/app/views/wardrobe/items/_search_results.html.haml +++ b/app/views/wardrobe/items/_search_results.html.haml @@ -4,7 +4,8 @@ %ul.search-results-list - @search_results.each do |item| - = render "items/item_card", item: item + - appearance = @appearances_by_item_id&.dig(item.id) + = render "items/item_card", item: item, appearance: appearance = will_paginate @search_results, param_name: "q[page]", params: @outfit.wardrobe_params.merge(q: params[:q]) diff --git a/app/views/wardrobe/items/badges/_zones.html.haml b/app/views/wardrobe/items/badges/_zones.html.haml new file mode 100644 index 00000000..6c25671d --- /dev/null +++ b/app/views/wardrobe/items/badges/_zones.html.haml @@ -0,0 +1,4 @@ +- if local_assigns[:appearance] && appearance.present? + - zones = appearance.swf_assets.map(&:zone).uniq.sort_by(&:label) + - zones.each do |zone| + %span.item-badge= zone.label