Module: Admin::Atreides::ProductsHelper

Includes:
Atreides::Extendable
Defined in:
app/helpers/admin/atreides/products_helper.rb

Instance Method Summary collapse

Instance Method Details

#image_column(product) ⇒ Object



3
4
5
# File 'app/helpers/admin/atreides/products_helper.rb', line 3

def image_column(product)
  !product.photos.empty? ? image_tag(product.photos.first.image.url(:thumb)) : ""
end

#inventory_column(product) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/helpers/admin/atreides/products_helper.rb', line 11

def inventory_column(product)
  (:table) do
    (:thead) do
      (:th, "Size") +
      (:th, "Qty")
    end +
    (:tbody) do
      product.sizes.map do |s|
        (:tr) do
          (:td, s.name) +
          (:td, s.qty)
        end
      end.join
    end
  end
end

#product_column(product) ⇒ Object



7
8
9
# File 'app/helpers/admin/atreides/products_helper.rb', line 7

def product_column(product)
  link_to product.title, edit_admin_product_path(product)
end

#sales_column(product) ⇒ Object



32
33
34
# File 'app/helpers/admin/atreides/products_helper.rb', line 32

def sales_column(product)
  Money.new(product.orders.sum(:final_amount_cents)).format
end

#total_column(product) ⇒ Object



28
29
30
# File 'app/helpers/admin/atreides/products_helper.rb', line 28

def total_column(product)
  product.sizes.sum(:qty)
end