Module: Spree::Admin::StoreCreditEventsHelper

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

Instance Method Summary collapse

Instance Method Details

#store_credit_event_admin_action_name(store_credit_event) ⇒ Object



18
19
20
21
22
23
24
25
# File 'app/helpers/spree/admin/store_credit_events_helper.rb', line 18

def store_credit_event_admin_action_name(store_credit_event)
  if Spree::StoreCreditEvent::NON_EXPOSED_ACTIONS.include?(store_credit_event.action) ||
     store_credit_event.action == Spree::StoreCredit::VOID_ACTION
    t("spree.store_credit.display_action.admin.#{store_credit_event.action}")
  else
    store_credit_event.display_action
  end
end


27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/helpers/spree/admin/store_credit_events_helper.rb', line 27

def store_credit_event_originator_link(store_credit_event)
  originator = store_credit_event.originator
  return unless originator

  add_user_originator_link
  unless originator_links.key?(store_credit_event.originator.class.to_s)
    raise "Unexpected originator type #{originator.class}"
  end

  options = {}
  link_options = originator_links[store_credit_event.originator.class.to_s]
  options[:target] = '_blank' if link_options[:new_tab]

  # Although not all href_types are used in originator_links
  # they are necessary because they may be used within extensions
  case link_options[:href_type]
  when :user
    link_to(
      t(link_options[:translation_key], email: originator.email, scope: 'spree'),
      spree.edit_admin_user_path(originator),
      options
    )
  when :line_item
    order = originator.line_item.order
    link_to(
      t(link_options[:translation_key], order_number: order.number, scope: 'spree'),
      spree.edit_admin_order_path(order),
      options
    )
  when :payment
    order = originator.order
    link_to(
      t(link_options[:translation_key], order_number: order.number, scope: 'spree'),
      spree.admin_order_payment_path(order, originator),
      options
    )
  when :payments
    order = originator.payment.order
    link_to(
      t(link_options[:translation_key], order_number: order.number, scope: 'spree'),
      spree.admin_order_payments_path(order),
      options
    )
  end
end