From 39c05b8dac7492e4e0c46a3c18154a358730aa42 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Tue, 21 May 2024 18:48:29 -0700 Subject: [PATCH] Refactor Item Getting Guide table rows to use a shared template I'm gonna add more stuff like linking to the item page and stuff, and that's starting to get complex enough to not want to repeat myself! --- app/views/items/_item_list_row.html.haml | 4 ++++ app/views/items/sources.html.haml | 24 +++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) create mode 100644 app/views/items/_item_list_row.html.haml diff --git a/app/views/items/_item_list_row.html.haml b/app/views/items/_item_list_row.html.haml new file mode 100644 index 00000000..6cf4f321 --- /dev/null +++ b/app/views/items/_item_list_row.html.haml @@ -0,0 +1,4 @@ +%tr + %td.thumbnail-cell= item_thumbnail_for(item) + %td= item.name + %td.actions-cell= yield diff --git a/app/views/items/sources.html.haml b/app/views/items/sources.html.haml index 73bf2ed7..4e523423 100644 --- a/app/views/items/sources.html.haml +++ b/app/views/items/sources.html.haml @@ -24,13 +24,10 @@ Buy all in NC Mall %tbody - @nc_mall_items.each do |item| - %tr - %td.thumbnail-cell= item_thumbnail_for(item) - %td= item.name - %td.actions-cell - %button{onclick: "alert('Todo!')"} - = cart_icon alt: "" - Buy (#{item.current_nc_price} NC) + = render "item_list_row", item: do + %button{onclick: "alert('Todo!')"} + = cart_icon alt: "" + Buy (#{item.current_nc_price} NC) - if @np_items.present? %h2 Neopoint items @@ -50,14 +47,11 @@ Total: #{pluralize @np_items.size, "item"} %tbody - @np_items.each do |item| - %tr - %td.thumbnail-cell= item_thumbnail_for(item) - %td= item.name - %td.actions-cell - = button_link_to "Shops", shop_wizard_url_for(item), - target: "_blank", icon: search_icon - = button_link_to "Trades", trading_post_url_for(item), - target: "_blank", icon: search_icon + = render "item_list_row", item: do + = button_link_to "Shops", shop_wizard_url_for(item), + target: "_blank", icon: search_icon + = button_link_to "Trades", trading_post_url_for(item), + target: "_blank", icon: search_icon - if @pb_items.present? %h2 Paintbrush items