Class: Lapillus::ListView
- Defined in:
- lib/lapillus/containers.rb
Instance Attribute Summary
Attributes inherited from Component
#behaviours, #identifier, #model, #property, #visible
Instance Method Summary collapse
-
#[](index) ⇒ Object
TODO: remove duplication.
- #build_refresh_etc ⇒ Object
- #component(index) ⇒ Object
- #components ⇒ Object
-
#refresh ⇒ Object
TODO write test.
-
#render_container(listview_element) ⇒ Object
TODO: result is a duplicate with super class method!.
-
#size ⇒ Object
NOTE: move to container?.
Methods inherited from Container
#add, add_component, fileuploadfield, image, #initialize, label, listview, panel, password_textfield, #post, textarea, textfield
Methods inherited from Component
#add_behaviour, #behaviour, #has_behaviour?, #has_model?, #has_parent?, #initialize, #on_render, #parent, #path, #render_component, #response_page=, #session, #value, #visible?, #webpage
Constructor Details
This class inherits a constructor from Lapillus::Container
Instance Method Details
#[](index) ⇒ Object
TODO: remove duplication
83 84 85 86 |
# File 'lib/lapillus/containers.rb', line 83 def [](index) index = index.to_i if index.kind_of?(String) return components[index] end |
#build_refresh_etc ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/lapillus/containers.rb', line 59 def build_refresh_etc raise "value is nil, it could be that the model/property is not set correctly!" if value.nil? block = parent.class.block(identifier) raise "listview without a block! #{self.path}" if block.nil? value.each_with_index { |item, index| new_component = ListItem.new(index, item) new_component.parent = self #NOTE: I could do this in the constructor! new_component.instance_exec(item, &block) @components << new_component } end |
#component(index) ⇒ Object
87 88 89 90 |
# File 'lib/lapillus/containers.rb', line 87 def component(index) index = index.to_i if index.kind_of?(String) return components[index] end |
#components ⇒ Object
73 74 75 76 77 78 |
# File 'lib/lapillus/containers.rb', line 73 def components if @components.empty? build_refresh_etc end @components end |
#refresh ⇒ Object
TODO write test
70 71 72 |
# File 'lib/lapillus/containers.rb', line 70 def refresh #TODO write test @components = [] end |
#render_container(listview_element) ⇒ Object
TODO: result is a duplicate with super class method!
93 94 95 96 97 98 99 |
# File 'lib/lapillus/containers.rb', line 93 def render_container(listview_element) result = REXML::Element.new(listview_element) components.each {|container| container.render_children(listview_element,result) } return result end |
#size ⇒ Object
NOTE: move to container?
79 80 81 |
# File 'lib/lapillus/containers.rb', line 79 def size #NOTE: move to container? return components.size end |