Module: ActiveadminTableFooter::TableForExtension
- Defined in:
- lib/activeadmin_table_footer/table_for_extension.rb
Instance Method Summary collapse
- #build(obj, *attrs) ⇒ Object
- #column(*args, &block) ⇒ Object
- #footer_data ⇒ Object
-
#unscoped_collection_for_footer ⇒ Object
The collection AA passes us is the paginated + ordered slice.
Instance Method Details
#build(obj, *attrs) ⇒ Object
5 6 7 8 9 |
# File 'lib/activeadmin_table_footer/table_for_extension.rb', line 5 def build(obj, *attrs) = attrs. @footer_data_proc = .delete(:footer_data) super(obj, *attrs, ) end |
#column(*args, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/activeadmin_table_footer/table_for_extension.rb', line 26 def column(*args, &block) super col = @columns.last if @aatf_footer_row # Tfoot already exists — every subsequent column gets a cell # (with content if it has :footer, empty otherwise) so columns align. (col) elsif (col) # First column with :footer — open tfoot and back-fill empty cells # for all previously-added columns so the row aligns with headers. ensure_tfoot! @columns[0...-1].each { |prior| (prior) } (col) end end |
#footer_data ⇒ Object
11 12 13 14 15 |
# File 'lib/activeadmin_table_footer/table_for_extension.rb', line 11 def return @footer_data if defined?(@footer_data) return (@footer_data = nil) unless @footer_data_proc @footer_data = @footer_data_proc.call() end |
#unscoped_collection_for_footer ⇒ Object
The collection AA passes us is the paginated + ordered slice. Aggregates over “all rows” need the underlying relation without LIMIT/OFFSET/ORDER —otherwise SUM/COUNT on page 2 would only see the page-2 slice and ORDER confuses some aggregate queries.
21 22 23 24 |
# File 'lib/activeadmin_table_footer/table_for_extension.rb', line 21 def return @collection unless @collection.respond_to?(:except) @collection.except(:limit, :offset, :order) end |