Class: Crm::ProductLinePresenter
- Inherits:
-
BasePresenter
- Object
- SimpleDelegator
- BasePresenter
- BasePresenter
- Crm::ProductLinePresenter
- Defined in:
- app/presenters/crm/product_line_presenter.rb
Overview
Presenter: product line presenter.
Instance Attribute Summary
Attributes inherited from BasePresenter
#current_account, #options, #url_helper
Instance Method Summary collapse
-
#cache_link ⇒ ActiveSupport::SafeBuffer
Link to refresh the product line cache.
-
#create_sub_product_line_link(options = {}) ⇒ String?
Renders a link to create a sub product line under this one.
-
#delete_link ⇒ ActiveSupport::SafeBuffer
Link to delete the product line.
-
#edit_link ⇒ ActiveSupport::SafeBuffer
Link to edit the product line.
-
#headings ⇒ Array<ProductLine>
Expanded lineage for heading display.
-
#product_line_breadcrumb(params = {}) ⇒ ActiveSupport::SafeBuffer
Breadcrumb items from Items/Product Lines down to this line's ancestors.
-
#product_line_tab_options(params = {}) ⇒ Hash{Symbol => Hash}
Tab definitions for the CRM product line detail page.
Methods inherited from BasePresenter
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
#cache_link ⇒ ActiveSupport::SafeBuffer
Link to refresh the product line cache.
73 74 75 76 |
# File 'app/presenters/crm/product_line_presenter.rb', line 73 def cache_link [:class] ||= 'btn btn-outline-primary' h.link_to('Refresh Cache', h.refresh_cache_product_line_path, **) end |
#create_sub_product_line_link(options = {}) ⇒ String?
Renders a link to create a sub product line under this one.
30 31 32 33 34 35 36 37 |
# File 'app/presenters/crm/product_line_presenter.rb', line 30 def create_sub_product_line_link( = {}) return unless h.can?(:create, ProductLine) [: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), **) end |
#delete_link ⇒ ActiveSupport::SafeBuffer
Link to delete the product line.
15 16 17 |
# File 'app/presenters/crm/product_line_presenter.rb', line 15 def delete_link h.delete_link r end |
#edit_link ⇒ ActiveSupport::SafeBuffer
Link to edit the product line.
9 10 11 |
# File 'app/presenters/crm/product_line_presenter.rb', line 9 def edit_link h.edit_link r end |
#headings ⇒ Array<ProductLine>
Expanded lineage for heading display.
21 22 23 |
# File 'app/presenters/crm/product_line_presenter.rb', line 21 def headings r. end |
#product_line_breadcrumb(params = {}) ⇒ ActiveSupport::SafeBuffer
Breadcrumb items from Items/Product Lines down to this line's ancestors.
42 43 44 45 46 47 48 49 50 |
# File 'app/presenters/crm/product_line_presenter.rb', line 42 def (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 = {}) ⇒ Hash{Symbol => Hash}
Tab definitions for the CRM product line detail page.
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/presenters/crm/product_line_presenter.rb', line 55 def (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" # Pass the record (not r.id) so the href carries to_param — the same # identifier spelling the pane's frame id is built from. Mixing the # numeric id into hrefs while the show URL used the FriendlyId slug made # every tab fetch look like a cross-record breakout. hsh[tab] = { remote_href: h.send(route_method, r, params) } end # Allow the :q param to pass through tabs_hsh[:items][:param_keys] = [:q] tabs_hsh end |