mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
refactor view logic to helper
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user