Improve usability of supplier selection for stock_articles in delivery form
This commit is contained in:
parent
7eb64e3c9d
commit
30b35cdd11
5 changed files with 50 additions and 10 deletions
|
@ -44,7 +44,7 @@
|
|||
$.ajax({
|
||||
url: '#{new_stock_article_path}',
|
||||
type: 'get',
|
||||
data: {stock_article: {name: selectedArticle.text}},
|
||||
data: {stock_article: {name: selectedArticle.text, supplier_id: #{@supplier.id}}},
|
||||
contentType: 'application/json; charset=UTF-8'
|
||||
});
|
||||
$('#new_stock_article').select2('data', null);
|
||||
|
|
|
@ -1,12 +1,31 @@
|
|||
// Handle more advanced DOM update after AJAX database manipulation.
|
||||
// See publish/subscribe design pattern in /doc.
|
||||
(function() {
|
||||
(function(w) {
|
||||
|
||||
$('#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 = $(
|
||||
'<%= 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');
|
||||
})();
|
||||
})(window);
|
||||
|
|
|
@ -1,16 +1,35 @@
|
|||
// Handle more advanced DOM update after AJAX database manipulation.
|
||||
// See publish/subscribe design pattern in /doc.
|
||||
(function() {
|
||||
(function(w) {
|
||||
// update entry in stock_article table
|
||||
|
||||
$('#stock_articles_for_adding tr').removeClass('success');
|
||||
|
||||
var stock_article_for_adding = $(
|
||||
'<%= j(render(:partial => 'stock_article_for_adding', :locals => {:article => @stock_article})) %>'
|
||||
).addClass('success');
|
||||
$('#stock_article_<%= @stock_article.id %>').remove();
|
||||
|
||||
$('#stock_article_<%= @stock_article.id %>').replaceWith(stock_article_for_adding);
|
||||
updateSort('#stock_articles_for_adding');
|
||||
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');
|
||||
}
|
||||
|
||||
mark_article_for_delivery(<%= @stock_article.id %>);
|
||||
|
||||
|
@ -25,4 +44,4 @@
|
|||
stock_change_entry.addClass('success');
|
||||
|
||||
updateSort('#stock_changes');
|
||||
})();
|
||||
})(window);
|
||||
|
|
|
@ -413,6 +413,7 @@ de:
|
|||
actions: Optionen
|
||||
article: Artikel
|
||||
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_stock_article: Lagerartikel anlegen
|
||||
price: Nettopreis
|
||||
|
|
|
@ -415,6 +415,7 @@ en:
|
|||
actions: Tasks
|
||||
article: Article
|
||||
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_stock_article: Create stock article
|
||||
price: Netprice
|
||||
|
|
Loading…
Reference in a new issue