Class: Crm::ProductLinePresenter

Inherits:
BasePresenter show all
Defined in:
app/presenters/crm/product_line_presenter.rb

Instance Attribute Summary

Attributes inherited from BasePresenter

#current_account, #options, #url_helper

Instance Method Summary collapse

Methods inherited from BasePresenter

#initialize

Methods inherited from BasePresenter

#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u

Constructor Details

This class inherits a constructor from Crm::BasePresenter

Instance Method Details



46
47
48
49
# File 'app/presenters/crm/product_line_presenter.rb', line 46

def cache_link
  options[:class] ||= 'btn btn-outline-primary'
  h.link_to('Refresh Cache', h.refresh_cache_product_line_path, **options)
end


16
17
18
19
20
21
22
# File 'app/presenters/crm/product_line_presenter.rb', line 16

def create_sub_product_line_link(options={})
  return unless h.can?(:create, ProductLine)
  options[:class] ||= 'btn btn-outline-primary'
  h.link_to(h.fa_icon('plus-circle', text: 'Add Sub Product Line'),
        h.new_product_line_path(parent_id: r.id),
        **options)
end


8
9
10
# File 'app/presenters/crm/product_line_presenter.rb', line 8

def delete_link
  h.delete_link r
end


4
5
6
# File 'app/presenters/crm/product_line_presenter.rb', line 4

def edit_link
  h.edit_link r
end

#headingsObject



12
13
14
# File 'app/presenters/crm/product_line_presenter.rb', line 12

def headings
  r.lineage_expanded
end

#product_line_breadcrumb(params = {}) ⇒ Object



24
25
26
27
28
29
30
31
32
# File 'app/presenters/crm/product_line_presenter.rb', line 24

def product_line_breadcrumb(params = {})
  capture do
    concat (:li, link_to('Items', h.items_path), class: 'breadcrumb-item')
    concat (:li, link_to('Product Lines', h.product_lines_path), class: 'breadcrumb-item')
    product_line.ancestors.reverse_each do |pl|
      concat h.tag.li(h.link_to(pl.name.presence || pl.name_en, h.product_line_path(pl, anchor: params[:tab])), class: 'breadcrumb-item')
    end
  end
end

#product_line_tab_options(params = {}) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'app/presenters/crm/product_line_presenter.rb', line 34

def product_line_tab_options(params={})
  tabs = %i[main_attributes descriptions seo specifications items publications digital_assets]
  params.slice!(:show_inactive)
  tabs_hsh = tabs.each_with_object({}) do |tab, hsh|
    route_method = "tab_#{tab}_product_line_path"
    hsh[tab] = { remote_href: h.send(route_method, r.id, params) }
  end
  # Allow the :q param to pass through
  tabs_hsh[:items][:param_keys] = [:q]
  tabs_hsh
end