Show receive button in grey when already received
This commit is contained in:
parent
7974d2ec81
commit
bc1eb3bc44
3 changed files with 16 additions and 4 deletions
|
@ -139,4 +139,18 @@ module OrdersHelper
|
||||||
'unavailable'
|
'unavailable'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Button for receiving an order.
|
||||||
|
# If the order hasn't been received before, the button is shown in green.
|
||||||
|
# @param order [Order]
|
||||||
|
# @option options [String] :class Classes added to the button's class attribute.
|
||||||
|
# @return [String] Order receive button.
|
||||||
|
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]}"
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -54,8 +54,7 @@
|
||||||
%td= truncate(order.note)
|
%td= truncate(order.note)
|
||||||
%td
|
%td
|
||||||
- unless order.stockit?
|
- unless order.stockit?
|
||||||
-# TODO btn-success class only if not received before
|
= receive_button order
|
||||||
= link_to t('.action_receive'), receive_order_path(order), class: 'btn btn-small btn-success'
|
|
||||||
|
|
||||||
%td
|
%td
|
||||||
= link_to t('ui.copy'), new_order_path(order_id: order, supplier_id: order.supplier), class: 'btn btn-small'
|
= link_to t('ui.copy'), new_order_path(order_id: order, supplier_id: order.supplier), class: 'btn btn-small'
|
||||||
|
|
|
@ -64,8 +64,7 @@
|
||||||
data: {confirm: t('.confirm_end', order: @order.name)}
|
data: {confirm: t('.confirm_end', order: @order.name)}
|
||||||
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
|
= link_to t('ui.edit'), edit_order_path(@order), class: 'btn'
|
||||||
- elsif not @order.closed? and not @order.stockit?
|
- elsif not @order.closed? and not @order.stockit?
|
||||||
-# TODO btn-success class only if not received before
|
= receive_button @order
|
||||||
= link_to t('orders.index.action_receive'), receive_order_path(@order), class: 'btn btn-success'
|
|
||||||
- unless @order.closed?
|
- unless @order.closed?
|
||||||
= link_to t('ui.delete'), @order, data: {confirm: t('.confirm_delete')}, method: :delete,
|
= link_to t('ui.delete'), @order, data: {confirm: t('.confirm_delete')}, method: :delete,
|
||||||
class: 'btn btn-danger'
|
class: 'btn btn-danger'
|
||||||
|
|
Loading…
Add table
Reference in a new issue