Merge remote-tracking branch 'tg-x/master'

Conflicts:
	app/views/shared/_open_orders.html.haml
This commit is contained in:
wvengen 2013-12-11 22:39:37 +01:00
commit e25570d870
2 changed files with 14 additions and 5 deletions

View file

@ -7,13 +7,20 @@ module GroupOrdersHelper
}.join("\n")
end
# Returns a link to the page where a group_order can be edited.
# If the option :show is true, the link is for showing the group_order.
def link_to_ordering(order, options = {})
path = if group_order = order.group_order(current_user.ordergroup)
group_order = order.group_order(current_user.ordergroup)
path = if options[:show] and group_order
group_order_path(group_order)
elsif group_order
edit_group_order_path(group_order, :order_id => order.id)
else
new_group_order_path(:order_id => order.id)
end
link_to order.name, path, options
options.delete(:show)
name = block_given? ? yield(order, group_order) : order.name
path ? link_to(name, path, options) : name
end
# Return css class names for order result table
@ -36,4 +43,4 @@ module GroupOrdersHelper
{group_order_article: goa, quantity: quantity, tolerance: tolerance, result: result, sub_total: sub_total}
end
end
end

View file

@ -10,7 +10,7 @@
%th= heading_helper Order, :name
%th= heading_helper Order, :ends
%th= t '.who_ordered'
%th= heading_helper GroupOrder, :price
%th.numeric= heading_helper GroupOrder, :price
%tbody
- total = 0
- Order.open.each do |order|
@ -20,7 +20,9 @@
- if group_order = order.group_order(ordergroup)
- total += group_order.price
%td= "#{show_user group_order.updated_by} (#{format_time(group_order.updated_on)})"
%td.numeric= number_to_currency(group_order.price)
%td.numeric
= link_to_ordering(order, show: true) do
- number_to_currency(group_order.price)
- else
%td{:colspan => 2}
- if total > 0