Class: OMF::Web::Widget::Layout::StackedLayout

Inherits:
AbstractWidget
  • Object
show all
Defined in:
lib/omf-web/widget/layout/stacked_layout.rb

Overview

Implements a layout which displays only one of the widget it contains but provides theme specific means to switch between them.

Instance Attribute Summary collapse

Attributes inherited from AbstractWidget

#opts, #widget_id, #widget_type

Instance Method Summary collapse

Methods inherited from AbstractWidget

#mime_type, #title, #tools_menu, #widget_info

Methods included from Common::Loggable

#_logger, #debug, #error, #fatal, #info, init_log, logger, set_environment, #warn

Constructor Details

#initialize(opts) ⇒ StackedLayout

Returns a new instance of StackedLayout.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 11

def initialize(opts)
  super opts
  widgets = opts[:widgets]
  # if (widgets.is_a? Hash)
    # puts "ERROR>>>> #{widgets.inspect}"
    # raise  "NOT SURE WHY WE ARE COMING THROUGH HERE"
    # opts = widgets
    # #@wopts = opts[:wopts] || {}
    # #puts ">>>> #{widgets.inspect}"
    # widgets = @wopts[:widgets] || []
  # end
  @widgets = widgets.collect {|w| OMF::Web::Widget.create_widget(w) }
  @active_index = 0
  @active_widget = @widgets[0]
end

Instance Attribute Details

#active_indexObject (readonly)

Returns the value of attribute active_index.



9
10
11
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 9

def active_index
  @active_index
end

Instance Method Details

#collect_data_sources(ds_set) ⇒ Object



33
34
35
36
37
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 33

def collect_data_sources(ds_set)
  @active_widget.collect_data_sources(ds_set)
  #@widgets.each {|w| w.collect_data_sources(ds_set) }
  ds_set
end

#contentObject



27
28
29
30
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 27

def content()
  OMF::Web::Theme.require 'stacked_renderer'
  OMF::Web::Theme::StackedRenderer.new(self, @widgets, @active_index, @opts)
end

#layout?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 43

def layout?
  return true
end

#nameObject



39
40
41
# File 'lib/omf-web/widget/layout/stacked_layout.rb', line 39

def name
  @opts[:name] || @active_widget.name
end