refactor view logic to helper

This commit is contained in:
Andy Brett
2021-04-03 10:11:16 -07:00
parent 9f0f88de4e
commit f2e238d0ea
2 changed files with 9 additions and 3 deletions

View File

@@ -120,6 +120,14 @@ module Spree
method: :put, icon: "icon-#{event}",
data: { confirm: confirm_message })
end
def quantity_field_tag(manifest_item)
html_options = { min: 0, class: "line_item_quantity", size: 5 }
unless manifest_item.variant.on_demand
html_options.merge!(max: manifest_item.variant.on_hand + manifest_item.quantity)
end
number_field_tag :quantity, manifest_item.quantity, html_options
end
end
end
end

View File

@@ -14,9 +14,7 @@
= "#{count} x #{t(state.humanize.downcase, scope: [:spree, :shipment_states], default: [:missing, "none"])}"
- unless shipment.shipped?
%td.item-qty-edit.hidden
- html_options = { :min => 0, :class => "line_item_quantity", :size => 5 }
- html_options.merge!({ :max => item.variant.on_hand + item.quantity }) unless item.variant.on_demand
= number_field_tag :quantity, item.quantity, html_options
= quantity_field_tag(item)
%td.item-total.align-center
= line_item_shipment_price(line_item, item.quantity)