Skip to content

Commit 045ffcc

Browse files
committed
README: AA 3.5 + 4 screenshots side-by-side with pagination
Replace the single AA 4 + dashboard mix with a paired AA 3.5 / 4 view of the same Subscriptions index (42 rows paginated to 30, footer shows totals across all pages). Drop the dashboard/array screenshot and the styling/footer-values reference tables — too much noise for a README.
1 parent 6005cba commit 045ffcc

1 file changed

Lines changed: 20 additions & 66 deletions

File tree

README.md

Lines changed: 20 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
# activeadmin_table_footer
22

3-
Adds a `<tfoot>` row to ActiveAdmin index tables with a simple per-column DSL
4-
and an optional single-query aggregate shared across cells.
3+
Adds a `<tfoot>` row to ActiveAdmin index tables. Totals are aggregated
4+
across **all pages** of the filtered scope — not just the visible one — in a
5+
single SQL query when you use `footer_data:`.
56

67
Works with **ActiveAdmin 3.5+ and 4.x**.
78

8-
![Subscriptions table with footer totals (AA 4)](https://github.com/activeadmin-plugins/activeadmin_table_footer/releases/download/assets-v1/subscriptions_with_footer_4_0.png)
9+
### ActiveAdmin 4
10+
11+
![Subscriptions index with footer totals on AA 4](https://github.com/activeadmin-plugins/activeadmin_table_footer/releases/download/assets-v1/subscriptions_with_footer_4_0.png)
12+
13+
### ActiveAdmin 3
14+
15+
![Subscriptions index with footer totals on AA 3.5](https://github.com/activeadmin-plugins/activeadmin_table_footer/releases/download/assets-v1/subscriptions_with_footer_3_5.png)
16+
17+
The page shows 30 rows, but the footer row reports the sum across all 42
18+
subscriptions — that's the point.
919

1020
## Install
1121

@@ -36,70 +46,14 @@ ActiveAdmin.register Subscription do
3646
end
3747
```
3848

39-
`footer_data:` runs **once** against the filtered scope (without
40-
`LIMIT/OFFSET/ORDER`), so totals cover every page — not just the visible
41-
slice. The result is exposed inside each `column :x, footer:` Proc via the
42-
`footer_data` method.
43-
44-
## `footer:` values
45-
46-
| Value | Behavior |
47-
|---|---|
48-
| `String` / Numeric | Rendered as-is |
49-
| `:sum`, `:count`, `:average`, `:minimum`, `:maximum` | Aggregate over the (unscoped) collection — SQL for AR, Ruby for plain Arrays |
50-
| `Proc` (arity 0) | Run inside the table — view helpers (`number_to_currency`, `link_to`), Arbre tags (`strong`, `span`), and `footer_data` work |
51-
| `Proc` (arity 1) | Receives the unscoped collection as argument |
52-
| `Arbre::Element` | Inserted directly |
53-
54-
Columns without `:footer` render an empty cell so widths align with the
55-
header. `<tfoot>` itself appears only when at least one column has a footer —
56-
regular tables are untouched.
57-
58-
## Plain-Array tables
59-
60-
Works the same when `table_for` gets a plain Array (custom panels, dashboards):
61-
62-
![Dashboard with in-memory Array table (AA 3)](https://github.com/activeadmin-plugins/activeadmin_table_footer/releases/download/assets-v1/dashboard_array_table_3_5.png)
63-
64-
```ruby
65-
table_for items do # items = [DashboardItem.new(...), ...]
66-
column :name, footer: -> { strong { "Totals" } }
67-
column :qty, footer: :sum
68-
column :price, footer: ->(arr) { number_to_currency(arr.sum(&:price)) }
69-
end
70-
```
71-
72-
Symbol aggregators fall back to `Enumerable` (nil-safe) when the collection
73-
isn't an AR relation.
74-
75-
## Styling
76-
77-
For AA 4 (Tailwind) sensible defaults are applied. Override globally:
78-
79-
```ruby
80-
# config/initializers/activeadmin_table_footer.rb
81-
ActiveadminTableFooter.configure do |c|
82-
c.footer_th_class = "px-4 py-3 bg-blue-50 font-bold"
83-
end
84-
```
85-
86-
For AA 3 (Sass):
87-
88-
```scss
89-
.index_table tfoot td {
90-
background: #f3f4f6;
91-
font-weight: 600;
92-
border-top: 1px solid #ddd;
93-
padding: 8px 10px;
94-
}
95-
```
96-
97-
## Compatibility
49+
The `footer_data:` Proc runs once over the filtered scope (LIMIT/OFFSET/ORDER
50+
are stripped automatically). The result is exposed inside each
51+
`column …, footer: …` Proc via `footer_data`.
9852

99-
| AA | Status |
100-
|---|---|
101-
| 4.0.0.beta22 ||
102-
| 3.5 ||
53+
`footer:` accepts a string, a symbol (`:sum`, `:count`, `:average`,
54+
`:minimum`, `:maximum`), or a Proc — Procs run inside the table view, so view
55+
helpers (`number_to_currency`, `link_to`) and Arbre tags (`strong`, `span`)
56+
work as expected.
10357

10458
## License
10559

0 commit comments

Comments
 (0)