Class: Olivander::Resources::ResourceFields::ResourceFieldGroup
- Inherits:
-
Object
- Object
- Olivander::Resources::ResourceFields::ResourceFieldGroup
- Defined in:
- app/controllers/concerns/olivander/resources/auto_form_attributes.rb
Instance Attribute Summary collapse
-
#editable ⇒ Object
Returns the value of attribute editable.
-
#fields ⇒ Object
Returns the value of attribute fields.
-
#forced_section ⇒ Object
Returns the value of attribute forced_section.
-
#key ⇒ Object
Returns the value of attribute key.
-
#on_form ⇒ Object
Returns the value of attribute on_form.
-
#on_show ⇒ Object
Returns the value of attribute on_show.
-
#sections ⇒ Object
Returns the value of attribute sections.
Instance Method Summary collapse
- #add_field(sym, type, editable, on_show, on_form) ⇒ Object
-
#initialize(key, editable, on_show, on_form) ⇒ ResourceFieldGroup
constructor
A new instance of ResourceFieldGroup.
- #max_section_columns ⇒ Object
- #next_section(columns = 1) ⇒ Object
Constructor Details
#initialize(key, editable, on_show, on_form) ⇒ ResourceFieldGroup
Returns a new instance of ResourceFieldGroup.
175 176 177 178 179 180 181 182 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 175 def initialize(key, editable, on_show, on_form) self.key = key self.editable = editable self.on_show = on_show self.on_form = on_form self.fields = [] self.sections = [] end |
Instance Attribute Details
#editable ⇒ Object
Returns the value of attribute editable.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def editable @editable end |
#fields ⇒ Object
Returns the value of attribute fields.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def fields @fields end |
#forced_section ⇒ Object
Returns the value of attribute forced_section.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def forced_section @forced_section end |
#key ⇒ Object
Returns the value of attribute key.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def key @key end |
#on_form ⇒ Object
Returns the value of attribute on_form.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def on_form @on_form end |
#on_show ⇒ Object
Returns the value of attribute on_show.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def on_show @on_show end |
#sections ⇒ Object
Returns the value of attribute sections.
173 174 175 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 173 def sections @sections end |
Instance Method Details
#add_field(sym, type, editable, on_show, on_form) ⇒ Object
184 185 186 187 188 189 190 191 192 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 184 def add_field(sym, type, editable, on_show, on_form) e = editable.nil? ? self.editable : editable s = on_show f = on_form section = forced_section || next_section field = ResourceField.new(sym, type, e, s, f, self) section.fields << field fields << field end |
#max_section_columns ⇒ Object
200 201 202 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 200 def max_section_columns sections.collect { |x| x.columns }.max end |
#next_section(columns = 1) ⇒ Object
194 195 196 197 198 |
# File 'app/controllers/concerns/olivander/resources/auto_form_attributes.rb', line 194 def next_section(columns = 1) section = ResourceFieldSection.new(columns) sections << section section end |