Class: Www::SupportProductLinePresenter

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

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


33
34
35
# File 'app/presenters/www/support_product_line_presenter.rb', line 33

def breadcrumb
  h.formatted_breadcrumb breadcrumb_links
end


26
27
28
29
30
# File 'app/presenters/www/support_product_line_presenter.rb', line 26

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



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?

Returns:

  • (Object)

    Product_line_presenter#can_be_purchased?

See Also:



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

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



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



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_introductionObject



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

#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



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_descriptionObject



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_keywordsObject



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_titleObject



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_presenterObject



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_urlObject

Alias for Product_line_presenter#purchase_url

Returns:

  • (Object)

    Product_line_presenter#purchase_url

See Also:



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

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



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



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_documentsObject



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_videosObject



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

#sectionsObject



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



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

def videos_grouped
  retrieve_videos.videos_grouped
end