Module: Workarea::Admin::ProductsHelper

Defined in:
app/helpers/workarea/admin/products_helper.rb

Instance Method Summary collapse

Instance Method Details

#format_variant_options(hash) ⇒ Object



3
4
5
6
7
8
# File 'app/helpers/workarea/admin/products_helper.rb', line 3

def format_variant_options(hash)
  hash.map do |name, value|
    joined = value.is_a?(Array) ? value.join(', ') : value
    "#{(:strong, name)}: #{joined}"
  end.join(', ').html_safe
end

#summary_inventory_status_css_classes(product) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/workarea/admin/products_helper.rb', line 10

def summary_inventory_status_css_classes(product)
  status_issue_class =
    if !product.active?
      'product-summary--inactive'
    elsif !product.inventory.available?
      "product-summary--#{product.inventory.status.to_s.dasherize}"
    end

  return [] unless status_issue_class.present?
  return [] if product.inventory.any?(&:displayable_when_out_of_stock?)
  [status_issue_class, 'product-summary--status-issue']
end