Module: Spree::Admin::AdjustmentsHelper

Defined in:
app/helpers/spree/admin/adjustments_helper.rb

Instance Method Summary collapse

Instance Method Details

#adjustment_state(adjustment) ⇒ Object


11
12
13
14
15
16
17
18
# File 'app/helpers/spree/admin/adjustments_helper.rb', line 11

def adjustment_state(adjustment)
  state = adjustment.state.to_sym
  if adjustment.finalized?
    Spree.t(state)
  else
    icon_for(state)
  end
end

#icon_for(adjustment_state) ⇒ Object


20
21
22
23
# File 'app/helpers/spree/admin/adjustments_helper.rb', line 20

def icon_for(adjustment_state)
  icon = { closed: 'icon-lock', open: 'icon-unlock' }
  (:span, '', class: icon[adjustment_state])
end

4
5
6
7
8
9
# File 'app/helpers/spree/admin/adjustments_helper.rb', line 4

def link_to_toggle_adjustment_state(order, adjustment, options={})
  return if adjustment.finalized?
  icon = { closed: 'icon-unlock', open: 'icon-lock' }
  alt_text = adjustment.immutable? ? Spree.t(:open) : Spree.t(:close)
  link_to_with_icon(icon[adjustment.state.to_sym], alt_text, toggle_state_admin_order_adjustment_url(order, adjustment), options)
end