Skip to content

Commit

Permalink
On foodcoops#779 Use new received state for 'Receive' button in ord…
Browse files Browse the repository at this point in the history
…ers index

This slightly increases the performance as the associated order_articles
no longer need to be fetched.
  • Loading branch information
lentschi committed Feb 5, 2021
1 parent 64113ab commit 7952cf2
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions app/helpers/orders_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ def receive_button(order, options={})
if order.stockit?
content_tag :div, t('orders.index.action_receive'), class: "btn disabled #{options[:class]}"
else
was_received = order.order_articles.where('units_received IS NOT NULL').any?
link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless was_received} #{options[:class]}"
link_to t('orders.index.action_receive'), receive_order_path(order), class: "btn#{' btn-success' unless order.received?} #{options[:class]}"
end
end
end

0 comments on commit 7952cf2

Please sign in to comment.