Module: Katalyst::Tables::Frontend
- Included in:
- Query::ModalComponent, QueryComponent
- Defined in:
- app/helpers/katalyst/tables/frontend.rb
Overview
View Helper for generating HTML tables. Include in your ApplicationHelper, or similar.
Instance Method Summary collapse
-
#summary_table_with(model:) {|the, nil| ... } ⇒ Object
Construct a new summary table component.
- #table_orderable_with(collection:, url:, id: nil, scope: nil) ⇒ Object
-
#table_pagination_with(collection:) ⇒ Object
Construct pagination navigation for the current page.
-
#table_query_with(collection:, url: url_for, component: nil) ⇒ Object
Construct a new query interface for filtering the current page.
- #table_selection_with(collection:, id: nil, primary_key: :id) ⇒ Object
-
#table_with(collection:, component: nil, header: true, caption: true, generate_ids: false, object_name: nil, partial: nil, as: nil) {|the, the| ... } ⇒ Object
Construct a new table component.
Instance Method Details
#summary_table_with(model:) {|the, nil| ... } ⇒ Object
Construct a new summary table component.
Blocks will receive the table in row-rendering mode (with row and record defined):
82 83 84 85 86 87 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 82 def summary_table_with(model:, **, &) component ||= default_summary_table_component_class component = component.new(model:, **) render(component, &) end |
#table_orderable_with(collection:, url:, id: nil, scope: nil) ⇒ Object
47 48 49 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 47 def table_orderable_with(collection:, url:, id: nil, scope: nil, &) render(Orderable::FormComponent.new(collection:, url:, id:, scope:)) end |
#table_pagination_with(collection:) ⇒ Object
Construct pagination navigation for the current page. Defaults to pagy_nav.
61 62 63 64 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 61 def table_pagination_with(collection:, **) component ||= default_table_pagination_component_class render(component.new(collection:, **)) end |
#table_query_with(collection:, url: url_for, component: nil) ⇒ Object
Construct a new query interface for filtering the current page.
70 71 72 73 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 70 def table_query_with(collection:, url: url_for, component: nil, &) component ||= default_table_query_component_class render(component.new(collection:, url:), &) end |
#table_selection_with(collection:, id: nil, primary_key: :id) ⇒ Object
54 55 56 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 54 def table_selection_with(collection:, id: nil, primary_key: :id, &) render(Selectable::FormComponent.new(collection:, id:, primary_key:), &) end |
#table_with(collection:, component: nil, header: true, caption: true, generate_ids: false, object_name: nil, partial: nil, as: nil) {|the, the| ... } ⇒ Object
Construct a new table component. This entry point supports a large number of options for customizing the table. The most common options are: Blocks will receive the table in row-rendering mode (with row and record defined): If no block is provided when the table is rendered then the table will look for a row partial: In addition to these options, standard HTML attributes can be passed which will be added to the table tag.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/katalyst/tables/frontend.rb', line 27 def table_with(collection:, component: nil, header: true, caption: true, generate_ids: false, object_name: nil, partial: nil, as: nil, **, &) component ||= default_table_component_class component = component.new(collection:, header:, caption:, generate_ids:, object_name:, partial:, as:, **) render(component, &) end |