Class: OMF::Web::Widget::Layout::TwoColumnsLayout

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

Overview

Implements a layout which displays contained widgets in two columns.

Instance Attribute Summary

Attributes inherited from AbstractWidget

#opts, #widget_id, #widget_type

Instance Method Summary collapse

Methods inherited from AbstractWidget

#mime_type, #title, #widget_info

Constructor Details

#initialize(type, opts) ⇒ TwoColumnsLayout

Returns a new instance of TwoColumnsLayout.



9
10
11
12
13
14
# File 'lib/omf-web/widget/layout/two_columns_layout.rb', line 9

def initialize(type, opts)
  super opts
  wt = opts[:widgets] || opts # support opts[:left] as well as opts[:widgets][:left]
  @left = (wt[:left] || []).map {|w| OMF::Web::Widget.create_widget(w)}
  @right = (wt[:right] || []).map {|w| OMF::Web::Widget.create_widget(w)}      
end

Instance Method Details

#collect_data_sources(ds_set) ⇒ Object



21
22
23
24
25
# File 'lib/omf-web/widget/layout/two_columns_layout.rb', line 21

def collect_data_sources(ds_set)
  @left.each {|w| w.collect_data_sources(ds_set) }
  @right.each {|w| w.collect_data_sources(ds_set) }
  ds_set
end

#contentObject



16
17
18
19
# File 'lib/omf-web/widget/layout/two_columns_layout.rb', line 16

def content()
  OMF::Web::Theme.require 'two_columns_renderer'
  OMF::Web::Theme::TwoColumnsRenderer.new(@left, @right, @opts)      
end

#layout?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/omf-web/widget/layout/two_columns_layout.rb', line 31

def layout?
  return true
end

#nameObject



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

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

#tools_menuObject

Return html for an optional widget tools menu to be added to the widget decoration by the theme.



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

def tools_menu()
  raise "Why are we here"
end