2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
|
# File 'app/helpers/crm/resources_helper.rb', line 2
def resource_label_link(resource)
with_options(class: 'badge bg-warning', style: 'white-space: normal;', data: { turbo_frame: '_top' }) do |options|
case resource.class.name
when 'Opportunity'
options.link_to resource.name.to_s, opportunity_path(resource.id)
when 'Communication'
if resource.draft? and can?(:update, resource)
options.link_to 'Communication', edit_communication_path(resource.id)
else
options.link_to 'Communication', communication_path(resource.id)
end
when 'Quote'
options.link_to "Quote ##{resource.reference_number}", quote_path(resource.id)
when 'Order'
options.link_to "Order ##{resource.cart_identifier}", order_path(resource.id)
when 'RoomConfiguration'
options.link_to resource.name_with_room.to_s, room_configuration_path(resource.id)
when 'Invoice'
options.link_to "Invoice ##{resource.reference_number}", invoice_path(resource.id)
when 'SupportCase'
options.link_to "Support Case ##{resource.case_number}", support_case_path(resource.id)
when 'CreditApplication'
options.link_to "Credit Application ##{resource.reference_number}", credit_application_path(resource.id)
when 'SpiffEnrollment'
options.link_to "Spiff Enrollment ##{resource.id}", spiff_enrollment_path(resource.id)
when 'PurchaseOrder'
options.link_to "Purchase Order ##{resource.reference_number}", purchase_order_path(resource.id)
when 'CreditMemo'
options.link_to "Credit Memo ##{resource.reference_number}", credit_memo_path(resource.id)
when 'Rma'
options.link_to resource.rma_number, rma_path(resource.id)
when 'Delivery'
options.link_to "Delivery ##{resource.id}", delivery_path(resource.id)
when 'LocatorRecord'
options.link_to "Locator Record ##{resource.id}", locator_record_path(resource.id)
when 'Payment'
if resource.order
options.link_to resource.to_s, order_path(resource.order)
else
options.content_tag(:span, resource.to_s)
end
else if (link = begin
options.link_to(resource.to_s, polymorphic_path(resource))
rescue StandardError
nil
end)
link
else options.content_tag(:span, resource.to_s)
end
end
end
end
|