Extract checkout select options to helpers

This commit is contained in:
Rohan Mitchell
2014-11-06 14:40:22 +11:00
parent 900a98b4bb
commit 06a9110e95
2 changed files with 10 additions and 2 deletions

View File

@@ -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 = {

View File

@@ -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