From 551e8941f3a864f569af7f078c0e7c41c9e1932b Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 27 May 2024 15:50:41 -0700 Subject: [PATCH] Add OWLS values to non-NC-Mall NC items in Item Getting Guide Note that there's a known performance issue here: we should try to fetch all the OWLS values at once, instead of doing them in sequence while rendering the page! --- app/assets/stylesheets/items/sources.sass | 11 +++++++++++ app/helpers/items_helper.rb | 11 +++++++++++ app/views/items/_item_header.html.haml | 2 +- app/views/items/_item_list_row.html.haml | 5 ++++- app/views/items/sources.html.haml | 2 +- 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/app/assets/stylesheets/items/sources.sass b/app/assets/stylesheets/items/sources.sass index 862778c3..8213feb0 100644 --- a/app/assets/stylesheets/items/sources.sass +++ b/app/assets/stylesheets/items/sources.sass @@ -61,6 +61,17 @@ text-wrap: balance font-style: italic + .subtitle + font-size: 85% + opacity: .85 + + a[title] + text-decoration-line: underline + text-decoration-style: dotted + + &:hover, &:focus + text-decoration-style: solid + /* For wearable items that belong to a specific set that all come together, * like a Paint Brush. */ &[data-group-type="bundle"] diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index 19f9e47a..d7f3d075 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -156,6 +156,17 @@ module ItemsHelper "Last updated: #{date_str} (#{time_ago_str} ago)" end + def nc_trade_value_subtitle_for(item) + value = item.nc_trade_value + return nil if value.nil? + + link_to "Owls listing: #{item.nc_trade_value.value_text}", + "https://www.neopets.com/~owls", + title: 'Owls keeps track of approximate "capsule" values of NC items ' + + "for trading. Items with similar values can often be traded for one " + + "another. This is an estimate, not a rule!" + end + private def build_on_pet_types(species, special_color=nil, &block) diff --git a/app/views/items/_item_header.html.haml b/app/views/items/_item_header.html.haml index d1a68f4f..62e8bb79 100644 --- a/app/views/items/_item_header.html.haml +++ b/app/views/items/_item_header.html.haml @@ -28,7 +28,7 @@ = link_to t('items.show.resources.jn_items'), jn_items_url_for(item) = link_to t('items.show.resources.impress_2020'), impress_2020_url_for(item) - if item.nc_trade_value - = link_to t('items.show.resources.owls', value: item.nc_trade_value.value_text), + = link_to t('items.show.resources.owls', value: item.nc_trade_value_text), "https://www.neopets.com/~owls", title: nc_trade_value_updated_at_text(item.nc_trade_value) - unless item.nc? diff --git a/app/views/items/_item_list_row.html.haml b/app/views/items/_item_list_row.html.haml index 35362c6d..96dc26c0 100644 --- a/app/views/items/_item_list_row.html.haml +++ b/app/views/items/_item_list_row.html.haml @@ -2,5 +2,8 @@ %td.thumbnail-cell = link_to item_thumbnail_for(item), item, target: "_blank", tabindex: "-1" - %td.name-cell= link_to item.name, item, target: "_blank" + %td.name-cell + = link_to item.name, item, target: "_blank" + - if subtitle.present? + .subtitle= subtitle %td.actions-cell= yield diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 4a2c7751..df732572 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -106,7 +106,7 @@ Total: #{pluralize @other_nc_items.size, "item"} %tbody - @other_nc_items.each do |item| - = render "item_list_row", item: do + = render "item_list_row", item:, subtitle: nc_trade_value_subtitle_for(item) do = button_link_to "NC Trades", item_trades_path(item, type: "offering"), target: "_blank", icon: search_icon