Class: Koi::Tables::BodyRowComponent
- Inherits:
-
Katalyst::Tables::BodyRowComponent
- Object
- Katalyst::Tables::BodyRowComponent
- Koi::Tables::BodyRowComponent
- Defined in:
- app/components/koi/tables/body_row_component.rb
Overview
Custom body row component, in order to override the default body cell component
Instance Method Summary collapse
-
#attachment(method, variant: :thumb, **attributes, &block) ⇒ void
Generates a column that renders an ActiveStorage attachment as a downloadable link.
-
#boolean(method, **attributes, &block) ⇒ void
Generates a column from boolean values rendered as “Yes” or “No”.
-
#currency(method, options: {}, **attributes, &block) ⇒ void
Generates a column from numeric values rendered using ‘number_to_currency`.
-
#date(method, format: :admin, **attributes, &block) ⇒ void
Generates a column from date values rendered using I18n.l.
-
#datetime(method, format: :admin, **attributes, &block) ⇒ void
Generates a column from datetime values rendered using I18n.l.
-
#link(method, url: [:admin, @record], link: {}, **attributes, &block) ⇒ void
Generates a column that links to the record’s show page (by default).
-
#number(method, **attributes, &block) ⇒ void
Generates a column from numeric values formatted appropriately.
-
#rich_text(method, **attributes, &block) ⇒ void
Generates a column containing HTML markup.
-
#text(method, **attributes, &block) ⇒ void
Generates a column that renders the contents as text.
Instance Method Details
#attachment(method, variant: :thumb, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column that renders an ActiveStorage attachment as a downloadable link.
137 138 139 |
# File 'app/components/koi/tables/body_row_component.rb', line 137 def (method, variant: :thumb, **attributes, &block) with_column(Body::AttachmentComponent.new(@table, @record, method, variant:, **attributes), &block) end |
#boolean(method, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column from boolean values rendered as “Yes” or “No”.
16 17 18 |
# File 'app/components/koi/tables/body_row_component.rb', line 16 def boolean(method, **attributes, &block) with_column(Body::BooleanComponent.new(@table, @record, method, **attributes), &block) end |
#currency(method, options: {}, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column from numeric values rendered using ‘number_to_currency`.
73 74 75 |
# File 'app/components/koi/tables/body_row_component.rb', line 73 def currency(method, options: {}, **attributes, &block) with_column(Body::CurrencyComponent.new(@table, @record, method, options:, **attributes), &block) end |
#date(method, format: :admin, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column from date values rendered using I18n.l. The default format is :admin, but it can be overridden.
31 32 33 |
# File 'app/components/koi/tables/body_row_component.rb', line 31 def date(method, format: :admin, **attributes, &block) with_column(Body::DateComponent.new(@table, @record, method, format:, **attributes), &block) end |
#datetime(method, format: :admin, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column from datetime values rendered using I18n.l. The default format is :admin, but it can be overridden.
46 47 48 |
# File 'app/components/koi/tables/body_row_component.rb', line 46 def datetime(method, format: :admin, **attributes, &block) with_column(Body::DatetimeComponent.new(@table, @record, method, format:, **attributes), &block) end |
#link(method, url: [:admin, @record], link: {}, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column that links to the record’s show page (by default).
or a symbol to be passed to the route helper
110 111 112 |
# File 'app/components/koi/tables/body_row_component.rb', line 110 def link(method, url: [:admin, @record], link: {}, **attributes, &block) with_column(Body::LinkComponent.new(@table, @record, method, url:, link:, **attributes), &block) end |
#number(method, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column from numeric values formatted appropriately.
59 60 61 |
# File 'app/components/koi/tables/body_row_component.rb', line 59 def number(method, **attributes, &block) with_column(Body::NumberComponent.new(@table, @record, method, **attributes), &block) end |
#rich_text(method, **attributes, &block) ⇒ void
This method assumes that the method returns HTML-safe content. If the content is not HTML-safe, it will be escaped.
This method returns an undefined value.
Generates a column containing HTML markup.
89 90 91 |
# File 'app/components/koi/tables/body_row_component.rb', line 89 def rich_text(method, **attributes, &block) with_column(Body::RichTextComponent.new(@table, @record, method, **attributes), &block) end |
#text(method, **attributes, &block) ⇒ void
This method returns an undefined value.
Generates a column that renders the contents as text.
123 124 125 |
# File 'app/components/koi/tables/body_row_component.rb', line 123 def text(method, **attributes, &block) with_column(BodyCellComponent.new(@table, @record, method, **attributes), &block) end |