Class: ODDB::View::Pager

Inherits:
HtmlGrid::List show all
Defined in:
src/view/pager.rb,
test/test_view/pager.rb

Direct Known Subclasses

Drugs::OffsetPager

Constant Summary

BACKGROUND_SUFFIX =
''
COMPONENTS =
{
  [0,0] =>  :number_link,
}
CSS_CLASS =
'pager right'
CSS_HEAD_MAP =
{
  [0,0] =>  'pager-head',
}
CSS_MAP =
{
  [0,0] =>  'pager',
}
OFFSET_STEP =
[1,0]
SORT_DEFAULT =
:to_i
SORT_HEADER =
false

Constants inherited from HtmlGrid::List

BACKGROUND_SUFFIX

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Pager) initialize(model, session, container = nil, event = :result, args = {})

A new instance of Pager



25
26
27
28
29
30
# File 'src/view/pager.rb', line 25

def initialize(model, session, container=nil, 
  event=:result, args={})
  @event = event
  @arguments = args
  super(model, session, container)
end

Instance Attribute Details

- (Object) arguments

Returns the value of attribute arguments



24
25
26
# File 'src/view/pager.rb', line 24

def arguments
  @arguments
end

- (Object) event

Returns the value of attribute event



24
25
26
# File 'src/view/pager.rb', line 24

def event
  @event
end

Instance Method Details



45
46
47
48
49
50
51
# File 'src/view/pager.rb', line 45

def compose_footer(offset)
  if(@page != @model.last)
    link = page_link(:pager_fwd, @page.next)
    link.value = @lookandfeel.lookup(:pager_fwd)
    @grid.add(link, *offset)
  end
end

- (Object) compose_header(offset)



35
36
37
38
39
40
41
42
43
44
# File 'src/view/pager.rb', line 35

def compose_header(offset)
  @grid.add(page_number(@model, @session), *offset)
  @grid.add_style('pager-head', *offset)
  offset = resolve_offset(offset, self::class::OFFSET_STEP)
  if(@page != @model.first)
    link = page_link(:pager_back, @page.previous)
    @grid.add(link, *offset)
  end
  resolve_offset(offset, self::class::OFFSET_STEP)
end

- (Object) init



31
32
33
34
# File 'src/view/pager.rb', line 31

def init
  @page = @session.state.page
  super 
end


60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'src/view/pager.rb', line 60

def page_link(key, page)
  if(page != @session.state.page)
    link = HtmlGrid::Link.new(key, page, @session, self)
    link.value = page.send(key) if page.respond_to?(key)
    link.set_attribute("class", "pager")
    values = @arguments.merge({
      :page =>  page.to_s,
    })
    link.href = @lookandfeel._event_url(@event, values)
    link
  else
    page.send(key)
  end
end

- (Object) to_html(context)



52
53
54
55
# File 'src/view/pager.rb', line 52

def to_html(context)
  init
  super
end