mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Extract checkout select options to helpers
This commit is contained in:
@@ -25,6 +25,14 @@ module CheckoutHelper
|
||||
order.display_item_total.money.to_f + checkout_adjustments_total(order).money.to_f
|
||||
end
|
||||
|
||||
def checkout_state_options
|
||||
[[]] + @order.billing_address.country.states.map { |c| [c.name, c.id] }
|
||||
end
|
||||
|
||||
def checkout_country_options
|
||||
available_countries.map { |c| [c.name, c.id] }
|
||||
end
|
||||
|
||||
|
||||
def validated_input(name, path, args = {})
|
||||
attributes = {
|
||||
|
||||
@@ -39,13 +39,13 @@
|
||||
= validated_input "City", "order.bill_address.city"
|
||||
|
||||
.small-6.columns
|
||||
= validated_select "State", "order.bill_address.state_id", [[]]+@order.billing_address.country.states.map{|c|[c.name, c.id]}
|
||||
= validated_select "State", "order.bill_address.state_id", checkout_state_options
|
||||
.row
|
||||
.small-6.columns
|
||||
= validated_input "Postcode", "order.bill_address.zipcode"
|
||||
|
||||
.small-6.columns.right
|
||||
= ba.select :country_id, available_countries.map{|c|[c.name, c.id]},
|
||||
= ba.select :country_id, checkout_country_options,
|
||||
"ng-model" => "order.bill_address.country_id", required: true
|
||||
|
||||
.row
|
||||
|
||||
Reference in New Issue
Block a user