Module: Crm::ResourcesHelper
- Defined in:
- app/helpers/crm/resources_helper.rb
Overview
View helper: resources.
Instance Method Summary collapse
Instance Method Details
#resource_label_link(resource) ⇒ Object
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 56 57 |
# File 'app/helpers/crm/resources_helper.rb', line 4 def resource_label_link(resource) (class: 'badge bg-warning', style: 'white-space: normal;', data: { turbo_frame: '_top' }) do || case resource.class.name when 'Opportunity' .link_to resource.name.to_s, opportunity_path(resource.id) when 'Communication' if resource.draft? && can?(:update, resource) .link_to 'Communication', edit_communication_path(resource.id) else .link_to 'Communication', communication_path(resource.id) end when 'Quote' .link_to "Quote ##{resource.reference_number}", quote_path(resource.id) when 'Order' .link_to "Order ##{resource.cart_identifier}", order_path(resource.id) when 'RoomConfiguration' .link_to resource.name_with_room.to_s, room_configuration_path(resource.id) when 'Invoice' .link_to "Invoice ##{resource.reference_number}", invoice_path(resource.id) when 'SupportCase' .link_to "Support Case ##{resource.case_number}", support_case_path(resource.id) when 'CreditApplication' .link_to "Credit Application ##{resource.reference_number}", credit_application_path(resource.id) when 'SpiffEnrollment' .link_to "Spiff Enrollment ##{resource.id}", spiff_enrollment_path(resource.id) when 'PurchaseOrder' .link_to "Purchase Order ##{resource.reference_number}", purchase_order_path(resource.id) when 'CreditMemo' .link_to "Credit Memo ##{resource.reference_number}", credit_memo_path(resource.id) when 'Rma' .link_to resource.rma_number, rma_path(resource.id) when 'Delivery' .link_to "Delivery ##{resource.id}", delivery_path(resource.id) when 'LocatorRecord' .link_to "Locator Record ##{resource.id}", locator_record_path(resource.id) when 'Payment' if resource.order .link_to resource.to_s, order_path(resource.order) else .content_tag(:span, resource.to_s) end else # Try a polymorphic link if (link = begin .link_to(resource.to_s, polymorphic_path(resource)) rescue StandardError nil end) link else # render static label .content_tag(:span, resource.to_s) end end end end |