Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' into 0_7_x

  • Loading branch information...
commit e012d4cbcb50aa6b6b81c3027d3fe1b341c08868 2 parents 09a448f + 7136a4e
@schof schof authored
View
13 app/controllers/checkout_controller.rb
@@ -60,22 +60,9 @@ def require_user_account
private
- # switch state info into name if the id isn't a valid state
- def fix_address_states(params)
- unless State.find_by_id(params[:bill_address_state_id])
- params[:bill_address_state_name] = params[:bill_address_state_id]
- params.delete :bill_address_state_id
- end
- unless State.find_by_id(params[:ship_address_state_id])
- params[:ship_address_state_name] = params[:ship_address_state_id]
- params.delete :ship_address_state_id
- end
- end
-
def build_object
@order = Order.find_by_number(params[:order_number])
if params[:checkout_presenter]
- fix_address_states params[:checkout_presenter]
@object ||= end_of_association_chain.send parent? ? :build : :new, params[:checkout_presenter]
else
# user has not yet submitted checkout parameters, we can use defaults of current_user and order objects
View
14 public/javascripts/checkout.js
@@ -67,9 +67,19 @@ var get_states = function() {
// {name,id} attributes over, returning the new child
var chg_state_input_element = function (parent, html) {
var child = parent.find(':only-child');
+ var name = child.attr('name');
+ var id = child.attr('id');
+ //Toggle back and forth between id and name
+ if(html.attr('type') == 'text' && child.attr('type') != 'text') {
+ name = name.replace('_id', '_name');
+ id = id.replace('_id', '_name');
+ } else if(html.attr('type') != 'text' && child.attr('type') == 'text') {
+ name = name.replace('_name', '_id');
+ id = id.replace('_name', '_id');
+ }
html.addClass('required')
- .attr('name', child.attr('name'))
- .attr('id', child.attr('id'));
+ .attr('name', name)
+ .attr('id', id);
child.remove(); // better as parent-relative?
parent.append(html);
return html;
Please sign in to comment.
Something went wrong with that request. Please try again.