From b9bb697ca187ba50fd4b3663583fb92a362bacf1 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Sun, 21 Jan 2024 04:45:22 -0800 Subject: [PATCH] Add trade counts to item page tab navigation --- app/views/item_trades/index.html.haml | 4 ++-- app/views/items/_item_header.haml | 7 +++++-- app/views/items/show.html.haml | 2 +- config/locales/en.yml | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/views/item_trades/index.html.haml b/app/views/item_trades/index.html.haml index 0c7d8a2e..7557585d 100644 --- a/app/views/item_trades/index.html.haml +++ b/app/views/item_trades/index.html.haml @@ -1,8 +1,8 @@ - title t(".title.#{@type}") - hide_title_header -= render partial: "items/item_header", - locals: {item: @item, current_subpage: "trades_#{@type}"} += render partial: "items/item_header", locals: {item: @item, + trades: @item_trades, current_subpage: "trades_#{@type}"} %h2.item-subpage-title= t(".title.#{@type}") diff --git a/app/views/items/_item_header.haml b/app/views/items/_item_header.haml index d93fccb1..6bf31aa2 100644 --- a/app/views/items/_item_header.haml +++ b/app/views/items/_item_header.haml @@ -1,4 +1,5 @@ - raise ArgumentError unless defined? item +- raise ArgumentError unless defined? trades - raise ArgumentError unless defined? current_subpage %header.item-header @@ -27,10 +28,12 @@ %header= t('items.show.subpages_nav.trades.header') %ul %li - = link_to t('items.show.subpages_nav.trades.offering'), + = link_to t('items.show.subpages_nav.trades.offering', + count: trades[:offering].size), item_trades_path(item, type: 'offering'), 'data-is-current' => current_subpage == 'trades_offering' %li - = link_to t('items.show.subpages_nav.trades.seeking'), + = link_to t('items.show.subpages_nav.trades.seeking', + count: trades[:offering].size), item_trades_path(item, type: 'seeking'), 'data-is-current' => current_subpage == 'trades_seeking' diff --git a/app/views/items/show.html.haml b/app/views/items/show.html.haml index 2c23282a..ad93b011 100644 --- a/app/views/items/show.html.haml +++ b/app/views/items/show.html.haml @@ -2,7 +2,7 @@ - canonical_path @item = render partial: "item_header", - locals: {item: @item, current_subpage: "preview"} + locals: {item: @item, trades: @trades, current_subpage: "preview"} %section#item-info-section #item-info diff --git a/config/locales/en.yml b/config/locales/en.yml index dd90ef76..0b6f0e54 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -330,8 +330,8 @@ en: preview: Preview trades: header: Trades - offering: Offering - seeking: Seeking + offering: Offering (%{count}) + seeking: Seeking (%{count}) preview: header: Preview customize_more: Customize more