Sha256: 0f52043044b9a8f983b3e95e64972ca14eca2d3e406c2087943d7cb638b65fcf

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

module Rawbotz
  module Helpers
    module ResourceLinkHelper
      include RawgentoModels

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rawbotz-0.1.5 lib/rawbotz/helpers/resource_link_helper.rb
rawbotz-0.1.4 lib/rawbotz/helpers/resource_link_helper.rb
rawbotz-0.1.3 lib/rawbotz/helpers/resource_link_helper.rb
rawbotz-0.1.2 lib/rawbotz/helpers/resource_link_helper.rb