Class: Aurita::GUI::Fieldset
- Defined in:
- lib/aurita-gui/form/fieldset.rb
Instance Attribute Summary collapse
-
#content_dacorator ⇒ Object
Returns the value of attribute content_dacorator.
-
#element_map ⇒ Object
Returns the value of attribute element_map.
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#field_decorator ⇒ Object
Returns the value of attribute field_decorator.
-
#label ⇒ Object
(also: #legend)
Returns the value of attribute label.
-
#legend ⇒ Object
(also: #set_legend, #label=)
Sets the attribute legend.
-
#name ⇒ Object
Returns the value of attribute name.
Attributes inherited from Element
#attrib, #force_closing_tag, #gui_element_id, #parent, #tag
Instance Method Summary collapse
- #add(field_element) ⇒ Object
- #content ⇒ Object
- #each(&block) ⇒ Object
-
#editable! ⇒ Object
Set all form elements to editable mode.
- #fields ⇒ Object
- #fields=(attrib_array) ⇒ Object
-
#initialize(params, &block) ⇒ Fieldset
constructor
A new instance of Fieldset.
- #length ⇒ Object
-
#readonly! ⇒ Object
Set all elements to readonly rendering mode.
- #string ⇒ Object (also: #to_s, #to_str)
Methods inherited from Element
#+, #<<, #[], #[]=, #add_class, #aurita_gui_element, #clear_floating, #css_classes, #find_by_dom_id, #get_content, #has_content?, #id, #id=, #inspect, #js_init_code, #method_missing, #recurse, #remove_class, #set_content, #swap, #to_ary, #touch, #touched?, #type=, #untouch
Methods included from Marshal_Helper_Class_Methods
Methods included from Marshal_Helper
Constructor Details
#initialize(params, &block) ⇒ Fieldset
Returns a new instance of Fieldset.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/aurita-gui/form/fieldset.rb', line 22 def initialize(params, &block) params[:tag] = :fieldset params[:id] = params[:name] unless params[:id] @name = params[:name] @fields = [] @elements = [] @element_map = {} @field_decorator = Aurita::GUI::Form_Field_Wrapper @content_decorator = Aurita::GUI::Form_Content_Wrapper if block_given? then yield.each { |field_element| add(field_element) } end legend_element = params[:legend] legend_element ||= params[:label] set_legend(legend_element) if legend_element params.delete(:legend) params.delete(:label) params.delete(:name) super(params, &block) @content = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Aurita::GUI::Element
Instance Attribute Details
#content_dacorator ⇒ Object
Returns the value of attribute content_dacorator.
20 21 22 |
# File 'lib/aurita-gui/form/fieldset.rb', line 20 def content_dacorator @content_dacorator end |
#element_map ⇒ Object
Returns the value of attribute element_map.
14 15 16 |
# File 'lib/aurita-gui/form/fieldset.rb', line 14 def element_map @element_map end |
#elements ⇒ Object
Returns the value of attribute elements.
16 17 18 |
# File 'lib/aurita-gui/form/fieldset.rb', line 16 def elements @elements end |
#field_decorator ⇒ Object
Returns the value of attribute field_decorator.
18 19 20 |
# File 'lib/aurita-gui/form/fieldset.rb', line 18 def field_decorator @field_decorator end |
#label ⇒ Object Also known as: legend
Returns the value of attribute label.
10 11 12 |
# File 'lib/aurita-gui/form/fieldset.rb', line 10 def label @label end |
#legend=(field) ⇒ Object Also known as: set_legend, label=
Sets the attribute legend
8 9 10 |
# File 'lib/aurita-gui/form/fieldset.rb', line 8 def legend=(value) @legend = value end |
#name ⇒ Object
Returns the value of attribute name.
12 13 14 |
# File 'lib/aurita-gui/form/fieldset.rb', line 12 def name @name end |
Instance Method Details
#add(field_element) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/aurita-gui/form/fieldset.rb', line 64 def add(field_element) @elements << field_element @element_map[field_element.name.to_s] = field_element @fields << field_element.name touch() end |
#content ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/aurita-gui/form/fieldset.rb', line 100 def content return @content if (@content && !@touched) @content = fields().map { |field| element = @element_map[field.to_s] STDERR.puts "What the? #{field.inspect}" unless element @field_decorator.new(element) if element } @content = @content_decorator.new() { @content } @content.add_css_class(:fieldset) if @legend then @content = HTML.fieldset { @legend + @content } else @content = HTML.fieldset { @content} end return @content end |
#each(&block) ⇒ Object
60 61 62 |
# File 'lib/aurita-gui/form/fieldset.rb', line 60 def each(&block) @elements.each(&block) end |
#editable! ⇒ Object
Set all form elements to editable mode.
89 90 91 92 93 94 |
# File 'lib/aurita-gui/form/fieldset.rb', line 89 def editable! @elements.each { |e| e.editable! } touch() end |
#fields ⇒ Object
77 78 79 |
# File 'lib/aurita-gui/form/fieldset.rb', line 77 def fields @fields end |
#fields=(attrib_array) ⇒ Object
72 73 74 75 |
# File 'lib/aurita-gui/form/fieldset.rb', line 72 def fields=(attrib_array) @fields = attrib_array.map { |f| f.to_s } touch() end |
#length ⇒ Object
96 97 98 |
# File 'lib/aurita-gui/form/fieldset.rb', line 96 def length @elements.length end |
#readonly! ⇒ Object
Set all elements to readonly rendering mode.
82 83 84 85 86 87 |
# File 'lib/aurita-gui/form/fieldset.rb', line 82 def readonly! @elements.each { |e| e.readonly! } touch() end |
#string ⇒ Object Also known as: to_s, to_str
121 122 123 |
# File 'lib/aurita-gui/form/fieldset.rb', line 121 def string content().to_s end |