From a007479f99345d1cf13e48a458a532fc8fe1bb78 Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 9 Jul 2024 13:30:28 -0700 Subject: [PATCH] Link to the NC Mall homepage from the Shopping List We were previously planning a more interesting "Add to Cart" integration with TNT, but it hasn't panned out! For now, we'll just link to the NC Mall homepage. --- app/helpers/application_helper.rb | 16 ++++++++++++++-- app/views/items/sources.html.haml | 20 ++++++++++---------- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 01cd3d9c..3ec615ff 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -21,12 +21,24 @@ module ApplicationHelper end end - def button_link_to(content, url, icon: nil, **options) + def button_link_to(content_or_url, url = nil, icon: nil, **options) + if url.present? + content = content_or_url + url = url + else + content = nil + url = content_or_url + end + klass = options.fetch(:class, "") + " button" link_to url, class: klass, **options do concat icon concat " " - concat content + if block_given? + yield + else + concat content + end end end diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index fe854b66..9e6f51e5 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -27,16 +27,16 @@ %td.actions-cell - if @items_needed[:nc_mall].present? - %button{ - onclick: "alert('Todo!')", - data: {"action-kind": "bulk-nc-mall"}, - } + = button_link_to "https://ncmall.neopets.com/", + target: "_blank", + data: {"action-kind": "bulk-nc-mall"} do = cart_icon alt: "" Buy all in NC Mall %tbody - @items[:nc_mall].each do |item| = render "item_list_row", item: do - %button{onclick: "alert('Todo!')"} + = button_link_to "https://ncmall.neopets.com/", + target: "_blank" do = cart_icon alt: "" Buy (#{item.current_nc_price} NC) @@ -74,10 +74,9 @@ (~#{dyeworks_estimated_potions_cost_for @items_needed[:dyeworks]} NC) %td.actions-cell - if @items_needed[:dyeworks].present? - %button{ - onclick: "alert('Todo!')", - data: {"action-kind": "bulk-nc-mall"}, - } + = button_link_to "https://ncmall.neopets.com/", + target: "_blank", + data: {"action-kind": "bulk-nc-mall"} do = cart_icon alt: "" Buy all in NC Mall %tbody @@ -112,7 +111,8 @@ } (Limited-time) - %button{onclick: "alert('Todo!')"} + = button_link_to "https://ncmall.neopets.com/", + target: "_blank" do = cart_icon alt: "" Buy base (#{item.dyeworks_base_item.current_nc_price} NC)