Module: CatalogsHelper
- Defined in:
- app/helpers/catalogs_helper.rb
Instance Method Summary collapse
-
#catalog_image_profile_marketplace(catalog) ⇒ Object
Determines which image profile marketplace to use for a catalog Amazon catalogs use AMZ profiles, Walmart catalogs use WAL profiles, others use WYS (website).
-
#catalog_image_profile_scope(catalog) ⇒ Object
Returns the image profile scope method name for a catalog.
-
#catalog_marketplace_name(catalog) ⇒ Object
Returns human-readable name for the marketplace.
- #catalog_tab_options(catalog = @catalog) ⇒ Object
- #catalogs_with_us_ca_prioritized(catalogs) ⇒ Object
Instance Method Details
#catalog_image_profile_marketplace(catalog) ⇒ Object
Determines which image profile marketplace to use for a catalog
Amazon catalogs use AMZ profiles, Walmart catalogs use WAL profiles, others use WYS (website)
28 29 30 31 32 33 34 35 36 |
# File 'app/helpers/catalogs_helper.rb', line 28 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) ⇒ Object
Returns the image profile scope method name for a catalog
39 40 41 42 43 44 45 |
# File 'app/helpers/catalogs_helper.rb', line 39 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) ⇒ Object
Returns human-readable name for the marketplace
48 49 50 51 52 53 54 |
# File 'app/helpers/catalogs_helper.rb', line 48 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) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'app/helpers/catalogs_helper.rb', line 16 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) ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/catalogs_helper.rb', line 2 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.detect { |c| c.id == CatalogConstants::CA_CATALOG_ID }) catalogs_sorted.delete(wy_ca) catalogs_sorted.insert(0, wy_ca) end if (wy_us = catalogs_sorted.detect { |c| c.id == CatalogConstants::US_CATALOG_ID }) catalogs_sorted.delete(wy_us) catalogs_sorted.insert(0, wy_us) end catalogs_sorted end |