Improve usability of supplier selection for stock_articles in delivery form

This commit is contained in:
Julius 2013-12-09 00:03:07 +01:00
parent 7eb64e3c9d
commit 30b35cdd11
5 changed files with 50 additions and 10 deletions

View file

@ -44,7 +44,7 @@
$.ajax({ $.ajax({
url: '#{new_stock_article_path}', url: '#{new_stock_article_path}',
type: 'get', type: 'get',
data: {stock_article: {name: selectedArticle.text}}, data: {stock_article: {name: selectedArticle.text, supplier_id: #{@supplier.id}}},
contentType: 'application/json; charset=UTF-8' contentType: 'application/json; charset=UTF-8'
}); });
$('#new_stock_article').select2('data', null); $('#new_stock_article').select2('data', null);

View file

@ -1,12 +1,31 @@
// Handle more advanced DOM update after AJAX database manipulation. // Handle more advanced DOM update after AJAX database manipulation.
// See publish/subscribe design pattern in /doc. // See publish/subscribe design pattern in /doc.
(function() { (function(w) {
$('#stock_articles_for_adding tr').removeClass('success'); $('#stock_articles_for_adding tr').removeClass('success');
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'
});
}
return false;
}
// the stock_article _DOES_ belong to the current supplier
var stock_article_for_adding = $( var stock_article_for_adding = $(
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>' '<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
).addClass('success'); ).addClass('success');
$('#stock_articles_for_adding tbody').append(stock_article_for_adding); $('#stock_articles_for_adding tbody').append(stock_article_for_adding);
updateSort('#stock_articles_for_adding'); updateSort('#stock_articles_for_adding');
})(); })(window);

View file

@ -1,16 +1,35 @@
// Handle more advanced DOM update after AJAX database manipulation. // Handle more advanced DOM update after AJAX database manipulation.
// See publish/subscribe design pattern in /doc. // See publish/subscribe design pattern in /doc.
(function() { (function(w) {
// update entry in stock_article table // update entry in stock_article table
$('#stock_articles_for_adding tr').removeClass('success'); $('#stock_articles_for_adding tr').removeClass('success');
var stock_article_for_adding = $( $('#stock_article_<%= @stock_article.id %>').remove();
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
).addClass('success');
$('#stock_article_<%= @stock_article.id %>').replaceWith(stock_article_for_adding); if(<%= @supplier.id != @stock_article.supplier.id %>) {
updateSort('#stock_articles_for_adding'); // 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');
}
mark_article_for_delivery(<%= @stock_article.id %>); mark_article_for_delivery(<%= @stock_article.id %>);
@ -25,4 +44,4 @@
stock_change_entry.addClass('success'); stock_change_entry.addClass('success');
updateSort('#stock_changes'); updateSort('#stock_changes');
})(); })(window);

View file

@ -413,6 +413,7 @@ de:
actions: Optionen actions: Optionen
article: Artikel article: Artikel
category: Kategorie category: Kategorie
confirm_foreign_supplier_reedit: Der Lagerartikel »%{name}« wurde erfolgreich gespeichert. Er gehört jedoch nicht zu dem Lieferanten dieser Lieferung. Möchtest Du diesen Lagerartikel erneut bearbeiten?
create_from_blank: Ohne Vorlage anlegen create_from_blank: Ohne Vorlage anlegen
create_stock_article: Lagerartikel anlegen create_stock_article: Lagerartikel anlegen
price: Nettopreis price: Nettopreis

View file

@ -415,6 +415,7 @@ en:
actions: Tasks actions: Tasks
article: Article article: Article
category: Category category: Category
confirm_foreign_supplier_reedit: The stock article %{name} was successfully saved. However, it belongs to a different supplier than this delivery. Would you like to edit the stock article again?
create_from_blank: Create new article create_from_blank: Create new article
create_stock_article: Create stock article create_stock_article: Create stock article
price: Netprice price: Netprice