Class: Crm::ProductLinePresenter
Overview
Presenter: product line presenter.
Instance Attribute Summary
#current_account, #options, #url_helper
Instance Method Summary
collapse
#initialize
#can?, #capture, #concat, #content_tag, #fa_icon, #h, #initialize, #link_to, #number_to_currency, #present, presents, #r, #safe_present, #simple_format, #u
Instance Method Details
#cache_link ⇒ Object
49
50
51
52
|
# File 'app/presenters/crm/product_line_presenter.rb', line 49
def cache_link
options[:class] ||= 'btn btn-outline-primary'
h.link_to('Refresh Cache', h.refresh_cache_product_line_path, **options)
end
|
#create_sub_product_line_link(options = {}) ⇒ Object
18
19
20
21
22
23
24
25
|
# File 'app/presenters/crm/product_line_presenter.rb', line 18
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
|
#delete_link ⇒ Object
10
11
12
|
# File 'app/presenters/crm/product_line_presenter.rb', line 10
def delete_link
h.delete_link r
end
|
#edit_link ⇒ Object
6
7
8
|
# File 'app/presenters/crm/product_line_presenter.rb', line 6
def edit_link
h.edit_link r
end
|
#headings ⇒ Object
14
15
16
|
# File 'app/presenters/crm/product_line_presenter.rb', line 14
def headings
r.lineage_expanded
end
|
#product_line_breadcrumb(params = {}) ⇒ Object
27
28
29
30
31
32
33
34
35
|
# File 'app/presenters/crm/product_line_presenter.rb', line 27
def product_line_breadcrumb(params = {})
capture do
concat content_tag(:li, link_to('Items', h.items_path), class: 'breadcrumb-item')
concat content_tag(: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
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/presenters/crm/product_line_presenter.rb', line 37
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
tabs_hsh[:items][:param_keys] = [:q]
tabs_hsh
end
|