diff --git a/app/helpers/items_helper.rb b/app/helpers/items_helper.rb index b5409952..28cea014 100644 --- a/app/helpers/items_helper.rb +++ b/app/helpers/items_helper.rb @@ -156,25 +156,6 @@ 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", target: "_blank", - 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 - - def dyeworks_explanation_subtitle_for(item) - base_item = item.dyeworks_base_item - content_tag :span, class: "dyeworks-explanation" do - concat link_to(base_item.name, base_item, target: "_blank") - concat " + 1 Potion" - end - end - def nc_total_for(items) items.map(&:current_nc_price).sum end diff --git a/app/views/items/_item_list_row.html.haml b/app/views/items/_item_list_row.html.haml index 09b7e52d..7e26c84f 100644 --- a/app/views/items/_item_list_row.html.haml +++ b/app/views/items/_item_list_row.html.haml @@ -1,4 +1,6 @@ -- subtitle = nil unless defined? subtitle +-# Run the block first, so we can get the subtitle content if provided! +- content = yield +- subtitle = yield :subtitle %tr %td.thumbnail-cell @@ -8,4 +10,4 @@ = link_to item.name, item, target: "_blank" - if subtitle.present? .subtitle= subtitle - %td.actions-cell= yield + %td.actions-cell= content diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index d27e0c8b..1c35d5a6 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -61,8 +61,12 @@ Buy all in NC Mall %tbody - @buyable_dyeworks_items.each do |item| - = render "item_list_row", item:, - subtitle: dyeworks_explanation_subtitle_for(item) do + = render "item_list_row", item: do + - base_item = item.dyeworks_base_item + - content_for :subtitle, flush: true do + %span.dyeworks-explanation + = link_to base_item.name, base_item, target: "_blank" + + 1 potion %button{onclick: "alert('Todo!')"} = cart_icon alt: "" Buy base (#{item.dyeworks_base_item.current_nc_price} NC) @@ -153,7 +157,12 @@ Total: #{pluralize @other_nc_items.size, "item"} %tbody - @other_nc_items.each do |item| - = render "item_list_row", item:, subtitle: nc_trade_value_subtitle_for(item) do + = render "item_list_row", item: do + - content_for :subtitle, flush: true do + - if item.nc_trade_value.present? + = link_to "Owls listing: #{item.nc_trade_value.value_text}", + "https://www.neopets.com/~owls", target: "_blank", + 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!' = button_link_to "NC Trades", item_trades_path(item, type: "offering"), target: "_blank", icon: search_icon