Module: CatalogsHelper
- Defined in:
- app/helpers/catalogs_helper.rb
Overview
View helper: catalogs.
Instance Method Summary collapse
-
#catalog_image_profile_marketplace(catalog) ⇒ Symbol
Determines which image profile marketplace to use for a catalog.
-
#catalog_image_profile_scope(catalog) ⇒ Symbol
Returns the image profile scope method name for a catalog.
-
#catalog_marketplace_name(catalog) ⇒ String
Returns human-readable name for the marketplace.
-
#catalog_tab_options(catalog = @catalog) ⇒ Hash{Symbol => Hash}
Builds the tab navigation options for a catalog detail page.
-
#catalogs_with_us_ca_prioritized(catalogs) ⇒ Array<Catalog>
Sorts catalogs by name with the main US and Canada catalogs moved to the front.
Instance Method Details
#catalog_image_profile_marketplace(catalog) ⇒ Symbol
Determines which image profile marketplace to use for a catalog.
Amazon catalogs use AMZ profiles, Walmart catalogs use WAL profiles, others use WYS (website)
49 50 51 52 53 54 55 56 57 |
# File 'app/helpers/catalogs_helper.rb', line 49 def catalog_image_profile_marketplace(catalog) if catalog.is_amazon? :AMZ elsif catalog.orchestrator_key&.start_with?('walmart') :WAL else :WYS end end |
#catalog_image_profile_scope(catalog) ⇒ Symbol
Returns the image profile scope method name for a catalog.
65 66 67 68 69 70 71 |
# File 'app/helpers/catalogs_helper.rb', line 65 def catalog_image_profile_scope(catalog) case catalog_image_profile_marketplace(catalog) when :AMZ then :amazon_image_profiles when :WAL then :walmart_image_profiles else :website_image_profiles end end |
#catalog_marketplace_name(catalog) ⇒ String
Returns human-readable name for the marketplace.
78 79 80 81 82 83 84 |
# File 'app/helpers/catalogs_helper.rb', line 78 def catalog_marketplace_name(catalog) case catalog_image_profile_marketplace(catalog) when :AMZ then 'Amazon' when :WAL then 'Walmart' else 'Website' end end |
#catalog_tab_options(catalog = @catalog) ⇒ Hash{Symbol => Hash}
Builds the tab navigation options for a catalog detail page.
34 35 36 37 38 39 40 41 42 |
# File 'app/helpers/catalogs_helper.rb', line 34 def (catalog = @catalog) { overview: { remote_href: tab_overview_catalog_path(catalog), title: 'Overview' }, items: { remote_href: tab_items_catalog_path(catalog), title: 'Items' }, settings: { remote_href: tab_settings_catalog_path(catalog), title: 'Settings' }, relationships: { remote_href: tab_relationships_catalog_path(catalog), title: 'Relationships' }, images: { remote_href: tab_images_catalog_path(catalog), title: 'Images' } } end |
#catalogs_with_us_ca_prioritized(catalogs) ⇒ Array<Catalog>
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/helpers/catalogs_helper.rb', line 14 def catalogs_with_us_ca_prioritized(catalogs) catalogs_sorted = catalogs.to_a.sort_by(&:name) # Extract US and Canada main catalogs and move them to the front if (wy_ca = catalogs_sorted.find { |c| c.id == CatalogConstants::CA_CATALOG_ID }) catalogs_sorted.delete(wy_ca) catalogs_sorted.insert(0, wy_ca) end if (wy_us = catalogs_sorted.find { |c| c.id == CatalogConstants::US_CATALOG_ID }) catalogs_sorted.delete(wy_us) catalogs_sorted.insert(0, wy_us) end catalogs_sorted end |