[WV2] Add ownership and wishlist badges
Show "Own" (green) and "Want" (blue) badges on item cards when a logged-in user has items in their closet lists. Badges appear on both search results and outfit items. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
8d728c84d1
commit
ff7c590790
4 changed files with 25 additions and 0 deletions
|
|
@ -26,6 +26,16 @@
|
|||
color: #7B341E;
|
||||
}
|
||||
|
||||
&[data-item-kind="own"] {
|
||||
background: #C6F6D5;
|
||||
color: #22543D;
|
||||
}
|
||||
|
||||
&[data-item-kind="want"] {
|
||||
background: #BEE3F8;
|
||||
color: #2C5282;
|
||||
}
|
||||
|
||||
.icon {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -113,6 +113,13 @@ class WardrobeController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
# Assign closet ownership/wishlist data to all visible items
|
||||
if user_signed_in?
|
||||
all_visible_items = worn_items.to_a + closeted_items.to_a
|
||||
all_visible_items += @search_results.to_a if @search_mode
|
||||
current_user.assign_closeted_to_items!(all_visible_items)
|
||||
end
|
||||
|
||||
render layout: false
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -9,4 +9,5 @@
|
|||
= render "items/badges/kind", item: item
|
||||
- if local_assigns[:appearance]
|
||||
= render "wardrobe/items/badges/zones", appearance: appearance
|
||||
= render "wardrobe/items/badges/closet", item: item
|
||||
= render "items/badges/first_seen", item: item
|
||||
|
|
|
|||
7
app/views/wardrobe/items/badges/_closet.html.haml
Normal file
7
app/views/wardrobe/items/badges/_closet.html.haml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
- if item.owned?
|
||||
%abbr.item-badge{data: {item_kind: "own"}, title: "You own this item"}
|
||||
Own
|
||||
|
||||
- if item.wanted?
|
||||
%abbr.item-badge{data: {item_kind: "want"}, title: "You want this item"}
|
||||
Want
|
||||
Loading…
Reference in a new issue