Class: Workarea::Admin::CategoryViewModel

Inherits:
ApplicationViewModel
  • Object
show all
Includes:
CommentableViewModel, ContentableViewModel, FeaturedProductsViewModel
Defined in:
app/view_models/workarea/admin/category_view_model.rb

Instance Method Summary collapse

Methods included from FeaturedProductsViewModel

#featured_products

Methods included from ContentableViewModel

#content

Methods included from CommentableViewModel

#comment_count, #comments, #has_comments?, #new_comments_for?, #subscribed_users

Instance Method Details



16
17
18
# File 'app/view_models/workarea/admin/category_view_model.rb', line 16

def breadcrumb_string
  options.fetch(:source, {})[:breadcrumbs] || breadcrumbs.join(' > ')
end


12
13
14
# File 'app/view_models/workarea/admin/category_view_model.rb', line 12

def breadcrumbs
  @breadcrumbs ||= Navigation::Breadcrumbs.new(model)
end

#insightsObject



20
21
22
# File 'app/view_models/workarea/admin/category_view_model.rb', line 20

def insights
  @insights ||= Insights::CategoryViewModel.wrap(model, options)
end

#price_facetObject



46
47
48
# File 'app/view_models/workarea/admin/category_view_model.rb', line 46

def price_facet
  @price_facet ||= range_facets['price'] || []
end

#productsObject



42
43
44
# File 'app/view_models/workarea/admin/category_view_model.rb', line 42

def products
  @products ||= Storefront::CategoryViewModel.new(model).products
end

#products_countObject



50
51
52
# File 'app/view_models/workarea/admin/category_view_model.rb', line 50

def products_count
  @products_count ||= model.products.count
end

#rule_fieldsArray

Returns an array of arrays that each contain a human readable value and and a value that is used in a category’s rule :field field.



36
37
38
39
40
# File 'app/view_models/workarea/admin/category_view_model.rb', line 36

def rule_fields
  Search::Storefront::Product.current_product_rule_fields.to_a.map do |field|
    [field.first.to_s.titleize, field.last]
  end
end

#sort_optionsObject



24
25
26
27
28
29
# File 'app/view_models/workarea/admin/category_view_model.rb', line 24

def sort_options
  Search::CategoryBrowse
    .available_sorts
    .map { |s| [s.name, s.slug] }
    .reject { |s| s.last == :relevance }
end

#timelineObject



8
9
10
# File 'app/view_models/workarea/admin/category_view_model.rb', line 8

def timeline
  @timeline ||= TimelineViewModel.new(model)
end