Module: PagesCore::PageModel::Tree::ClassMethods

Defined in:
app/models/concerns/pages_core/page_model/tree.rb

Instance Method Summary collapse

Instance Method Details

#admin_list(locale) ⇒ Object



28
29
30
31
32
# File 'app/models/concerns/pages_core/page_model/tree.rb', line 28

def admin_list(locale)
  left_outer_joins(:parent)
    .where("pages.status < 4")
    .order(admin_list_order).in_locale(locale)
end

#admin_list_orderObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/models/concerns/pages_core/page_model/tree.rb', line 34

def admin_list_order
  Arel.sql(
    <<-QUERY
    pages.parent_page_id, parents_pages.news_page,
    case when parents_pages.news_page
      then pages.pinned end desc,
    case when parents_pages.news_page
      then pages.published_at end desc,
    position asc
    QUERY
  )
end

#rootObject

Returns the first root page



53
54
55
# File 'app/models/concerns/pages_core/page_model/tree.rb', line 53

def root
  roots.first
end

#rootsObject

Returns all root pages



48
49
50
# File 'app/models/concerns/pages_core/page_model/tree.rb', line 48

def roots
  where(parent_page_id: nil).order("position ASC")
end