Merge price columns in receive form into one

Conflicts:
	app/views/orders/_edit_amount.html.haml
This commit is contained in:
Julius 2014-01-02 21:59:08 +01:00 committed by wvengen
parent 0af8a065a1
commit f230d39055
3 changed files with 24 additions and 22 deletions

View file

@ -35,6 +35,11 @@ module OrdersHelper
end
end
def article_price_change_hint(order_article)
return nil if order_article.article.price == order_article.article_price.price
"<i class='icon icon-asterisk' title='#{j t('.old_price', default: 'Old price')}: #{number_to_currency order_article.article.price}'></i>".html_safe
end
def receive_input_field(form)
order_article = form.object
units_expected = (order_article.units_billed or order_article.units_to_order)

View file

@ -7,7 +7,9 @@
%td= order_article.article.order_number
%td.name{title: order_title.join("\n")}= order_article.article.name
%td.unit= order_article.article.unit
%td.article_price= number_to_currency order_article.article.price
%td.article_price
= number_to_currency order_article.article.price
= article_price_change_hint(order_article)
%td #{order_article.quantity} + #{order_article.tolerance}
%td
= order_article.units_to_order
@ -16,7 +18,7 @@
- unless order_article.units_billed.nil?
= order_article.units_billed
= pkg_helper order_article.article
%td
%td.units_received_cell
= receive_input_field(form)
= pkg_helper order_article.article_price, false
- if order_article.result_manually_changed?

View file

@ -1,30 +1,25 @@
// Handle more advanced DOM update after AJAX database manipulation.
// See publish/subscribe design pattern in /doc.
(function(w) {
var order_article_entry = $('#order_article_<%= @order_article.id %>');
// get old element and update the cell which is reused
var old_order_article_entry = $('#order_article_<%= @order_article.id %>');
$('.name', order_article_entry).text(
'<%= j @order_article.article.name %>'
);
$('.unit', order_article_entry).text(
'<%= j @order_article.article.unit %>'
);
$('.article_unit_quantity', order_article_entry).text(
'(× <%= @order_article.article.unit_quantity %>)'
);
$('.article_price', order_article_entry).text(
'<%= j number_to_currency @order_article.article.price %>'
);
$('.article_price_unit_quantity', order_article_entry).text(
$('.article_price_unit_quantity', old_order_article_entry).text(
'(× <%= @order_article.article_price.unit_quantity %>)'
);
$('.article_price_price', order_article_entry).text(
'<%= j number_to_currency @order_article.article_price.price %>'
// render new element and inject dynamic cell
var new_order_article_entry = $(
'<%= j render(partial: 'edit_amount', locals: {order_article: @order_article}) %>'
);
$('td.units_received_cell', new_order_article_entry).replaceWith(
$('td.units_received_cell', old_order_article_entry)
);
// finally replace the OrderArticle entry
old_order_article_entry.replaceWith(new_order_article_entry);
update_delta($('input.units_received', new_order_article_entry));
})(window);