[WV2] Add Phase 2 implementation plan

This commit is contained in:
Emi Matchu 2026-02-15 19:53:23 -08:00
parent d4e2f1c1d8
commit d02afd87e8

View file

@ -93,3 +93,110 @@ Feature parity with Wardrobe 2020 where valuable.
- [Impress 2020 Dependencies](./impress-2020-dependencies.md) - What still depends on the Impress 2020 service
- [Customization Architecture](./customization-architecture.md) - Data model deep dive
- Wardrobe 2020 source: `app/javascript/wardrobe-2020/` (the authoritative reference for feature parity comparisons)
---
# Phase 2 Development Plan
## Commit 1: [WV2] Add item info links
Add a link on each item card that opens the item's detail page.
Files to modify:
- app/views/wardrobe/items/_item_card_content.html.haml — Add info link
- app/assets/stylesheets/wardrobe/show.css — Style it
Approach:
- Add link_to to /items/:id with an info icon/emoji, target: "_blank"
- Style: subtle, visible on hover/focus-within, always visible on touch (@media (hover: none))
## Commit 2: [WV2] Add zone badges to search results
Show which zones each item occupies in search result cards.
Files to modify:
- app/views/wardrobe/items/_item_card_content.html.haml — Conditionally render zone badges
- app/views/wardrobe/items/badges/_zones.html.haml (new partial) — Render zone label badges
- app/assets/stylesheets/wardrobe/show.css — Style zone badges (muted, small)
- app/controllers/wardrobe_controller.rb — Load item appearances for search results so zone data is available
Approach:
- Only show zone badges in search results (not outfit items, where the zone group header provides context)
- Pass a local variable (e.g. show_zones: true) from the search results template to item_card_content
- Use Item.appearances_for(items, pet_type) to batch-load appearances for search result items
- Render each item's occupied zone labels as small badges
- Zone data comes from the item's SwfAsset layers for the current pet's body_id
Design decision: Zone badges are omitted from outfit items. When an item occupies multiple zones, the outfit view shows it under multiple zone group headers, which is sufficient context. The rare case
where it could be misleading (e.g., item occupies Background+Foreground but only Background has conflicts) is niche enough to accept for now.
## Commit 3: [WV2] Add ownership and wishlist badges
Show "Own" / "Want" badges when a logged-in user has items in their closet lists.
Files to modify:
- app/controllers/wardrobe_controller.rb — Call assign_closeted_to_items! on all visible items
- app/views/wardrobe/items/badges/_closet.html.haml (new partial) — Own/Want badges
- app/views/wardrobe/items/_item_card_content.html.haml — Include closet badge partial
- app/assets/stylesheets/wardrobe/show.css or app/assets/stylesheets/application/item-badges.css — Badge colors
Approach:
- In controller: current_user.assign_closeted_to_items!(all_items) if user_signed_in? where all_items is the combined set of worn + closeted + search result items
- Badge partial: green "Own" badge if item.owned?, blue "Want" badge if item.wanted?
- No badges when not logged in
Existing code to reuse:
- User#assign_closeted_to_items! (app/models/user.rb:163)
- Badge styling patterns from app/assets/stylesheets/application/item-badges.css
## Commit 4: [WV2] Switch search to text-based filter syntax
Replace the structured search filter approach with from_text(), enabling the full search syntax (is:nc, occupies:background, user:owns, etc.) in a single text field.
Files to modify:
- app/controllers/wardrobe_controller.rb — Replace build_search_filters + from_params with from_text + auto-fit merge
- app/views/wardrobe/show.html.haml — Update search form to single q text param, update placeholder
Approach:
- Change the search form from q[name] to a single q string param
- Controller search logic:
@query = Item::Search::Query.from_text(params[:q], current_user)
results = @query.results
body_id = @outfit.alt_style&.body_id || @outfit.pet_type&.body_id
results = results.merge(Item.fits(body_id)) if body_id
@search_results = results.paginate(page: params[:page], per_page: 30)
- Remove build_search_filters method entirely
- Auto-fit filter applied at controller level via .merge(Item.fits(body_id)), completely separate from user's search text
- Handle Item::Search::Error gracefully (render error message in search results area)
- Update placeholder: "Search items… (try is:nc, occupies:hat, user:owns)"
- Update @search_mode to check params[:q].present? as a string
- Update pagination param from q[page] to page
## Commit 5: [WV2] Improve pagination with page dropdown
Replace will_paginate's view helpers with a custom prev/next + page dropdown control.
Files to modify:
- app/views/wardrobe/items/_search_results.html.haml — Replace will_paginate calls
- app/views/wardrobe/items/_pagination.html.haml (new partial) — Custom pagination UI
- app/assets/stylesheets/wardrobe/show.css — Style pagination bar
Approach:
- Layout: [← Prev] [Page <select> of N] [Next →]
- The <select> is inside an <auto-submit-form> for JS-enhanced page switching
- Prev/Next are regular links (work without JS)
- Without JS: select has a "Go" submit button (hidden when JS active via auto-submit-form:defined)
- Use will_paginate's collection methods (.current_page, .total_pages, .previous_page, .next_page) — keep .paginate() in controller, just replace the view rendering
- Single pagination bar (top of results, remove bottom duplicate)
## Verification
Test at localhost:3000/wardrobe/v2:
1. Info links: Hover over item cards → info link appears → click opens /items/:id in new tab
2. Zone badges: Search for items → results show zone badges (e.g., "Background", "Hat"). Outfit items do NOT show zone badges.
3. Ownership badges: Log in (test/test123) → search → items in closet show "Own"/"Want" badges. Log out → no badges.
4. Search syntax: Type is:nc sword → NC items matching "sword". Try occupies:background, user:owns, -is:pb, "exact phrase"
5. Search errors: Type user:owns when not logged in → friendly error. Type occupies:nonsense → friendly error.
6. Pagination: Search with many results → prev/next + page dropdown → select a page → navigates there