plutonium 0.58.0 → 0.59.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.claude/skills/plutonium-behavior/SKILL.md +4 -0
  3. data/.claude/skills/plutonium-resource/SKILL.md +49 -0
  4. data/CHANGELOG.md +15 -0
  5. data/app/assets/plutonium.css +1 -1
  6. data/app/assets/plutonium.js +7 -2
  7. data/app/assets/plutonium.js.map +2 -2
  8. data/app/assets/plutonium.min.js +1 -1
  9. data/app/assets/plutonium.min.js.map +2 -2
  10. data/docs/.vitepress/config.ts +1 -0
  11. data/docs/reference/resource/actions.md +3 -0
  12. data/docs/reference/resource/export.md +94 -0
  13. data/docs/superpowers/specs/2026-06-12-export-csv-default-action-design.md +306 -0
  14. data/gemfiles/rails_7.gemfile.lock +3 -1
  15. data/gemfiles/rails_8.0.gemfile.lock +3 -1
  16. data/gemfiles/rails_8.1.gemfile.lock +3 -1
  17. data/lib/generators/pu/lite/solid_errors/solid_errors_generator.rb +3 -3
  18. data/lib/plutonium/definition/base.rb +3 -0
  19. data/lib/plutonium/query/filter.rb +4 -1
  20. data/lib/plutonium/query/filters/association.rb +1 -2
  21. data/lib/plutonium/resource/controller.rb +1 -0
  22. data/lib/plutonium/resource/controllers/export_csv.rb +162 -0
  23. data/lib/plutonium/resource/controllers/queryable.rb +1 -0
  24. data/lib/plutonium/resource/policy.rb +21 -0
  25. data/lib/plutonium/routing/mapper_extensions.rb +13 -0
  26. data/lib/plutonium/ui/export_button.rb +86 -0
  27. data/lib/plutonium/ui/layout/base.rb +10 -11
  28. data/lib/plutonium/ui/layout/resource_layout.rb +18 -0
  29. data/lib/plutonium/ui/table/components/toolbar.rb +9 -2
  30. data/lib/plutonium/ui/table/resource.rb +18 -1
  31. data/lib/plutonium/version.rb +1 -1
  32. data/package.json +1 -1
  33. data/plutonium.gemspec +1 -0
  34. data/src/css/components.css +11 -11
  35. data/src/js/controllers/icon_rail_controller.js +11 -2
  36. metadata +20 -2
@@ -131,6 +131,7 @@ export default defineConfig(withMermaid({
131
131
  { text: "Definition", link: "/reference/resource/definition" },
132
132
  { text: "Query", link: "/reference/resource/query" },
133
133
  { text: "Actions", link: "/reference/resource/actions" },
134
+ { text: "CSV Export", link: "/reference/resource/export" },
134
135
  ]
135
136
  },
136
137
  {
@@ -360,6 +360,9 @@ class PostDefinition < ResourceDefinition
360
360
  end
361
361
  ```
362
362
 
363
+ > **CSV export is not an action.** It's a built-in, policy-gated capability with its own
364
+ > button — see [CSV Export](./export.md). Don't declare it with `action :export_csv`.
365
+
363
366
  ## Interaction responses
364
367
 
365
368
  ```ruby
@@ -0,0 +1,94 @@
1
+ # CSV Export
2
+
3
+ Every resource ships with a streamed CSV export, **disabled by default**. It is *not* an
4
+ [action](./actions.md) — it streams a file and opens in a new tab — so it is enabled
5
+ through the policy rather than declared with `action :export_csv`. The route
6
+ (`GET /<resources>/export_csv`) is auto-mounted on every resource; a split "Export"
7
+ button appears on the index page once the policy permits it.
8
+
9
+ ## Enabling
10
+
11
+ Override one policy method:
12
+
13
+ ```ruby
14
+ class PostPolicy < ResourcePolicy
15
+ def export_csv? = true # or `index?` to mirror list access
16
+ end
17
+ ```
18
+
19
+ `export_csv?` defaults to `false`, so export is strictly opt-in. While it returns false
20
+ the button is hidden and the route returns `403`.
21
+
22
+ ## The two exports
23
+
24
+ The control is a split button with two behaviours:
25
+
26
+ | | Source | Filename |
27
+ |---|---|---|
28
+ | **Export** (primary) | The current view — selected scope + filters + search (the index's `?q`), **all** matching rows (not just the visible page) | `posts_<date>.csv` |
29
+ | **Export all** (dropdown) | The entire authorized scope — ignores scope, filters, search, and default scope | `posts_all_<date>.csv` |
30
+
31
+ "Export all" always exports everything the user is authorized to read, regardless of the
32
+ current scope/filters.
33
+
34
+ Both stream via `find_each`, so memory stays flat regardless of row count. `find_each`
35
+ iterates in **primary-key order**, so the file does not preserve the index's current
36
+ sort (filters/search/scope still apply to the primary export).
37
+
38
+ ## Columns
39
+
40
+ The exported columns come from `permitted_attributes_for_export` on the policy (defaults
41
+ to `permitted_attributes_for_index`), with the **primary key always prepended as the
42
+ first column**.
43
+
44
+ ```ruby
45
+ class PostPolicy < ResourcePolicy
46
+ def export_csv? = true
47
+ def permitted_attributes_for_export = [:title, :author, :total, :created_at]
48
+ end
49
+ ```
50
+
51
+ The method is named `_export` (not `_export_csv`) on purpose, so a future export format
52
+ could reuse the same column set.
53
+
54
+ ## Customizing a field's output
55
+
56
+ The `export` definition DSL parallels `display` and `column`. The block receives the
57
+ record and returns the cell value; `label:` overrides the header (default: the humanized
58
+ attribute name).
59
+
60
+ ```ruby
61
+ class PostDefinition < ResourceDefinition
62
+ export :author, label: "Author email", &->(post) { post.author.email }
63
+ export :total, &->(post) { post.total.format }
64
+ end
65
+ ```
66
+
67
+ The column *set* still comes from `permitted_attributes_for_export`; `export` only
68
+ customizes how a listed column is rendered.
69
+
70
+ ## Value resolution
71
+
72
+ For a column **without** an `export` block, the value is read straight off the record
73
+ (`record.public_send(name)`):
74
+
75
+ - **Scalars** (strings, numbers, booleans, dates) are written as-is.
76
+ - **Associations** render as their display label — the same `display_name_of` the index
77
+ uses (e.g. `User #5`, or the record's `to_label`/`name`/`title` if defined) — never
78
+ `#<User:0x…>`. Add an `export` block to export a specific field instead (e.g. the email).
79
+ - A name that is **neither** an `export` block **nor** a real method on the record renders
80
+ the placeholder `<<invalid column>>` rather than aborting the (already-streaming) download.
81
+ To export a computed or virtual column, give it an `export` block — a `label:`-only
82
+ `export` does **not** supply a value, so it too renders the placeholder.
83
+
84
+ ## Notes & limits
85
+
86
+ - Exports run **synchronously** and hold the request (and a DB connection) while
87
+ streaming. A background job that emails a download link is intentionally out of scope
88
+ for now.
89
+ - The export button opens in a new tab (`target="_blank"`), which also keeps Turbo from
90
+ intercepting the streamed download.
91
+ - **CSV/formula injection** is neutralized: any cell whose value begins with `=`, `+`,
92
+ `-`, `@`, or a leading tab/CR is prefixed with a single quote so spreadsheet apps import
93
+ it as literal text instead of executing it as a formula.
94
+ - `csv` is a runtime dependency of Plutonium (it is no longer a Ruby default gem on 3.4+).
@@ -0,0 +1,306 @@
1
+ # Built-in CSV Export — Design
2
+
3
+ **Date:** 2026-06-12
4
+ **Status:** Implemented
5
+
6
+ > **Revision (two exports, toolbar split button).** The shipped feature is a **split
7
+ > button** with two behaviours, not a single export:
8
+ > - **Export** (primary) — the current view (selected scope + filters + search via
9
+ > `?q`). Source: `filtered_resource_collection`. Filename `…_<date>.csv`.
10
+ > - **Export all** (dropdown) — the entire authorized scope, bypassing the query object
11
+ > (`?all=1`). Source: `current_authorized_scope`. Filename `…_all_<date>.csv`.
12
+ >
13
+ > The controller selects the source via `export_csv_collection` (keyed on `params[:all]`).
14
+ > The split button (`Plutonium::UI::ExportButton`, reusing the `resource-drop-down`
15
+ > Stimulus controller) is rendered in the **index table toolbar, just after the Filter
16
+ > button** — `Plutonium::UI::Table::Components::Toolbar` receives an `export:` config
17
+ > built by `Table::Resource#export_toolbar_config` (policy-gated; carries the current
18
+ > `?q`). It is styled with `pu-btn-outline pu-btn-sm` to match the Filter button, with
19
+ > the two halves joined via inline corner styles. A page-limited "export current page"
20
+ > variant and a scope-named primary label were both considered and dropped.
21
+
22
+ ## Goal
23
+
24
+ Ship CSV export as a **built-in, auto-mounted, policy-gated capability** on every Plutonium
25
+ resource — disabled by default, enabled by a one-line policy override, surfaced through a
26
+ **custom export button** on the index page (not the action DSL — exports are special: they stream
27
+ and open in a new tab). This generalizes the `AdminPortal::Concerns::ExportCsv` pattern from the
28
+ achieve-api app into the framework, following Plutonium's existing `typeahead` design
29
+ (auto-mounted route + default policy method + controller concern).
30
+
31
+ The achieve app wired export per-resource by hand (a definition action, a controller concern,
32
+ manual `collection { get :export_csv }` per resource, raw `attribute_names` as columns). Here the
33
+ route auto-mounts, the column set comes from the policy/definition, the per-field output is
34
+ customizable via an `export` DSL, and the export **streams** so it's safe on large tables — the
35
+ only thing a user does to turn it on is enable the policy.
36
+
37
+ ## How users enable it
38
+
39
+ ```ruby
40
+ class PostPolicy < Plutonium::Resource::Policy
41
+ def export_csv? = true # or `index?`
42
+ end
43
+ ```
44
+
45
+ That's it. The route already exists, the button appears on the index page once permitted, the
46
+ column set defaults to the index columns. Optionally:
47
+
48
+ ```ruby
49
+ class PostDefinition < Plutonium::Resource::Definition
50
+ # customize a single field's output + header (column set still comes from the policy)
51
+ export :author, label: "Author email", &->(post) { post.author.email }
52
+ export :total, &->(post) { post.total.format }
53
+ end
54
+ ```
55
+
56
+ ```ruby
57
+ class PostPolicy < Plutonium::Resource::Policy
58
+ def export_csv? = true
59
+ # override the exported column set (defaults to permitted_attributes_for_index)
60
+ def permitted_attributes_for_export = [:title, :author, :total, :created_at]
61
+ end
62
+ ```
63
+
64
+ ## Behavior
65
+
66
+ - The export button is a plain `<a target="_blank">` to `GET /<resources>/export_csv`, carrying
67
+ the **current query string** (`?q[...]`). So it exports **all records matching the current
68
+ filters/search/scope** — not just the visible page (the index is paginated; export is not).
69
+ - `target="_blank"` opens the download in a new tab **and** naturally bypasses Turbo (Turbo
70
+ ignores links with a `target`), so the streamed file download isn't intercepted/rendered.
71
+ - The response **streams** (`send_stream`) — rows are written as they're read in batches, so
72
+ memory stays flat regardless of row count. No row cap.
73
+
74
+ ## Design (5 touch-points)
75
+
76
+ ### 1. Routing — auto-mount (parallels `define_collection_typeahead_actions`)
77
+
78
+ `lib/plutonium/routing/mapper_extensions.rb`. Add `define_collection_export_actions`, invoked
79
+ inside the `interactive_resource_actions` concern:
80
+
81
+ ```ruby
82
+ def define_collection_export_actions
83
+ collection do
84
+ get "export_csv", action: :export_csv, as: :export_csv
85
+ end
86
+ end
87
+ ```
88
+
89
+ Every resource registered via `register_resource` gets `GET /<resources>/export_csv`. No
90
+ per-resource route edits. Path helper: `export_csv_<resources>_path`.
91
+
92
+ ### 2. Controller concern (parallels `Typeahead`)
93
+
94
+ `lib/plutonium/resource/controllers/export_csv.rb`, included in `controller.rb` after
95
+ `CrudActions` (so it can reuse the private `filtered_resource_collection`).
96
+
97
+ ```ruby
98
+ require "csv"
99
+
100
+ module Plutonium::Resource::Controllers::ExportCsv
101
+ extend ActiveSupport::Concern
102
+
103
+ included do
104
+ before_action :authorize_export_csv!, only: :export_csv
105
+ skip_verify_current_authorized_scope only: :export_csv
106
+ end
107
+
108
+ # GET /<resources>/export_csv
109
+ # Streams via a lazy Enumerator response body (NOT send_stream — that
110
+ # lives in ActionController::Live, which would turn every resource
111
+ # action into a threaded streaming response). The primary key is always
112
+ # the first column. Rows are the index's filtered collection.
113
+ def export_csv
114
+ response.headers["Content-Type"] = "text/csv; charset=utf-8"
115
+ response.headers["Content-Disposition"] =
116
+ ActionDispatch::Http::ContentDisposition.format(disposition: "attachment", filename: export_csv_filename)
117
+ response.headers["X-Accel-Buffering"] = "no"
118
+ response.headers["Cache-Control"] = "no-cache"
119
+ self.response_body = export_csv_lines
120
+ end
121
+
122
+ def export_csv_lines
123
+ columns = export_columns # [primary_key] + (exportable_attributes - [primary_key])
124
+ Enumerator.new do |yielder|
125
+ yielder << CSV.generate_line(columns.map { |c| export_csv_header(c) })
126
+ filtered_resource_collection.find_each do |record|
127
+ yielder << CSV.generate_line(columns.map { |c| export_csv_value(record, c) })
128
+ end
129
+ end
130
+ end
131
+
132
+ private
133
+
134
+ def authorize_export_csv!
135
+ authorize_current! resource_class, to: :export_csv?
136
+ end
137
+
138
+ def exportable_attributes
139
+ @exportable_attributes ||= current_policy.send_with_report(:permitted_attributes_for_export)
140
+ end
141
+
142
+ def export_csv_value(record, name)
143
+ defn = current_definition.defined_exports[name]
144
+ (defn && defn[:block]) ? defn[:block].call(record) : record.public_send(name)
145
+ end
146
+
147
+ def export_csv_header(name)
148
+ defn = current_definition.defined_exports[name]
149
+ defn&.dig(:options, :label) || name.to_s.humanize
150
+ end
151
+ end
152
+ ```
153
+
154
+ **Streaming + ordering tradeoff:** `find_each` bounds memory (loads ~1k rows at a time, GC'd per
155
+ batch) but **forces primary-key order** — the file does *not* preserve the index's current sort.
156
+ Filters, search, and scope from `filtered_resource_collection` *are* applied. This is the
157
+ deliberate cost of unbounded streaming; CSV consumers re-sort downstream. (Sort-fidelity would
158
+ require keyset pagination — out of scope.)
159
+
160
+ `send_stream` is available on the framework's Rails floor (Appraisal `rails-7` pins `~> 7.2`;
161
+ `send_stream` landed in 7.2).
162
+
163
+ **Known N+1:** an `export` block that walks an association will N+1 across batches. Acceptable for
164
+ v1 (document it); a preload hook can come later.
165
+
166
+ ### 3. Policy (parallels `permitted_attributes_for_index`)
167
+
168
+ `lib/plutonium/resource/policy.rb`, in the action-methods section:
169
+
170
+ ```ruby
171
+ # Checks if CSV export is permitted.
172
+ # @return [Boolean] false by default — enable per-resource by overriding.
173
+ def export_csv?
174
+ false
175
+ end
176
+
177
+ # Returns the attributes included in an export.
178
+ # @return [Array<Symbol>] defaults to the index columns.
179
+ def permitted_attributes_for_export
180
+ permitted_attributes_for_index
181
+ end
182
+ ```
183
+
184
+ `export_csv?` defaults to `false` — the explicit opt-in gate. `permitted_attributes_for_export`
185
+ is format-agnostic (named `_export`, not `_export_csv`, so a future XLSX/JSON export reuses the
186
+ same column set) and defaults to the index columns: "index columns by default, policy-overridable."
187
+ The controller always prepends `resource_class.primary_key` as the first column (de-duplicated),
188
+ so the id is exported even when the policy's attribute list omits it.
189
+
190
+ `csv` is declared as a gemspec dependency — it is no longer a default gem on Ruby 3.4+.
191
+
192
+ ### 4. Custom export button (NOT a definition action)
193
+
194
+ A dedicated Phlex component, `lib/plutonium/ui/export_button.rb`:
195
+
196
+ ```ruby
197
+ class Plutonium::UI::ExportButton < Plutonium::UI::Component::Base
198
+ def initialize(url:)
199
+ @url = url
200
+ end
201
+
202
+ def view_template
203
+ a(href: @url, target: "_blank", rel: "noopener", class: "pu-btn pu-btn-outline pu-btn-sm") do
204
+ render Phlex::TablerIcons::Download.new(class: "w-4 h-4 shrink-0")
205
+ span { "Export" }
206
+ end
207
+ end
208
+ end
209
+ ```
210
+
211
+ Rendered by `Plutonium::UI::Page::Index` via the existing `render_after_page_header` hook, gated on
212
+ the policy:
213
+
214
+ ```ruby
215
+ def render_after_page_header
216
+ return unless current_policy.allowed_to?(:export_csv?)
217
+ url = resource_url_for(resource_class, action: :export_csv, **export_query_params)
218
+ div(class: "flex justify-end mb-2") { render Plutonium::UI::ExportButton.new(url:) }
219
+ end
220
+ ```
221
+
222
+ `export_query_params` forwards the current `q` (filters/search/scope/sort params) so the export
223
+ matches what the user is looking at. The exact `resource_url_for` signature for appending `action:`
224
+ + query params is verified against the existing `route_options_to_url`/`resource_url_for` usage
225
+ during implementation; the button URL is the only routing detail to confirm.
226
+
227
+ A custom button (rather than a definition action) is the right call because export is not a normal
228
+ navigable action: it streams a file, must open in a new tab, must not be Turbo-driven, and is
229
+ inherently collection-level. Keeping it out of the action DSL avoids bending that DSL around those
230
+ quirks.
231
+
232
+ ### 5. Definition DSL — `export` (parallels `display`/`column`)
233
+
234
+ `lib/plutonium/definition/base.rb`: add `:export` to the `defineable_props` list (alongside
235
+ `:field, :input, :display, :column`). Generates `export :name, **options, &block` and
236
+ `defined_exports`, exactly like `display`/`column`.
237
+
238
+ - `&block` — receives the record, returns the cell value (overrides the raw `public_send`).
239
+ - `label:` — overrides the column header (default `name.to_s.humanize`).
240
+
241
+ The `export` DSL **customizes output of columns**; the column *set* is driven by
242
+ `permitted_attributes_for_export`. An `export` entry for a name not in that set is simply unused;
243
+ conversely the policy method may list virtual/method names (like index columns can), with `export`
244
+ supplying their formatting.
245
+
246
+ ## Data flow
247
+
248
+ ```
249
+ [Export button on index] --target=_blank, ?q=current--> GET /posts/export_csv?q[...]
250
+ → authorize_export_csv! (export_csv? — 403 if false)
251
+ → exportable_attributes (policy.permitted_attributes_for_export)
252
+ → filtered_resource_collection (current_authorized_scope + search/filter/scope; NOT paginated)
253
+ → send_stream: header line, then find_each → one CSV line per record (PK order)
254
+ → text/csv attachment "<plural>_<date>.csv", streamed, opens in new tab
255
+ ```
256
+
257
+ Row-level authorization is the scope itself (`current_authorized_scope`), so
258
+ `skip_verify_current_authorized_scope` is correct here — same as `typeahead`. Tenant/parent scoping
259
+ applies because `filtered_resource_collection` is reused unchanged.
260
+
261
+ ## Error handling
262
+
263
+ - `export_csv?` false → `ActionPolicy::Unauthorized` (403); button is also hidden.
264
+ - Unknown column name in `permitted_attributes_for_export` with no `export` block →
265
+ `NoMethodError` from `public_send` — a definition/policy authoring error that should surface
266
+ loudly (same as an unknown index column).
267
+ - An error raised mid-stream (after headers are sent) cannot un-send the 200/headers — the
268
+ download ends up truncated. Acceptable for v1; the column-resolution paths above are simple.
269
+
270
+ ## Out of scope (YAGNI)
271
+
272
+ - Background-job / email export for very large tables — explicitly deferred (not designed now). The
273
+ `permitted_attributes_for_export` naming leaves the door open for an async path and other formats
274
+ later.
275
+ - A split "export current view / export all" button — there is one export: all rows matching the
276
+ current query.
277
+ - Preserving the index sort in the file (PK order; see tradeoff above).
278
+ - Per-row authorization beyond the scope filter; preload/N+1 handling for `export` blocks.
279
+
280
+ ## Testing
281
+
282
+ Use a dummy-app resource (created via generators per project convention) with the policy enabled:
283
+
284
+ - Route exists: `GET /<resources>/export_csv` resolves.
285
+ - Disabled by default: with default policy, the button is hidden and the route 403s.
286
+ - Enabled: returns a streamed `text/csv` attachment with the right filename.
287
+ - Header row = humanized column names; `export :x, label:` overrides a header.
288
+ - Body rows = one per matching record; `export :x, &block` formats that cell.
289
+ - Respects query: `?q[...]` search/filter narrows the exported rows; pagination does NOT limit them.
290
+ - `permitted_attributes_for_export` override changes the column set.
291
+ - Tenant/parent scoping: export never leaks rows outside `current_authorized_scope`.
292
+
293
+ ## Files
294
+
295
+ | Action | Path |
296
+ |---|---|
297
+ | Modify | `plutonium.gemspec` (add `csv` dependency) |
298
+ | Modify | `lib/plutonium/routing/mapper_extensions.rb` (add `define_collection_export_actions`, call it in concern) |
299
+ | Create | `lib/plutonium/resource/controllers/export_csv.rb` |
300
+ | Modify | `lib/plutonium/resource/controller.rb` (include the concern) |
301
+ | Modify | `lib/plutonium/resource/policy.rb` (`export_csv?`, `permitted_attributes_for_export`) |
302
+ | Create | `lib/plutonium/ui/export_button.rb` |
303
+ | Modify | `lib/plutonium/ui/page/index.rb` (`render_after_page_header` → policy-gated button) |
304
+ | Modify | `lib/plutonium/definition/base.rb` (add `:export` defineable prop) |
305
+ | Create | tests under `test/` + dummy-app resource |
306
+ | Modify | docs (`docs/reference/...`) + relevant `.claude/skills/` skill |
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- plutonium (0.57.0)
4
+ plutonium (0.58.1)
5
5
  action_policy (~> 0.7.0)
6
+ csv
6
7
  listen (~> 3.8)
7
8
  pagy (~> 43.0)
8
9
  phlex (~> 2.0)
@@ -138,6 +139,7 @@ GEM
138
139
  concurrent-ruby (1.3.6)
139
140
  connection_pool (3.0.2)
140
141
  crass (1.0.6)
142
+ csv (3.3.5)
141
143
  date (3.5.1)
142
144
  drb (2.2.3)
143
145
  erb (6.0.2)
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- plutonium (0.57.0)
4
+ plutonium (0.58.1)
5
5
  action_policy (~> 0.7.0)
6
+ csv
6
7
  listen (~> 3.8)
7
8
  pagy (~> 43.0)
8
9
  phlex (~> 2.0)
@@ -135,6 +136,7 @@ GEM
135
136
  concurrent-ruby (1.3.6)
136
137
  connection_pool (3.0.2)
137
138
  crass (1.0.6)
139
+ csv (3.3.5)
138
140
  date (3.5.1)
139
141
  drb (2.2.3)
140
142
  erb (6.0.2)
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- plutonium (0.57.0)
4
+ plutonium (0.58.1)
5
5
  action_policy (~> 0.7.0)
6
+ csv
6
7
  listen (~> 3.8)
7
8
  pagy (~> 43.0)
8
9
  phlex (~> 2.0)
@@ -137,6 +138,7 @@ GEM
137
138
  concurrent-ruby (1.3.6)
138
139
  connection_pool (3.0.2)
139
140
  crass (1.0.6)
141
+ csv (3.3.5)
140
142
  date (3.5.1)
141
143
  drb (2.2.3)
142
144
  erb (6.0.2)
@@ -43,7 +43,7 @@ module Pu
43
43
  # frozen_string_literal: true
44
44
 
45
45
  Rails.application.configure do
46
- config.solid_errors.connects_to = {database: {writing: :#{@db_name}}}
46
+ config.solid_errors.connects_to = {database: {writing: :#{@db_name}, reading: :#{@db_name}}}
47
47
  config.solid_errors.email_from = ENV["SOLID_ERRORS_EMAIL_FROM"].presence
48
48
  config.solid_errors.email_to = ENV["SOLID_ERRORS_EMAIL_TO"].presence
49
49
  # Only deliver notifications when explicitly opted in AND both addresses are
@@ -51,8 +51,8 @@ module Pu
51
51
  # attempt to deliver malformed mail.
52
52
  config.solid_errors.send_emails = ENV["SOLID_ERRORS_SEND_EMAILS"].present? &&
53
53
  config.solid_errors.email_from.present? && config.solid_errors.email_to.present?
54
- config.solid_errors.username = ENV.fetch("SOLID_ERRORS_USERNAME", nil)
55
- config.solid_errors.password = ENV.fetch("SOLID_ERRORS_PASSWORD", nil)
54
+ config.solid_errors.username = ENV["SOLID_ERRORS_USERNAME"]
55
+ config.solid_errors.password = ENV["SOLID_ERRORS_PASSWORD"]
56
56
  end
57
57
  RUBY
58
58
  end
@@ -62,6 +62,9 @@ module Plutonium
62
62
  # fields
63
63
  defineable_props :field, :input, :display, :column
64
64
 
65
+ # export
66
+ defineable_prop :export
67
+
65
68
  # queries
66
69
  defineable_props :filter, :scope
67
70
 
@@ -17,9 +17,12 @@ module Plutonium
17
17
  end
18
18
  end
19
19
 
20
- def initialize(key:)
20
+ attr_reader :resource_class
21
+
22
+ def initialize(key:, resource_class: nil)
21
23
  super()
22
24
  @key = key
25
+ @resource_class = resource_class
23
26
  end
24
27
  end
25
28
  end
@@ -16,10 +16,9 @@ module Plutonium
16
16
  # filter :user, with: :association, class_name: User, scope: ->(s) { s.active }
17
17
  #
18
18
  class Association < Filter
19
- def initialize(class_name: nil, resource_class: nil, scope: nil, multiple: true, **)
19
+ def initialize(class_name: nil, scope: nil, multiple: true, **)
20
20
  super(**)
21
21
  @class_name = class_name
22
- @resource_class = resource_class
23
22
  @scope_proc = scope
24
23
  @multiple = multiple
25
24
  end
@@ -16,6 +16,7 @@ module Plutonium
16
16
  include Plutonium::Resource::Controllers::CrudActions
17
17
  include Plutonium::Resource::Controllers::InteractiveActions
18
18
  include Plutonium::Resource::Controllers::Typeahead
19
+ include Plutonium::Resource::Controllers::ExportCsv
19
20
  include Plutonium::StructuredInputs::ParamsConcern
20
21
 
21
22
  included do