Class: Www::SupportProductLinePresenter

Inherits:
BasePresenter
  • Object
show all
Includes:
Memery
Defined in:
app/presenters/www/support_product_line_presenter.rb

Overview

Presenter: support product line presenter.

Delegated Instance Attributes collapse

Instance Method Summary collapse

Instance Method Details

#articlesObject



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


35
36
37
# File 'app/presenters/www/support_product_line_presenter.rb', line 35

def breadcrumb
  h.formatted_breadcrumb breadcrumb_links
end


28
29
30
31
32
# File 'app/presenters/www/support_product_line_presenter.rb', line 28

def breadcrumb_links
  bcs = [{ name: 'Product Support', url: h.cms_link('/support') }]
  bcs += h.catalog_breadcrumb_links(product_line, section: :support)
  bcs
end

#cache_keyObject



8
9
10
# File 'app/presenters/www/support_product_line_presenter.rb', line 8

def cache_key
  "#{I18n.locale}/v4/#{product_line.cache_key}"
end

#can_be_purchased?Object

Alias for Product_line_presenter#can_be_purchased?

Returns:

  • (Object)

    Product_line_presenter#can_be_purchased?

See Also:



126
# File 'app/presenters/www/support_product_line_presenter.rb', line 126

delegate :can_be_purchased?, to: :product_line_presenter

#display_faqs?Boolean

Returns:

  • (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

Returns:

  • (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

#documentsObject



45
46
47
48
49
50
51
52
# File 'app/presenters/www/support_product_line_presenter.rb', line 45

def documents
  docs = retrieve_documents.all_publications
  related_items.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_categoryObject



55
56
57
# File 'app/presenters/www/support_product_line_presenter.rb', line 55

def documents_grouped_by_category
  documents.group_by(&:product_category_name)
end

#dynamic_introductionObject



112
113
114
115
116
117
118
119
# File 'app/presenters/www/support_product_line_presenter.rb', line 112

def dynamic_introduction
  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?
  "This support page provides #{contents.to_sentence} for the #{product_line.display_name} product line."
end

#faqsObject



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_imageObject



24
25
26
# File 'app/presenters/www/support_product_line_presenter.rb', line 24

def og_image
  product_line&.primary_image&.image_url
end

#page_descriptionObject



16
17
18
# File 'app/presenters/www/support_product_line_presenter.rb', line 16

def page_description
  seo_support_description.presence || "The support portal for #{name} provides free installation guides, wiring diagrams, operation manuals and more."
end

#page_keywordsObject



20
21
22
# File 'app/presenters/www/support_product_line_presenter.rb', line 20

def page_keywords
  [display_name, 'Support', 'Specifications', 'Documents', 'Videos', 'Manuals', 'Articles'].join(',')
end

#page_titleObject



12
13
14
# File 'app/presenters/www/support_product_line_presenter.rb', line 12

def page_title
  "#{product_line.seo_support_title.presence || title} | WarmlyYours"
end

#product_line_presenterObject



121
122
123
# File 'app/presenters/www/support_product_line_presenter.rb', line 121

def product_line_presenter
  Www::ProductLinePresenter.new(product_line)
end

#purchase_urlObject

Alias for Product_line_presenter#purchase_url

Returns:

  • (Object)

    Product_line_presenter#purchase_url

See Also:



128
# File 'app/presenters/www/support_product_line_presenter.rb', line 128

delegate :purchase_url, to: :product_line_presenter


81
82
83
84
85
86
87
88
89
90
91
92
# File 'app/presenters/www/support_product_line_presenter.rb', line 81

def related_items
  # 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


95
96
97
# File 'app/presenters/www/support_product_line_presenter.rb', line 95

def related_items_active
  related_items.sort_by { |i| i.past_model? ? 1 : 0 }
end

#representative_product_catalogObject



130
131
132
133
134
135
136
137
138
139
# File 'app/presenters/www/support_product_line_presenter.rb', line 130

def representative_product_catalog
  return nil unless related_items_active.any?

  # Get the first active product and create its schema
  representative_item = related_items_active.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_schemaObject



141
142
143
144
145
# File 'app/presenters/www/support_product_line_presenter.rb', line 141

def representative_product_schema
  return nil unless representative_product_catalog

  Www::ProductCatalogPresenter.new(representative_product_catalog).schema_dot_org_structure
end

#retrieve_documentsObject



40
41
42
# File 'app/presenters/www/support_product_line_presenter.rb', line 40

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_videosObject



59
60
61
# File 'app/presenters/www/support_product_line_presenter.rb', line 59

def retrieve_videos
  ProductLine::VideoRetriever.new(tags: 'for-support-page', ignore_individual_query_limits: true).process(product_line)
end

#sectionsObject



147
148
149
150
151
152
153
154
155
156
157
158
# File 'app/presenters/www/support_product_line_presenter.rb', line 147

def sections
  s = {}
  if related_items_active.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: related_items_active.size, title: 'Main Products', data: related_items_active, 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

#titleObject



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

#videosObject



67
68
69
# File 'app/presenters/www/support_product_line_presenter.rb', line 67

def videos
  retrieve_videos.all_videos
end

#videos_groupedObject

Alias for Retrieve_videos#videos_grouped

Returns:

  • (Object)

    Retrieve_videos#videos_grouped

See Also:



64
# File 'app/presenters/www/support_product_line_presenter.rb', line 64

delegate :videos_grouped, to: :retrieve_videos