Class: CWM::PagerTreeItem

Inherits:
TreeItem show all
Defined in:
library/cwm/src/lib/cwm/tree_pager.rb

Overview

A TreeItem that knows a Page, useful for a TreePager. The UI label and `id` are taken from its Page: CWM::Page#label, AbstractWidget#widget_id

Instance Attribute Summary collapse

Attributes inherited from TreeItem

#children, #icon, #id, #label, #open

Instance Method Summary collapse

Methods inherited from TreeItem

#ui_term

Constructor Details

#initialize(page, icon: nil, open: true, children: []) ⇒ PagerTreeItem

Returns a new instance of PagerTreeItem

Parameters:



15
16
17
18
19
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 15

def initialize(page, icon: nil, open: true, children: [])
  @page = page
  super(page.widget_id, page.label,
        icon: icon, open: open, children: children)
end

Instance Attribute Details

#pagePage (readonly)

Returns:



11
12
13
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 11

def page
  @page
end

Instance Method Details

#pagesArray<Page>

Returns My page and all pages of descendant items (needed to initialize a CWM::Pager).

Returns:

  • (Array<Page>)

    My page and all pages of descendant items (needed to initialize a CWM::Pager).



23
24
25
# File 'library/cwm/src/lib/cwm/tree_pager.rb', line 23

def pages
  children.values.flat_map(&:pages).unshift(@page)
end