2013-12-07 16:42:25 +01:00
|
|
|
// Handle more advanced DOM update after AJAX database manipulation.
|
|
|
|
// See publish/subscribe design pattern in /doc.
|
2013-12-09 00:03:07 +01:00
|
|
|
(function(w) {
|
2013-06-26 15:16:52 +02:00
|
|
|
// update entry in stock_article table
|
|
|
|
|
2013-06-13 23:33:24 +02:00
|
|
|
$('#stock_articles_for_adding tr').removeClass('success');
|
|
|
|
|
2013-12-09 00:03:07 +01:00
|
|
|
$('#stock_article_<%= @stock_article.id %>').remove();
|
|
|
|
|
|
|
|
if(<%= @supplier.id != @stock_article.supplier.id %>) {
|
|
|
|
// the stock_article does _NOT_ belong to the current supplier
|
|
|
|
var try_again = w.confirm('<%= j(
|
|
|
|
t('deliveries.form.confirm_foreign_supplier_reedit', :name => @stock_article.name)
|
|
|
|
) %>');
|
|
|
|
|
|
|
|
if(try_again) {
|
|
|
|
$.ajax({
|
|
|
|
url: '<%= j edit_stock_article_path(@stock_article) %>',
|
|
|
|
type: 'get',
|
|
|
|
contentType: 'application/json; charset=UTF-8'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// the stock_article _DOES_ belong to the current supplier
|
|
|
|
var stock_article_for_adding = $(
|
|
|
|
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
|
|
|
|
).addClass('success');
|
|
|
|
|
|
|
|
$('#stock_articles_for_adding tbody').append(stock_article_for_adding);
|
|
|
|
updateSort('#stock_articles_for_adding');
|
|
|
|
}
|
2013-06-26 15:16:52 +02:00
|
|
|
|
2013-06-26 19:57:38 +02:00
|
|
|
mark_article_for_delivery(<%= @stock_article.id %>);
|
2013-06-13 23:33:24 +02:00
|
|
|
|
2013-06-26 15:16:52 +02:00
|
|
|
// update entry in stock_changes table
|
2013-06-13 23:33:24 +02:00
|
|
|
|
|
|
|
$('#stock_changes tr').removeClass('success');
|
|
|
|
|
|
|
|
var stock_change_entry = $('#stock_change_stock_article_<%= @stock_article.id %>');
|
|
|
|
$('.stock_article_name', stock_change_entry).text('<%= j(@stock_article.name) %>');
|
2013-07-09 17:08:59 +02:00
|
|
|
$('.unit', stock_change_entry).text('<%= j(@stock_article.unit) %>');
|
2013-06-13 23:33:24 +02:00
|
|
|
|
|
|
|
stock_change_entry.addClass('success');
|
|
|
|
|
|
|
|
updateSort('#stock_changes');
|
2013-12-09 00:03:07 +01:00
|
|
|
})(window);
|