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]
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
|