Module: Rawbotz::Helpers::ResourceLinkHelper

Includes:
RawgentoModels
Defined in:
lib/rawbotz/helpers/resource_link_helper.rb

Instance Method Summary collapse

Instance Method Details



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rawbotz/helpers/resource_link_helper.rb', line 6

def local_product_link product
  if product.present?
    if product.name.empty?
      "<a href=\"/product/#{product.id}\">[no product name!]</a>"
    else
      "<a href=\"/product/#{product.id}\">#{product.name}</a>"
    end
  else
    "Product not in database"
  end
end


42
43
44
# File 'lib/rawbotz/helpers/resource_link_helper.rb', line 42

def order_link order
  "<a href=\"/order/#{order.id}\">Order #{order.id} (#{order.supplier.try(:name) || "no supplier"})</a>"
end


30
31
32
33
34
# File 'lib/rawbotz/helpers/resource_link_helper.rb', line 30

def product_link product
  return local_product_link(product) if product.is_a?(LocalProduct)
  return remote_product_link(product) if product.is_a?(RemoteProduct)
  "no product"
end


17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rawbotz/helpers/resource_link_helper.rb', line 17

def remote_product_link product
  if product.is_a? LocalProduct
    remote_product_link product.remote_product
  elsif product.try(:id)
    "<a href=\"/remote_product/#{product.id}\">"\
    "<i class=\"fa fa-globe\"></i>#{product.name}</a>"
  elsif product.name
    # Used in RemoteOrder view.
    "#{product.name}"
  else
    "not linked"
  end
end


35
36
37
38
39
40
41
# File 'lib/rawbotz/helpers/resource_link_helper.rb', line 35

def supplier_link supplier
  if supplier.to_s != ""
    "<a href=\"/supplier/#{supplier.id}\">#{supplier.name}</a>"
  else
    "[no supplier]"
  end
end