Class: Www::SupportProductLinePresenter
- Inherits:
-
BasePresenter
- Object
- BasePresenter
- Www::SupportProductLinePresenter
- Includes:
- Memery
- Defined in:
- app/presenters/www/support_product_line_presenter.rb
Delegated Instance Attributes collapse
-
#can_be_purchased? ⇒ Object
Alias for Product_line_presenter#can_be_purchased?.
-
#purchase_url ⇒ Object
Alias for Product_line_presenter#purchase_url.
Instance Method Summary collapse
- #articles ⇒ Object
- #breadcrumb ⇒ Object
- #breadcrumb_links ⇒ Object
- #cache_key ⇒ Object
- #display_faqs? ⇒ Boolean
- #display_product_line_image? ⇒ Boolean
- #documents ⇒ Object
- #documents_grouped_by_category ⇒ Object
- #dynamic_introduction ⇒ Object
- #faqs ⇒ Object
- #og_image ⇒ Object
- #page_description ⇒ Object
- #page_keywords ⇒ Object
- #page_title ⇒ Object
- #product_line_presenter ⇒ Object
- #related_items ⇒ Object
- #related_items_active ⇒ Object
- #representative_product_catalog ⇒ Object
- #representative_product_schema ⇒ Object
- #retrieve_documents ⇒ Object
- #retrieve_videos ⇒ Object
- #sections ⇒ Object
- #title ⇒ Object
- #videos ⇒ Object
- #videos_grouped ⇒ Object
Instance Method Details
#articles ⇒ Object
71 72 73 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 71 def articles ArticleTechnical.published.for_product_line_url_with_ancestors(product_line.slug_ltree.to_s).order(:subject) end |
#breadcrumb ⇒ Object
33 34 35 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 33 def h. end |
#breadcrumb_links ⇒ Object
26 27 28 29 30 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 26 def bcs = [{ name: 'Product Support', url: h.cms_link('/support') }] bcs += h.(product_line, section: :support) bcs end |
#cache_key ⇒ Object
6 7 8 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 6 def cache_key "#{I18n.locale}/v4/#{product_line.cache_key}" end |
#can_be_purchased? ⇒ Object
Alias for Product_line_presenter#can_be_purchased?
129 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 129 delegate :can_be_purchased?, to: :product_line_presenter |
#display_faqs? ⇒ Boolean
100 101 102 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 100 def display_faqs? faqs.present? end |
#display_product_line_image? ⇒ Boolean
104 105 106 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 104 def display_product_line_image? !support_portal_should_use_images? end |
#documents ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 43 def documents docs = retrieve_documents.all_publications .active.each do |item| sip = Www::SupportItemPresenter.new(item, h) docs += sip.documents(all_product_lines: false) end docs.uniq(&:sku) end |
#documents_grouped_by_category ⇒ Object
53 54 55 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 53 def documents_grouped_by_category documents.group_by(&:product_category_name) end |
#dynamic_introduction ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 112 def dynamic_introduction str = 'This support page provides ' contents = [] contents += %w[publications manuals] if retrieve_documents.present? contents << 'videos' if videos_grouped.present? contents << 'support articles' if articles.present? contents << 'common support questions' if display_faqs? str << contents.to_sentence str << " for the #{product_line.display_name} product line." str end |
#faqs ⇒ Object
76 77 78 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 76 def faqs Item::ArticleRetriever.new(article_types: %w[faq], support: true, add_vote_data: true).process(product_line: product_line).articles end |
#og_image ⇒ Object
22 23 24 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 22 def og_image product_line&.primary_image&.image_url end |
#page_description ⇒ Object
14 15 16 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 14 def page_description seo_support_description.presence || "The support portal for #{name} provides free installation guides, wiring diagrams, operation manuals and more." end |
#page_keywords ⇒ Object
18 19 20 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 18 def page_keywords [display_name, 'Support', 'Specifications', 'Documents', 'Videos', 'Manuals', 'Articles'].join(',') end |
#page_title ⇒ Object
10 11 12 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 10 def page_title "#{product_line.seo_support_title.presence || title} | WarmlyYours" end |
#product_line_presenter ⇒ Object
124 125 126 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 124 def product_line_presenter Www::ProductLinePresenter.new(product_line) end |
#purchase_url ⇒ Object
Alias for Product_line_presenter#purchase_url
131 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 131 delegate :purchase_url, to: :product_line_presenter |
#related_items ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 81 def # The UDG4-4999 is a duplicate of -WY and in all technicality we will support only UDG4-4999-WY for display in the active section results = all_my_support_items.where.not(sku: 'UDG4-4999').where(visible_for_support: true) if product_line.support_items_sort_method_sku_only? results.reorder(Item[:sku]) elsif product_line.support_items_sort_method_product_category_sku? results.joins(:product_category).reorder(ProductCategory[:name], Item[:sku]) else results.reorder(Item[:popularity].desc, :sku) end end |
#related_items_active ⇒ Object
95 96 97 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 95 def .sort_by { |i| i.past_model? ? 1 : 0 } end |
#representative_product_catalog ⇒ Object
133 134 135 136 137 138 139 140 141 142 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 133 def representative_product_catalog return nil unless .any? # Get the first active product and create its schema representative_item = .first ViewProductCatalog.where(catalog_id: Catalog.locale_to_catalog_id) .where(item_id: representative_item.id) .where(item_is_web_accessible: true) .first end |
#representative_product_schema ⇒ Object
144 145 146 147 148 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 144 def representative_product_schema return nil unless representative_product_catalog Www::ProductCatalogPresenter.new(representative_product_catalog).schema_dot_org_structure end |
#retrieve_documents ⇒ Object
38 39 40 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 38 def retrieve_documents ProductLine::PublicationRetriever.new.process(product_line.slug_ltree.to_s, categories: [:support], product_category_ids: product_line.product_category_ids) end |
#retrieve_videos ⇒ Object
57 58 59 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 57 def retrieve_videos ProductLine::VideoRetriever.new(tags: 'for-support-page', ignore_individual_query_limits: true).process(product_line) end |
#sections ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 150 def sections s = {} if .present? partial = support_portal_should_use_images? ? 'www/support_portals/section_related_items_with_images' : 'www/support_portals/section_related_items' s[:related_items_active] = { partial: partial, counter: .size, title: 'Main Products', data: , fa_icon: 'box' } end s[:faqs] = { partial: 'www/support_portals/section_faqs', counter: faqs.size, title: 'Support Questions', data: faqs, referral_product_line: product_line.slug_ltree.to_s, pl: product_line, fa_icon: 'question-mark' } if display_faqs? s[:publications] = { partial: 'www/support_portals/section_publications_links', counter: documents.size, title: 'Documents', data: documents_grouped_by_category, fa_icon: 'publication' } if retrieve_documents.present? s[:videos] = { partial: 'www/support_portals/section_videos', counter: videos.size, title: 'Videos', data: videos_grouped, pl: product_line, fa_icon: 'video' } if videos_grouped.present? s[:articles] = { partial: 'www/support_portals/section_articles_links', counter: articles.size, title: 'Articles', data: articles, pl: product_line, fa_icon: 'document' } if articles.present? s end |
#title ⇒ Object
108 109 110 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 108 def title product_line.support_title.presence || "#{product_line.display_name} Support" end |
#videos ⇒ Object
67 68 69 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 67 def videos retrieve_videos.all_videos end |
#videos_grouped ⇒ Object
62 63 64 |
# File 'app/presenters/www/support_product_line_presenter.rb', line 62 def videos_grouped retrieve_videos.videos_grouped end |