Class: Effective::TableRow
- Inherits:
-
Object
- Object
- Effective::TableRow
- Defined in:
- app/models/effective/table_row.rb
Direct Known Subclasses
Effective::TableRows::ArticleEditor, Effective::TableRows::BelongsTo, Effective::TableRows::Boolean, Effective::TableRows::Collection, Effective::TableRows::ContentFor, Effective::TableRows::DateField, Effective::TableRows::DatetimeField, Effective::TableRows::EffectiveAddress, Effective::TableRows::EmailField, Effective::TableRows::FileField, Effective::TableRows::PercentField, Effective::TableRows::PhoneField, Effective::TableRows::PriceField, Effective::TableRows::TextArea, Effective::TableRows::UrlField
Instance Attribute Summary collapse
-
#builder ⇒ Object
Returns the value of attribute builder.
-
#name ⇒ Object
Returns the value of attribute name.
-
#options ⇒ Object
Returns the value of attribute options.
-
#template ⇒ Object
Returns the value of attribute template.
Instance Method Summary collapse
-
#content ⇒ Object
Intended for override.
- #controller_namespace ⇒ Object
- #hint ⇒ Object
-
#initialize(name, options, builder:) ⇒ TableRow
constructor
So this takes in the options for an entire form group.
-
#label ⇒ Object
Humanized label or the label from form.
- #label_content ⇒ Object
-
#to_html(&block) ⇒ Object
Render method.
- #tr_class ⇒ Object
-
#value ⇒ Object
Value from resource.
Constructor Details
#initialize(name, options, builder:) ⇒ TableRow
So this takes in the options for an entire form group.
11 12 13 14 15 16 17 |
# File 'app/models/effective/table_row.rb', line 11 def initialize(name, , builder:) @builder = builder @template = builder.template @name = name @options = end |
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def builder @builder end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def name @name end |
#options ⇒ Object
Returns the value of attribute options.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def @options end |
#template ⇒ Object
Returns the value of attribute template.
5 6 7 |
# File 'app/models/effective/table_row.rb', line 5 def template @template end |
Instance Method Details
#content ⇒ Object
Intended for override
24 25 26 |
# File 'app/models/effective/table_row.rb', line 24 def content value end |
#controller_namespace ⇒ Object
19 20 21 |
# File 'app/models/effective/table_row.rb', line 19 def controller_namespace Effective::Resource.new(template.controller.controller_path).namespace end |
#hint ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'app/models/effective/table_row.rb', line 53 def hint text = [:hint] return if text.blank? content_tag(:div) do content_tag(:small, text.html_safe, class: 'text-muted') end end |
#label ⇒ Object
Humanized label or the label from form
46 47 48 49 50 51 |
# File 'app/models/effective/table_row.rb', line 46 def label text = [:label] || EffectiveResources.et(builder.object, name) prefix = builder.[:prefix] [*prefix, text].join(': ') end |
#label_content ⇒ Object
39 40 41 42 43 |
# File 'app/models/effective/table_row.rb', line 39 def label_content label.html_safe # hint = self.hint # (hint.present? ? "#{label}#{hint}" : label).html_safe end |
#to_html(&block) ⇒ Object
Render method
33 34 35 36 37 |
# File 'app/models/effective/table_row.rb', line 33 def to_html(&block) content_tag(:tr, class: tr_class) do content_tag(:th, label_content) + content_tag(:td, content.presence || '-') end end |
#tr_class ⇒ Object
28 29 30 |
# File 'app/models/effective/table_row.rb', line 28 def tr_class "row-#{name}" # This matches datatables which is "col-#{name}" end |
#value ⇒ Object
Value from resource
63 64 65 |
# File 'app/models/effective/table_row.rb', line 63 def value [:value] || builder.value(name) end |