foodsoft/app/views/deliveries/add_stock_change.js.erb

25 lines
963 B
Text
Raw Normal View History

2013-06-26 15:16:52 +02:00
(function(w) {
if(is_article_unavailable_for_delivery(<%= @stock_change.stock_article.id %>)) {
return false;
}
mark_article_unavailable_for_delivery(<%= @stock_change.stock_article.id %>);
2013-06-26 15:16:52 +02:00
var quantity = w.prompt('<%= j(t('.how_many_units', :unit => @stock_change.stock_article.unit, :name => @stock_change.stock_article.name)) %>'); <%# how to properly escape here? %>
if(null === quantity) {
unmark_article_unavailable_for_delivery(<%= @stock_change.stock_article.id %>); // think wisely before changing this: What about double clicks on "deliver" button?
return false;
}
$('#stock_changes tr').removeClass('success');
var stock_change = $(
'<%= j(render(:partial => 'stock_change', :locals => {:stock_change => @stock_change})) %>'
).addClass('success');
$('input.stock-change-quantity', stock_change).val(quantity);
$('#stock_changes').append(stock_change);
updateSort('#stock_changes');
})(window);