Remove unpermitted parameters and javascript error in orders

This commit is contained in:
benji 2015-09-02 14:35:29 +02:00
parent 4e88be6562
commit c0fe8833fa
4 changed files with 9 additions and 7 deletions

View file

@ -41,8 +41,8 @@ disIfNec = (row) ->
$(row).find('.btn-inc').prop('disabled', counter == parseInt($(row).find('.row_counter').attr('max')))
recalculate = () ->
value = ($(row).find('.row_counter').val() * $(row).find('.price').val() for row in $('.form_row')).reduce (a, b) -> a+b
$('#order_price').val((value / 100.0).toFixed(2))
value = ($(row).val() * $(row).data('price') for row in $('.row_counter')).reduce(((a, b) -> a+b), 0)
$('#order_price').html((value / 100.0).toFixed(2))
increment = (button, n) ->
row = $(button).closest('.form_row')

View file

@ -55,3 +55,7 @@
}
}
}
#order_price {
width: 50px;
}

View file

@ -12,10 +12,8 @@
<%= content_tag :span, product.name %>
<%= content_tag :small, euro(product.price) %>
</h4>
<%= f.counter :count, min: 0, max: product.stock, skip_label: true, wrapper_class: "input-group", class: "row_counter" %>
<%= f.counter :count, min: 0, max: product.stock, skip_label: true, wrapper_class: "input-group", class: "row_counter", data: { price: f.object.product.price_cents } %>
<%= f.fields_for :product do |product| %>
<%= product.hidden_field :price_cents, class: :price %>
<%= product.hidden_field :stock, class: :stock %>
<% end %>
</div>
</div>

View file

@ -1,8 +1,8 @@
<div class="col-md-3 form_total">
<%= f.label :total_price %>
<strong>Total price</strong>
<div class="input-group">
<span class="input-group-addon">&euro;</span>
<%= f.number_field :price, disabled: true, skip_label: true, step: :any, class: 'form-control big-form-field' %>
<%= content_tag :span, "", id: "order_price", class: "input-group-addon" %>
<span class="input-group-btn">
<%= f.submit "Order!", class: "btn btn-primary big-form-button" %>
</span>