Class: QuickSearch::CatalogItemPresenter
- Inherits:
-
PinPresenter
- Object
- PinPresenter
- QuickSearch::CatalogItemPresenter
- Defined in:
- app/presenters/quick_search/catalog_item_presenter.rb
Overview
Presents a CatalogItem as a quick search result / pinned item, with catalog
state, FNSKU, and third-party part-number badges.
Instance Method Summary collapse
-
#set_attributes ⇒ void
Sets the card title (SKU), badge sub-header, link, and result class.
-
#text_sub_header ⇒ String
The item name shown as plain-text sub-header.
-
#type_label ⇒ String
The catalog name shown as the card's type label.
Instance Method Details
#set_attributes ⇒ void
This method returns an undefined value.
Sets the card title (SKU), badge sub-header, link, and result class.
11 12 13 14 15 16 17 18 19 |
# File 'app/presenters/quick_search/catalog_item_presenter.rb', line 11 def set_attributes @title = result.sku @sub_header = +'' @sub_header << state_badge @sub_header << h.tag.span(result.amazon_fnsku, class: 'badge bg-info') if result.amazon_fnsku.present? @sub_header << h.tag.span(result.third_party_part_number, class: 'badge text-bg-secondary') if result.third_party_part_number.present? @link = catalog_item_path(result) @result_class = :catalog_item end |
#text_sub_header ⇒ String
Returns the item name shown as plain-text sub-header.
22 23 24 |
# File 'app/presenters/quick_search/catalog_item_presenter.rb', line 22 def text_sub_header result.name end |
#type_label ⇒ String
Returns the catalog name shown as the card's type label.
27 28 29 |
# File 'app/presenters/quick_search/catalog_item_presenter.rb', line 27 def type_label result.catalog.name end |