From 9733ceae250f5272fe1e10ac3fb7c71594553417 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Mon, 6 May 2024 20:37:59 -0700 Subject: [PATCH] Add bare-bones Item Getting Guide page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit TNT requested that we figure out ways to connect the dots between people's intentions on DTI to their purchases in the NC Mall. But rather than just slam ad links everywhere, our plan is to design an actually useful feature about it: the "Item Getting Guide". It'll break down items by how you can actually get them (NP economy, NC Mall, retired NC, Dyeworks, etc), and we're planning some cute actions you can take, like shortcuts for getting them onto trade wishlists or into your NC Mall cart. This is just a little demo version of the page, just breaking down items specified in the URL into NC/NP/PB! Later we'll do more granular breakdown than this, with more info and actions—and we'll also like, link to it at all, which isn't the case yet! (The main way we expect people to get here is by a "Get these items" button we'll add to the outfit editor, but there might be other paths, too.) --- app/assets/stylesheets/_items.sass | 2 +- app/controllers/items_controller.rb | 16 ++++++++++++++++ app/models/item.rb | 4 ++++ app/views/items/sources.html.haml | 14 ++++++++++++++ config/routes.rb | 1 + 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 app/views/items/sources.html.haml diff --git a/app/assets/stylesheets/_items.sass b/app/assets/stylesheets/_items.sass index 71aeadde..1083a4db 100644 --- a/app/assets/stylesheets/_items.sass +++ b/app/assets/stylesheets/_items.sass @@ -1,6 +1,6 @@ @import "partials/campaign-progress" -body.items, body.item_trades +body.items-index, body.items-show, body.items-needed, body.item_trades +campaign-progress text-align: center diff --git a/app/controllers/items_controller.rb b/app/controllers/items_controller.rb index 9b59e604..f41d3445 100644 --- a/app/controllers/items_controller.rb +++ b/app/controllers/items_controller.rb @@ -112,6 +112,22 @@ class ItemsController < ApplicationController end end + def sources + item_ids = params[:ids].split(",") + @items = Item.where(id: item_ids).order(:name) + + if @items.empty? + render file: "public/404.html", status: :not_found, layout: nil + return + end + + @nc_items = @items.select(&:nc?) + @np_items = @items.select(&:np?) + @pb_items = @items.select(&:pb?) + + render layout: "application" + end + protected def assign_closeted! diff --git a/app/models/item.rb b/app/models/item.rb index 582d9e0b..6db92d53 100644 --- a/app/models/item.rb +++ b/app/models/item.rb @@ -158,6 +158,10 @@ class Item < ApplicationRecord I18n.with_locale(:en) { self.description == PAINTBRUSH_SET_DESCRIPTION } end + def np? + !nc? && !pb? + end + def owned? @owned || false end diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml new file mode 100644 index 00000000..0fe98f94 --- /dev/null +++ b/app/views/items/sources.html.haml @@ -0,0 +1,14 @@ +- title "Item Getting Guide" +%h1#title Item Getting Guide + +- if @nc_items.present? + %h2 Neocash items + = render @nc_items + +- if @np_items.present? + %h2 Neopoint items + = render @np_items + +- if @pb_items.present? + %h2 Paintbrush items + = render @pb_items diff --git a/config/routes.rb b/config/routes.rb index 240cf790..96a62347 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -27,6 +27,7 @@ OpenneoImpressItems::Application.routes.draw do collection do get :needed + get "sources/:ids", action: :sources end end resources :species, only: [] do