impress/app/views/items/_item_header.haml
Emi Matchu 23240005a2 Oops, fix bug that would sometimes flip own/want in the item bulk menu
If your first wanted list was created before your first owned list,
then `false` would come before `true` in the keys of
`current_user_lists`.

I both fixed this to be more consistent at the model level, because who
likes unpredictable behavior? But also downstream at the view I
hardcoded that true should come before false, because that's a UI
concern that I want to be encoded in the view regardless of what's
upstream.
2024-01-23 04:06:58 -08:00

91 lines
4.2 KiB
Text

- raise ArgumentError unless defined? item
- raise ArgumentError unless defined? trades
- raise ArgumentError unless defined? current_user_lists
- raise ArgumentError unless defined? current_user_quantities
- raise ArgumentError unless defined? current_subpage
%header.item-header
.item-header-main
= image_tag item.thumbnail_url, class: 'item-thumbnail'
%h2.item-name= item.name
%nav.item-links
- if item.nc?
%abbr.item-kind{'data-type' => 'nc', title: t('items.show.item_kinds.nc.description')}
= t('items.show.item_kinds.nc.label')
- elsif item.pb?
%abbr.item-kind{'data-type' => 'pb', title: t('items.show.item_kinds.pb.description')}
= t('items.show.item_kinds.pb.label')
- else
%abbr.item-kind{'data-type' => 'np', title: t('items.show.item_kinds.np.description')}
= t('items.show.item_kinds.np.label')
= link_to t('items.show.resources.jn_items'), jn_items_url_for(item)
- if item.nc_trade_value
= link_to t('items.show.resources.owls', value: item.nc_trade_value.value_text),
"https://www.neopets.com/~owls",
title: nc_trade_value_updated_at_text(item.nc_trade_value)
- unless item.nc?
= link_to t('items.show.resources.shop_wizard'), shop_wizard_url_for(item)
= link_to t('items.show.resources.super_shop_wizard'), super_shop_wizard_url_for(item)
= link_to t('items.show.resources.trading_post'), trading_post_url_for(item)
= link_to t('items.show.resources.auction_genie'), auction_genie_url_for(item)
- if user_signed_in?
.user-lists-section
= link_to t('items.show.closet_hangers.button'),
user_closet_hangers_path(current_user),
class: 'dialog-opener'
%dialog
%h3
= t 'items.show.closet_hangers.header_html',
user_items_link: link_to(t('your_items'),
user_closet_hangers_path(current_user))
= form_tag update_quantities_user_item_closet_hangers_path(:user_id => current_user, :item_id => item), :method => :put do
.closet-hangers-ownership-groups
- [true, false].each do |owned|
- lists = current_user_lists[owned]
%div
%h4= closet_lists_group_name(:you, owned)
%ul
- lists.each_with_index do |list, index|
%li
= number_field_tag "quantity[#{list.id}]",
current_user_quantities[list.id], min: 0,
autofocus: owned && index == 0
= label_tag "quantity[#{list.id}]", list.name
%li
= number_field_tag "quantity[#{owned}]",
current_user_quantities[owned], min: 0,
autofocus: owned && lists.empty?
- unless lists.empty?
= label_tag "quantity[#{owned}]",
t('closet_lists.unlisted_name'),
:class => 'unlisted'
- else
= label_tag "quantity[#{owned}]",
t('items.show.closet_hangers.quantity_label')
= submit_tag t('items.show.closet_hangers.submit')
%p.item-description= item.description
%nav.item-subpages-nav
= link_to t('items.show.subpages_nav.preview'), item,
class: ['preview-link'], 'data-is-current' => current_subpage == 'preview'
.trades-section
%header= t('items.show.subpages_nav.trades.header')
%ul
%li
= 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',
count: trades[:seeking].size),
item_trades_path(item, type: 'seeking'),
'data-is-current' => current_subpage == 'trades_seeking'
- content_for :javascripts do
= javascript_include_tag 'items/item_header'