Module: Crm::TagsHelper
- Defined in:
- app/helpers/crm/tags_helper.rb
Overview
View helper: tags.
Instance Method Summary collapse
-
#taggable_display_name(record, type) ⇒ Object
Returns a display name for a taggable record.
-
#taggable_type_icon(type) ⇒ Object
Returns a Font Awesome icon class for a taggable type.
-
#taggable_url(record, type) ⇒ Object
Returns the URL path for viewing a taggable record in CRM.
Instance Method Details
#taggable_display_name(record, type) ⇒ Object
Returns a display name for a taggable record
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/helpers/crm/tags_helper.rb', line 31 def taggable_display_name(record, type) case type when 'Article' record.try(:subject) || record.try(:title) || "Article ##{record.id}" when 'Showcase' record.try(:name) || "Showcase ##{record.id}" when 'DigitalAsset' record.try(:title) || record.try(:name) || "Digital Asset ##{record.id}" when 'FloorPlanDisplay' record.try(:name) || "Floor Plan Display ##{record.id}" when 'Item' [record.try(:sku), record.try(:name) || record.try(:name_en)].compact.join(' - ') when 'ProductLine' record.try(:name) || record.try(:name_en) || "Product Line ##{record.id}" when 'ActivityType' [record.try(:task_type), record.try(:description)].compact.join(' - ') when 'LocatorRecord' record.try(:name) || "Locator Record ##{record.id}" else record.try(:name) || record.try(:title) || "#{type} ##{record.id}" end end |
#taggable_type_icon(type) ⇒ Object
Returns a Font Awesome icon class for a taggable type
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/helpers/crm/tags_helper.rb', line 7 def taggable_type_icon(type) case type when 'Article' 'fa-solid fa-newspaper' when 'Showcase' 'fa-solid fa-images' when 'DigitalAsset' 'fa-solid fa-photo-film' when 'FloorPlanDisplay' 'fa-solid fa-map' when 'Item' 'fa-solid fa-box' when 'ProductLine' 'fa-solid fa-boxes-stacked' when 'ActivityType' 'fa-solid fa-list-check' when 'LocatorRecord' 'fa-solid fa-location-dot' else 'fa-solid fa-file' end end |
#taggable_url(record, type) ⇒ Object
Returns the URL path for viewing a taggable record in CRM
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'app/helpers/crm/tags_helper.rb', line 55 def taggable_url(record, type) case type when 'Article' article_crm_path(record) when 'Showcase' begin showcase_path(record) rescue StandardError nil end when 'DigitalAsset' digital_asset_crm_path(record) when 'FloorPlanDisplay' begin floor_plan_display_path(record) rescue StandardError nil end when 'Item' begin item_path(record) rescue StandardError nil end when 'ProductLine' begin product_line_path(record) rescue StandardError nil end when 'ActivityType' begin activity_type_path(record) rescue StandardError nil end when 'LocatorRecord' begin locator_record_path(record) rescue StandardError nil end end end |