iron_admin 0.7.0 → 0.8.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 (210) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +129 -1
  3. data/README.md +48 -1
  4. data/UPGRADING.md +495 -8
  5. data/app/assets/tailwind/iron_admin/engine.css +79 -4
  6. data/app/components/iron_admin/dashboards/activity_feed_component/item_component.html.haml +6 -9
  7. data/app/components/iron_admin/dashboards/activity_feed_component.html.haml +6 -5
  8. data/app/components/iron_admin/dashboards/activity_feed_component.rb +21 -24
  9. data/app/components/iron_admin/dashboards/chart_component.html.haml +3 -5
  10. data/app/components/iron_admin/dashboards/chart_component.rb +86 -24
  11. data/app/components/iron_admin/dashboards/concerns/themed_card.rb +39 -0
  12. data/app/components/iron_admin/dashboards/metric_card_component.html.haml +8 -7
  13. data/app/components/iron_admin/dashboards/metric_card_component.rb +2 -0
  14. data/app/components/iron_admin/dashboards/progress_component.html.haml +11 -7
  15. data/app/components/iron_admin/dashboards/progress_component.rb +11 -6
  16. data/app/components/iron_admin/dashboards/quick_links_component/link_component.html.haml +8 -9
  17. data/app/components/iron_admin/dashboards/quick_links_component.html.haml +6 -5
  18. data/app/components/iron_admin/dashboards/quick_links_component.rb +4 -12
  19. data/app/components/iron_admin/dashboards/recent_table_component.html.haml +15 -10
  20. data/app/components/iron_admin/dashboards/recent_table_component.rb +49 -0
  21. data/app/components/iron_admin/dashboards/stats_grid_component/stat_component.html.haml +13 -14
  22. data/app/components/iron_admin/dashboards/stats_grid_component.html.haml +1 -0
  23. data/app/components/iron_admin/dashboards/stats_grid_component.rb +9 -11
  24. data/app/components/iron_admin/filters/bar_component.html.haml +8 -6
  25. data/app/components/iron_admin/filters/bar_component.rb +56 -9
  26. data/app/components/iron_admin/filters/control_styles.rb +82 -0
  27. data/app/components/iron_admin/filters/date_range_component.html.haml +9 -4
  28. data/app/components/iron_admin/filters/date_range_component.rb +10 -6
  29. data/app/components/iron_admin/filters/search_component.html.haml +4 -4
  30. data/app/components/iron_admin/filters/search_component.rb +3 -5
  31. data/app/components/iron_admin/filters/select_filter_component.html.haml +1 -1
  32. data/app/components/iron_admin/filters/select_filter_component.rb +5 -16
  33. data/app/components/iron_admin/form/belongs_to_autocomplete_component.html.haml +9 -5
  34. data/app/components/iron_admin/form/belongs_to_autocomplete_component.rb +10 -8
  35. data/app/components/iron_admin/form/belongs_to_component.html.haml +2 -2
  36. data/app/components/iron_admin/form/belongs_to_component.rb +4 -18
  37. data/app/components/iron_admin/form/checkbox_component.rb +2 -3
  38. data/app/components/iron_admin/form/concerns/form_input_behavior.rb +1 -1
  39. data/app/components/iron_admin/form/control_classes.rb +108 -0
  40. data/app/components/iron_admin/form/date_picker_component.rb +3 -7
  41. data/app/components/iron_admin/form/field_wrapper_component.html.haml +3 -3
  42. data/app/components/iron_admin/form/field_wrapper_component.rb +3 -3
  43. data/app/components/iron_admin/form/nested_form_component.html.haml +4 -5
  44. data/app/components/iron_admin/form/nested_form_component.rb +12 -2
  45. data/app/components/iron_admin/form/select_component.html.haml +1 -1
  46. data/app/components/iron_admin/form/select_component.rb +2 -16
  47. data/app/components/iron_admin/form/text_input_component.rb +1 -5
  48. data/app/components/iron_admin/form/textarea_component.rb +1 -5
  49. data/app/components/iron_admin/layout/flash_component.html.haml +1 -1
  50. data/app/components/iron_admin/layout/flash_component.rb +4 -3
  51. data/app/components/iron_admin/layout/navbar_component.html.haml +15 -9
  52. data/app/components/iron_admin/layout/navbar_component.rb +29 -1
  53. data/app/components/iron_admin/layout/shell_component.html.haml +4 -4
  54. data/app/components/iron_admin/layout/shell_component.rb +16 -3
  55. data/app/components/iron_admin/layout/sidebar_component.html.haml +21 -25
  56. data/app/components/iron_admin/layout/sidebar_component.rb +76 -1
  57. data/app/components/iron_admin/layout/theme_switcher_component.html.haml +15 -0
  58. data/app/components/iron_admin/layout/theme_switcher_component.rb +74 -0
  59. data/app/components/iron_admin/resources/actions_component.html.haml +15 -8
  60. data/app/components/iron_admin/resources/actions_component.rb +34 -2
  61. data/app/components/iron_admin/resources/breadcrumb_component.html.haml +3 -3
  62. data/app/components/iron_admin/resources/breadcrumb_component.rb +8 -7
  63. data/app/components/iron_admin/resources/bulk_actions_component.html.haml +9 -8
  64. data/app/components/iron_admin/resources/bulk_actions_component.rb +47 -4
  65. data/app/components/iron_admin/resources/data_table_component.html.haml +15 -15
  66. data/app/components/iron_admin/resources/data_table_component.rb +34 -3
  67. data/app/components/iron_admin/resources/related_list_component.html.haml +7 -7
  68. data/app/components/iron_admin/resources/related_list_component.rb +26 -2
  69. data/app/components/iron_admin/resources/show_field_component.html.haml +3 -3
  70. data/app/components/iron_admin/resources/show_field_component.rb +10 -4
  71. data/app/components/iron_admin/resources/styles.rb +136 -0
  72. data/app/components/iron_admin/ui/alert_component.html.haml +2 -2
  73. data/app/components/iron_admin/ui/alert_component.rb +27 -31
  74. data/app/components/iron_admin/ui/badge_component.rb +40 -20
  75. data/app/components/iron_admin/ui/button_component.rb +37 -11
  76. data/app/components/iron_admin/ui/card_component.rb +3 -3
  77. data/app/components/iron_admin/ui/dropdown_component.html.haml +1 -1
  78. data/app/components/iron_admin/ui/dropdown_component.rb +34 -13
  79. data/app/components/iron_admin/ui/empty_state_component.html.haml +4 -5
  80. data/app/components/iron_admin/ui/empty_state_component.rb +2 -2
  81. data/app/components/iron_admin/ui/modal_component.html.haml +5 -5
  82. data/app/components/iron_admin/ui/modal_component.rb +6 -4
  83. data/app/components/iron_admin/ui/pagination_component.html.haml +14 -14
  84. data/app/components/iron_admin/ui/pagination_component.rb +26 -9
  85. data/app/components/iron_admin/ui/scopes_component.html.haml +2 -2
  86. data/app/components/iron_admin/ui/scopes_component.rb +44 -11
  87. data/app/components/iron_admin/ui/tooltip_component.rb +11 -4
  88. data/app/controllers/iron_admin/application_controller.rb +58 -4
  89. data/app/controllers/iron_admin/audit_controller.rb +30 -6
  90. data/app/controllers/iron_admin/concerns/action_executable.rb +37 -0
  91. data/app/controllers/iron_admin/concerns/assignable_references.rb +149 -0
  92. data/app/controllers/iron_admin/concerns/authorizable.rb +11 -0
  93. data/app/controllers/iron_admin/concerns/blank_password_filterable.rb +21 -0
  94. data/app/controllers/iron_admin/concerns/event_emittable.rb +47 -7
  95. data/app/controllers/iron_admin/concerns/filterable.rb +34 -9
  96. data/app/controllers/iron_admin/concerns/nested_permittable.rb +5 -3
  97. data/app/controllers/iron_admin/concerns/nested_tenant_check.rb +159 -0
  98. data/app/controllers/iron_admin/concerns/polymorphic_references.rb +131 -0
  99. data/app/controllers/iron_admin/concerns/scopeable.rb +54 -7
  100. data/app/controllers/iron_admin/concerns/searchable.rb +3 -3
  101. data/app/controllers/iron_admin/concerns/tenant_assignable.rb +118 -0
  102. data/app/controllers/iron_admin/concerns/tenant_containment.rb +146 -0
  103. data/app/controllers/iron_admin/exports_controller.rb +2 -2
  104. data/app/controllers/iron_admin/imports_controller.rb +1 -1
  105. data/app/controllers/iron_admin/resources_controller.rb +48 -41
  106. data/app/controllers/iron_admin/search_controller.rb +1 -2
  107. data/app/controllers/iron_admin/themes_controller.rb +50 -0
  108. data/app/controllers/iron_admin/tools_controller.rb +58 -5
  109. data/app/helpers/iron_admin/action_form_helper.rb +19 -0
  110. data/app/helpers/iron_admin/application_helper.rb +93 -16
  111. data/app/helpers/iron_admin/assignable_records_helper.rb +32 -0
  112. data/app/helpers/iron_admin/component_overrides_helper.rb +9 -4
  113. data/app/helpers/iron_admin/field_display_helper.rb +88 -43
  114. data/app/helpers/iron_admin/related_records_helper.rb +51 -0
  115. data/app/helpers/iron_admin/theme_helper.rb +56 -46
  116. data/app/javascript/iron_admin/controllers/cp_bulk_select_controller.js +12 -0
  117. data/app/javascript/iron_admin/controllers/cp_chart_controller.js +4 -0
  118. data/app/javascript/iron_admin/controllers/cp_disclosure_controller.js +19 -0
  119. data/app/javascript/iron_admin/controllers/cp_search_shortcut_controller.js +39 -0
  120. data/app/javascript/iron_admin/index.js +4 -0
  121. data/app/views/iron_admin/audit/index.html.haml +78 -81
  122. data/app/views/iron_admin/dashboard/index.html.haml +10 -9
  123. data/app/views/iron_admin/form/_action_field.html.haml +50 -0
  124. data/app/views/iron_admin/form/_nested_row.html.haml +18 -13
  125. data/app/views/iron_admin/imports/new.html.haml +14 -13
  126. data/app/views/iron_admin/imports/preview.html.haml +24 -21
  127. data/app/views/iron_admin/resources/_form.html.haml +70 -68
  128. data/app/views/iron_admin/resources/action_form.html.haml +16 -59
  129. data/app/views/iron_admin/resources/bulk_action_form.html.haml +20 -58
  130. data/app/views/iron_admin/resources/edit.html.haml +3 -3
  131. data/app/views/iron_admin/resources/index.html.haml +87 -74
  132. data/app/views/iron_admin/resources/new.html.haml +2 -2
  133. data/app/views/iron_admin/resources/show.html.haml +53 -41
  134. data/app/views/iron_admin/search/index.html.haml +17 -9
  135. data/app/views/iron_admin/shared/_pagination.html.haml +13 -10
  136. data/app/views/iron_admin/shared/error.html.haml +16 -12
  137. data/app/views/iron_admin/tools/action_form.html.haml +9 -55
  138. data/app/views/iron_admin/tools/show.html.haml +4 -5
  139. data/app/views/layouts/iron_admin/_document_head.html.haml +24 -0
  140. data/app/views/layouts/iron_admin/application.html.haml +4 -17
  141. data/app/views/layouts/iron_admin/minimal.html.haml +7 -0
  142. data/config/importmap.rb +2 -0
  143. data/config/locales/en.yml +23 -0
  144. data/config/routes.rb +1 -0
  145. data/docs/FAQ.md +87 -37
  146. data/docs/README.md +8 -2
  147. data/docs/components/README.md +6 -2
  148. data/docs/components/dashboard-components.md +24 -35
  149. data/docs/components/filter-components.md +44 -92
  150. data/docs/components/form-components.md +16 -32
  151. data/docs/components/resource-components.md +46 -27
  152. data/docs/components/ui-components.md +44 -26
  153. data/docs/getting-started/installation.md +5 -1
  154. data/docs/getting-started/quick-start.md +36 -23
  155. data/docs/guides/authentication.md +182 -42
  156. data/docs/guides/components.md +97 -15
  157. data/docs/guides/custom-adapters.md +24 -4
  158. data/docs/guides/dashboard.md +68 -44
  159. data/docs/guides/export.md +24 -8
  160. data/docs/guides/extending.md +206 -51
  161. data/docs/guides/fields.md +229 -70
  162. data/docs/guides/imports.md +33 -18
  163. data/docs/guides/resources.md +333 -111
  164. data/docs/guides/theming.md +930 -58
  165. data/docs/guides/troubleshooting.md +7 -3
  166. data/docs/plugin-system-design.md +8 -7
  167. data/docs/reference/configuration.md +51 -16
  168. data/docs/reference/routes.md +1 -0
  169. data/docs/reference/theme-properties.md +101 -38
  170. data/lib/generators/iron_admin/install/templates/initializer.rb.tt +7 -2
  171. data/lib/generators/iron_admin/install_audit/templates/create_iron_admin_audit_entries.rb.tt +2 -0
  172. data/lib/iron_admin/action_field.rb +11 -0
  173. data/lib/iron_admin/adapters/active_record.rb +95 -0
  174. data/lib/iron_admin/adapters/base.rb +107 -0
  175. data/lib/iron_admin/adapters/http/query.rb +21 -0
  176. data/lib/iron_admin/adapters/http.rb +84 -4
  177. data/lib/iron_admin/adapters/mongoid.rb +96 -2
  178. data/lib/iron_admin/audit_log.rb +64 -6
  179. data/lib/iron_admin/authentication_warning.rb +31 -0
  180. data/lib/iron_admin/concerns/filter_definable.rb +15 -1
  181. data/lib/iron_admin/concerns/nestable.rb +25 -0
  182. data/lib/iron_admin/concerns/scope_countable.rb +56 -0
  183. data/lib/iron_admin/concerns/soft_deletable.rb +28 -9
  184. data/lib/iron_admin/configuration/components.rb +14 -3
  185. data/lib/iron_admin/configuration/theme/neutral_defaults.rb +179 -0
  186. data/lib/iron_admin/configuration/theme.rb +292 -87
  187. data/lib/iron_admin/configuration.rb +340 -45
  188. data/lib/iron_admin/dashboard.rb +22 -38
  189. data/lib/iron_admin/engine.rb +16 -2
  190. data/lib/iron_admin/errors.rb +3 -0
  191. data/lib/iron_admin/field.rb +78 -17
  192. data/lib/iron_admin/field_inferrer.rb +61 -3
  193. data/lib/iron_admin/field_override_warning.rb +67 -0
  194. data/lib/iron_admin/import/import_preview.rb +56 -7
  195. data/lib/iron_admin/import/importer.rb +91 -14
  196. data/lib/iron_admin/import/tenant_precheck.rb +67 -0
  197. data/lib/iron_admin/plugin/registration.rb +64 -0
  198. data/lib/iron_admin/plugin_registry.rb +3 -2
  199. data/lib/iron_admin/policy.rb +22 -12
  200. data/lib/iron_admin/policy_coverage_warning.rb +46 -0
  201. data/lib/iron_admin/request_context.rb +18 -0
  202. data/lib/iron_admin/resource.rb +218 -77
  203. data/lib/iron_admin/resource_registry.rb +86 -13
  204. data/lib/iron_admin/scope_counts.rb +73 -0
  205. data/lib/iron_admin/tenant_scope.rb +30 -0
  206. data/lib/iron_admin/tool.rb +61 -12
  207. data/lib/iron_admin/tool_context.rb +10 -6
  208. data/lib/iron_admin/version.rb +1 -1
  209. data/lib/iron_admin.rb +29 -2
  210. metadata +37 -7
@@ -19,20 +19,16 @@ IronAdmin::Dashboards::ChartComponent.new(
19
19
  **Example:**
20
20
 
21
21
  ```haml
22
- = render IronAdmin::Dashboards::ChartComponent.new(
23
- title: "Monthly Signups",
22
+ = render IronAdmin::Dashboards::ChartComponent.new(title: "Monthly Signups",
24
23
  type: :line,
25
24
  data: @monthly_signups.values,
26
25
  labels: @monthly_signups.keys,
27
- height: 250
28
- )
26
+ height: 250)
29
27
 
30
- = render IronAdmin::Dashboards::ChartComponent.new(
31
- title: "Users by Role",
28
+ = render IronAdmin::Dashboards::ChartComponent.new(title: "Users by Role",
32
29
  type: :pie,
33
30
  data: @role_counts.values,
34
- labels: @role_counts.keys
35
- )
31
+ labels: @role_counts.keys)
36
32
  ```
37
33
 
38
34
  ---
@@ -47,6 +43,11 @@ IronAdmin::Dashboards::StatsGridComponent.new(
47
43
  )
48
44
  ```
49
45
 
46
+ The grid has one column on phones and two from `sm`. Three columns start at `lg` and four at
47
+ `xl`, as in the dashboard's metric grid: from `lg` the sidebar leaves the page about 700px, too
48
+ narrow for four cards. The cards are spaced like the metric cards (`gap-6`). In each card the label
49
+ wraps beside the icon, and the value sits on its own row below them.
50
+
50
51
  **Slots:**
51
52
  - `stats` - Individual stat items (renders `StatComponent`)
52
53
 
@@ -86,7 +87,7 @@ IronAdmin::Dashboards::ActivityFeedComponent.new(
86
87
  - `description` - Activity description
87
88
  - `timestamp` - Time or string
88
89
  - `icon` - Heroicon name
89
- - `icon_color` - `:green`, `:red`, `:blue`, `:yellow`, `:gray`
90
+ - `icon_color` - a color name of the theme's `badge_palette` (`:green`, `:red`, `:yellow`, `:blue`, `:indigo`, `:purple`, `:pink`, `:orange`, `:teal` or `:gray`; default `:blue`). An unknown color uses `:gray`
90
91
  - `href` - Optional link
91
92
 
92
93
  **Example:**
@@ -94,13 +95,11 @@ IronAdmin::Dashboards::ActivityFeedComponent.new(
94
95
  ```haml
95
96
  = render IronAdmin::Dashboards::ActivityFeedComponent.new(title: "Recent Activity") do |feed|
96
97
  - @recent_activities.each do |activity|
97
- - feed.with_item(
98
- description: activity.description,
98
+ - feed.with_item(description: activity.description,
99
99
  timestamp: activity.created_at,
100
100
  icon: activity.icon,
101
101
  icon_color: activity.color,
102
- href: activity_path(activity)
103
- )
102
+ href: activity_path(activity))
104
103
  ```
105
104
 
106
105
  ---
@@ -150,11 +149,9 @@ IronAdmin::Dashboards::MetricCardComponent.new(
150
149
  **Example:**
151
150
 
152
151
  ```haml
153
- = render IronAdmin::Dashboards::MetricCardComponent.new(
154
- name: :monthly_revenue,
152
+ = render IronAdmin::Dashboards::MetricCardComponent.new(name: :monthly_revenue,
155
153
  value: 15000.50,
156
- format: :currency
157
- )
154
+ format: :currency)
158
155
  ```
159
156
 
160
157
  ---
@@ -184,11 +181,9 @@ IronAdmin::Dashboards::RecentTableComponent.new(
184
181
  **Example:**
185
182
 
186
183
  ```haml
187
- = render IronAdmin::Dashboards::RecentTableComponent.new(
188
- resource_name: :order,
184
+ = render IronAdmin::Dashboards::RecentTableComponent.new(resource_name: :order,
189
185
  records: Order.limit(5),
190
- current_user: iron_admin_current_user
191
- )
186
+ current_user: iron_admin_current_user)
192
187
  ```
193
188
 
194
189
  ---
@@ -202,18 +197,16 @@ Combine components to create a complete dashboard:
202
197
  -# Stats row
203
198
  = render IronAdmin::Dashboards::StatsGridComponent.new(columns: 4) do |grid|
204
199
  - grid.with_stat(label: "Users", value: User.count)
205
- - grid.with_stat(label: "Revenue", value: number_to_currency(Payment.sum(:amount)), format: :currency)
200
+ - grid.with_stat(label: "Revenue", value: number_to_currency(Payment.sum(:amount)))
206
201
  - grid.with_stat(label: "Orders", value: Order.count)
207
202
  - grid.with_stat(label: "Conversion", value: "3.2%")
208
203
 
209
204
  .grid.grid-cols-1.lg:grid-cols-2.gap-8
210
205
  -# Chart
211
- = render IronAdmin::Dashboards::ChartComponent.new(
212
- title: "Signups Over Time",
206
+ = render IronAdmin::Dashboards::ChartComponent.new(title: "Signups Over Time",
213
207
  type: :line,
214
208
  data: @signup_data,
215
- labels: @signup_labels
216
- )
209
+ labels: @signup_labels)
217
210
 
218
211
  -# Activity feed
219
212
  = render IronAdmin::Dashboards::ActivityFeedComponent.new do |feed|
@@ -222,13 +215,9 @@ Combine components to create a complete dashboard:
222
215
 
223
216
  -# Recent tables
224
217
  .grid.grid-cols-1.lg:grid-cols-2.gap-8
225
- = render IronAdmin::Dashboards::RecentTableComponent.new(
226
- resource_name: :user,
227
- records: User.order(created_at: :desc).limit(5)
228
- )
229
-
230
- = render IronAdmin::Dashboards::RecentTableComponent.new(
231
- resource_name: :order,
232
- records: Order.order(created_at: :desc).limit(5)
233
- )
218
+ = render IronAdmin::Dashboards::RecentTableComponent.new(resource_name: :user,
219
+ records: User.order(created_at: :desc).limit(5))
220
+
221
+ = render IronAdmin::Dashboards::RecentTableComponent.new(resource_name: :order,
222
+ records: Order.order(created_at: :desc).limit(5))
234
223
  ```
@@ -22,12 +22,10 @@ when `resource_class:` is given, and the placeholder otherwise.
22
22
  **Example:**
23
23
 
24
24
  ```haml
25
- = render IronAdmin::Filters::SearchComponent.new(
26
- form_url: resources_path,
25
+ = render IronAdmin::Filters::SearchComponent.new(form_url: resources_path,
27
26
  placeholder: "Search users...",
28
27
  value: params[:q],
29
- hidden_params: { scope: params[:scope] }
30
- )
28
+ hidden_params: { scope: params[:scope] })
31
29
  ```
32
30
 
33
31
  ---
@@ -48,12 +46,10 @@ IronAdmin::Filters::SelectFilterComponent.new(
48
46
  **Example:**
49
47
 
50
48
  ```haml
51
- = render IronAdmin::Filters::SelectFilterComponent.new(
52
- name: :role,
49
+ = render IronAdmin::Filters::SelectFilterComponent.new(name: :role,
53
50
  options: [["Admin", "admin"], ["User", "user"], ["Guest", "guest"]],
54
51
  label: "User Role",
55
- selected: params.dig(:filters, :role)
56
- )
52
+ selected: params.dig(:filters, :role))
57
53
  ```
58
54
 
59
55
  ---
@@ -74,73 +70,36 @@ IronAdmin::Filters::DateRangeComponent.new(
74
70
  **Example:**
75
71
 
76
72
  ```haml
77
- = render IronAdmin::Filters::DateRangeComponent.new(
78
- name: :created_at,
73
+ = render IronAdmin::Filters::DateRangeComponent.new(name: :created_at,
79
74
  label: "Created Between",
80
75
  from_value: params.dig(:filters, :created_at_from),
81
- to_value: params.dig(:filters, :created_at_to)
82
- )
76
+ to_value: params.dig(:filters, :created_at_to))
83
77
  ```
84
78
 
85
79
  ---
86
80
 
87
- ## StringFilterComponent
81
+ ## String and number filters
88
82
 
89
- Text input with an operator dropdown for string matching.
83
+ The index draws a string filter and a number filter inline. There is no
84
+ `StringFilterComponent` or `NumberFilterComponent`. Declare the filter on the
85
+ resource:
90
86
 
91
87
  ```ruby
92
- IronAdmin::Filters::StringFilterComponent.new(
93
- name: :name, # Required: filter parameter name
94
- label: nil, # Optional: label text (auto-generated from name)
95
- value: nil, # Optional: current filter value
96
- operator: "contains" # Optional: current operator (default: "contains")
97
- )
88
+ module IronAdmin
89
+ module Resources
90
+ class ProductResource < IronAdmin::Resource
91
+ filter :name, type: :string
92
+ filter :price, type: :number
93
+ end
94
+ end
95
+ end
98
96
  ```
99
97
 
100
- **Operators:** `contains`, `equals`, `starts_with`, `ends_with`
101
-
102
- **Example:**
103
-
104
- ```haml
105
- = render IronAdmin::Filters::StringFilterComponent.new(
106
- name: :name,
107
- label: "Customer Name",
108
- value: params.dig(:filters, :name),
109
- operator: params.dig(:filters, :name_operator) || "contains"
110
- )
111
- ```
112
-
113
- ---
114
-
115
- ## NumberFilterComponent
116
-
117
- Number input with an operator dropdown for numeric comparisons.
118
-
119
- ```ruby
120
- IronAdmin::Filters::NumberFilterComponent.new(
121
- name: :price, # Required: filter parameter name
122
- label: nil, # Optional: label text (auto-generated from name)
123
- value: nil, # Optional: current filter value
124
- max_value: nil, # Optional: upper bound for "between" operator
125
- operator: "equals" # Optional: current operator (default: "equals")
126
- )
127
- ```
128
-
129
- **Operators:** `equals`, `greater_than`, `less_than`, `between`
130
-
131
- When the `between` operator is selected, a second input for the upper bound is displayed.
132
-
133
- **Example:**
134
-
135
- ```haml
136
- = render IronAdmin::Filters::NumberFilterComponent.new(
137
- name: :price,
138
- label: "Price",
139
- value: params.dig(:filters, :price),
140
- max_value: params.dig(:filters, :price_max),
141
- operator: params.dig(:filters, :price_operator) || "equals"
142
- )
143
- ```
98
+ A `:string` filter (`filter :name, type: :string`) offers contains, equals,
99
+ starts_with and ends_with. A `:number` filter (`filter :price, type: :number`)
100
+ offers equals, greater_than, less_than and between, and shows a second input
101
+ when the operator is between. The [resources guide](../guides/resources.md#filter-types)
102
+ lists both.
144
103
 
145
104
  ---
146
105
 
@@ -153,34 +112,35 @@ IronAdmin::Filters::BarComponent.new(
153
112
  form_url: "/admin/users", # Required: form submit URL
154
113
  scope: nil, # Optional: current scope
155
114
  query: nil, # Optional: current search query
156
- active_count: 0 # Optional: number of active filters
115
+ active_count: 0, # Optional: number of active filters
116
+ current_sort: nil, # Optional: current sort column
117
+ current_direction: nil # Optional: current sort direction
157
118
  )
158
119
  ```
159
120
 
121
+ Applying the filters keeps `scope`, `query` (as `q`) and, when they are set, `current_sort`
122
+ and `current_direction` (as `sort` and `direction`) as hidden fields. The Clear link keeps
123
+ them too and drops only the filters. These keywords match the ones the `filter_bar` override
124
+ slot passes.
125
+
160
126
  **Slots:**
161
127
  - `filters` - Individual filter components
162
128
 
163
129
  **Example:**
164
130
 
165
131
  ```haml
166
- = render IronAdmin::Filters::BarComponent.new(
167
- form_url: resources_path,
168
- active_count: @active_filter_count
169
- ) do |bar|
132
+ = render IronAdmin::Filters::BarComponent.new(form_url: resources_path,
133
+ active_count: @active_filter_count) do |bar|
170
134
 
171
135
  - bar.with_filter do
172
- = render IronAdmin::Filters::SelectFilterComponent.new(
173
- name: :status,
136
+ = render IronAdmin::Filters::SelectFilterComponent.new(name: :status,
174
137
  options: status_options,
175
- selected: params.dig(:filters, :status)
176
- )
138
+ selected: params.dig(:filters, :status))
177
139
 
178
140
  - bar.with_filter do
179
- = render IronAdmin::Filters::DateRangeComponent.new(
180
- name: :created_at,
141
+ = render IronAdmin::Filters::DateRangeComponent.new(name: :created_at,
181
142
  from_value: params.dig(:filters, :created_at_from),
182
- to_value: params.dig(:filters, :created_at_to)
183
- )
143
+ to_value: params.dig(:filters, :created_at_to))
184
144
  ```
185
145
 
186
146
  ---
@@ -192,25 +152,17 @@ Typical filter bar setup:
192
152
  ```haml
193
153
  .flex.items-center.gap-4
194
154
  -# Search
195
- = render IronAdmin::Filters::SearchComponent.new(
196
- form_url: resources_path,
197
- value: params[:q]
198
- )
155
+ = render IronAdmin::Filters::SearchComponent.new(form_url: resources_path,
156
+ value: params[:q])
199
157
 
200
158
  -# Filter dropdown
201
- = render IronAdmin::Filters::BarComponent.new(
202
- form_url: resources_path,
203
- active_count: active_filter_count
204
- ) do |bar|
159
+ = render IronAdmin::Filters::BarComponent.new(form_url: resources_path,
160
+ active_count: active_filter_count) do |bar|
205
161
 
206
162
  - bar.with_filter do
207
- = render IronAdmin::Filters::SelectFilterComponent.new(
208
- name: :role,
209
- options: role_options
210
- )
163
+ = render IronAdmin::Filters::SelectFilterComponent.new(name: :role,
164
+ options: role_options)
211
165
 
212
166
  - bar.with_filter do
213
- = render IronAdmin::Filters::DateRangeComponent.new(
214
- name: :created_at
215
- )
167
+ = render IronAdmin::Filters::DateRangeComponent.new(name: :created_at)
216
168
  ```
@@ -21,12 +21,10 @@ IronAdmin::Form::TextInputComponent.new(
21
21
  **Example:**
22
22
 
23
23
  ```haml
24
- = render IronAdmin::Form::TextInputComponent.new(
25
- name: :email,
24
+ = render IronAdmin::Form::TextInputComponent.new(name: :email,
26
25
  value: @user.email,
27
26
  type: :email,
28
- placeholder: "user@example.com"
29
- )
27
+ placeholder: "user@example.com")
30
28
  ```
31
29
 
32
30
  ---
@@ -49,12 +47,10 @@ IronAdmin::Form::SelectComponent.new(
49
47
  **Example:**
50
48
 
51
49
  ```haml
52
- = render IronAdmin::Form::SelectComponent.new(
53
- name: :role,
50
+ = render IronAdmin::Form::SelectComponent.new(name: :role,
54
51
  options: [["Admin", "admin"], ["User", "user"], ["Guest", "guest"]],
55
52
  selected: @user.role,
56
- include_blank: "Select a role..."
57
- )
53
+ include_blank: "Select a role...")
58
54
  ```
59
55
 
60
56
  ---
@@ -76,11 +72,9 @@ IronAdmin::Form::CheckboxComponent.new(
76
72
  **Example:**
77
73
 
78
74
  ```haml
79
- = render IronAdmin::Form::CheckboxComponent.new(
80
- name: :email_notifications,
75
+ = render IronAdmin::Form::CheckboxComponent.new(name: :email_notifications,
81
76
  label: "Receive email notifications",
82
- checked: @user.email_notifications
83
- )
77
+ checked: @user.email_notifications)
84
78
  ```
85
79
 
86
80
  ---
@@ -104,12 +98,10 @@ IronAdmin::Form::TextareaComponent.new(
104
98
  **Example:**
105
99
 
106
100
  ```haml
107
- = render IronAdmin::Form::TextareaComponent.new(
108
- name: :description,
101
+ = render IronAdmin::Form::TextareaComponent.new(name: :description,
109
102
  value: @product.description,
110
103
  rows: 6,
111
- placeholder: "Enter product description..."
112
- )
104
+ placeholder: "Enter product description...")
113
105
  ```
114
106
 
115
107
  ---
@@ -133,12 +125,10 @@ IronAdmin::Form::DatePickerComponent.new(
133
125
  **Example:**
134
126
 
135
127
  ```haml
136
- = render IronAdmin::Form::DatePickerComponent.new(
137
- name: :start_date,
128
+ = render IronAdmin::Form::DatePickerComponent.new(name: :start_date,
138
129
  value: @event.start_date,
139
130
  type: :datetime_local,
140
- min: Date.today
141
- )
131
+ min: Date.today)
142
132
  ```
143
133
 
144
134
  ---
@@ -162,12 +152,10 @@ IronAdmin::Form::BelongsToComponent.new(
162
152
  **Example:**
163
153
 
164
154
  ```haml
165
- = render IronAdmin::Form::BelongsToComponent.new(
166
- name: :category_id,
155
+ = render IronAdmin::Form::BelongsToComponent.new(name: :category_id,
167
156
  association_class: Category,
168
157
  selected: @product.category_id,
169
- display_method: :title
170
- )
158
+ display_method: :title)
171
159
  ```
172
160
 
173
161
  ---
@@ -190,16 +178,12 @@ IronAdmin::Form::FieldWrapperComponent.new(
190
178
  **Example:**
191
179
 
192
180
  ```haml
193
- = render IronAdmin::Form::FieldWrapperComponent.new(
194
- name: :email,
181
+ = render IronAdmin::Form::FieldWrapperComponent.new(name: :email,
195
182
  label: "Email Address",
196
183
  errors: @user.errors[:email],
197
184
  required: true,
198
- hint: "We'll never share your email."
199
- ) do
200
- = render IronAdmin::Form::TextInputComponent.new(
201
- name: :email,
185
+ hint: "We'll never share your email.") do
186
+ = render IronAdmin::Form::TextInputComponent.new(name: :email,
202
187
  value: @user.email,
203
- has_error: @user.errors[:email].any?
204
- )
188
+ has_error: @user.errors[:email].any?)
205
189
  ```
@@ -20,14 +20,12 @@ IronAdmin::Resources::DataTableComponent.new(
20
20
  **Example:**
21
21
 
22
22
  ```haml
23
- = render IronAdmin::Resources::DataTableComponent.new(
24
- records: @users,
25
- fields: UserResource.resolved_fields.first(5),
26
- resource_class: UserResource,
23
+ = render IronAdmin::Resources::DataTableComponent.new(records: @users,
24
+ fields: @resource_class.resolved_fields.first(5),
25
+ resource_class: @resource_class,
27
26
  base_url: request.fullpath.split("?").first + "?",
28
27
  current_sort: params[:sort],
29
- current_direction: params[:direction]
30
- )
28
+ current_direction: params[:direction])
31
29
  ```
32
30
 
33
31
  The component appends `sort=<column>&direction=<asc|desc>` to `base_url`. Its sort links have
@@ -54,10 +52,8 @@ IronAdmin::Resources::ShowFieldComponent.new(
54
52
  ```haml
55
53
  %dl
56
54
  - @fields.each do |field|
57
- = render IronAdmin::Resources::ShowFieldComponent.new(
58
- field: field,
59
- record: @user
60
- )
55
+ = render IronAdmin::Resources::ShowFieldComponent.new(field: field,
56
+ record: @user)
61
57
  ```
62
58
 
63
59
  ---
@@ -89,6 +85,10 @@ IronAdmin::Resources::ActionsComponent.new(
89
85
  With `confirm: true`, the button asks for confirmation with the action's `confirm_message`,
90
86
  or with `iron_admin.resources.action.confirm` ("Are you sure?") when it has none.
91
87
 
88
+ An action with `form_fields` is a link to its form (`resource_action_form_path`), styled like
89
+ the buttons, and the form asks for the confirmation when it is submitted. See
90
+ [Action Forms](../guides/resources.md#action-forms).
91
+
92
92
  The component renders every action it is given. On the show page, IronAdmin sets
93
93
  `@member_actions` to the actions it would run for that record: allowed by the resource
94
94
  policy, able to load the record (a soft-deleted record only offers `restore`), and with a
@@ -97,11 +97,9 @@ passing `condition`. Pass that list instead of `defined_actions` in a custom sho
97
97
  **Example:**
98
98
 
99
99
  ```haml
100
- = render IronAdmin::Resources::ActionsComponent.new(
101
- actions: @member_actions,
100
+ = render IronAdmin::Resources::ActionsComponent.new(actions: @member_actions,
102
101
  record: @record,
103
- resource_class: @resource_class
104
- )
102
+ resource_class: @resource_class)
105
103
  ```
106
104
 
107
105
  ---
@@ -126,8 +124,8 @@ IronAdmin::Resources::BreadcrumbComponent.new
126
124
 
127
125
  ```haml
128
126
  = render IronAdmin::Resources::BreadcrumbComponent.new do |breadcrumb|
129
- - breadcrumb.with_item(label: "Dashboard", href: dashboard_path)
130
- - breadcrumb.with_item(label: "Users", href: users_path)
127
+ - breadcrumb.with_item(label: "Dashboard", href: root_path)
128
+ - breadcrumb.with_item(label: "Users", href: resources_path("users"))
131
129
  - breadcrumb.with_item(label: @user.name, current: true)
132
130
  ```
133
131
 
@@ -139,18 +137,40 @@ Actions for selected records.
139
137
 
140
138
  ```ruby
141
139
  IronAdmin::Resources::BulkActionsComponent.new(
142
- actions: bulk_actions, # Required: array of bulk action hashes
143
- resource_class: UserResource # Required: resource class
140
+ actions: @permitted_bulk_actions, # Required: the bulk actions the policy allows
141
+ resource_class: UserResource # Required: resource class
144
142
  )
145
143
  ```
146
144
 
145
+ `@permitted_bulk_actions` is set on the index. On any other page it is nil, and `render?`
146
+ treats a nil list as empty, so the component renders nothing until you pass a list. Build
147
+ the actions the policy allows for the current user, and leave out a condition that raises:
148
+
149
+ ```ruby
150
+ user = iron_admin_current_user
151
+ actions = UserResource.defined_bulk_actions.select do |action|
152
+ policy = UserResource.resource_policy
153
+ next true unless policy
154
+
155
+ policy.action_allowed?(action[:name], user)
156
+ rescue StandardError
157
+ false
158
+ end
159
+ ```
160
+
161
+ Each action is a small form with a `data-bulk-actions-target="form"` attribute, for a host
162
+ Stimulus controller (`bulk-actions`) that adds the selected `ids[]` to it. An action without
163
+ `form_fields` posts to the bulk action; an action with `form_fields` opens its form with a GET
164
+ (`resource_bulk_action_form_path`), which has no CSRF token, so the ids land in that form.
165
+ With `confirm: true`, the button of an action without `form_fields` asks for confirmation
166
+ (`data-turbo-confirm`, with the action's `confirm_message` or
167
+ `iron_admin.resources.action.confirm`); an action with `form_fields` asks on its form's submit.
168
+
147
169
  **Example:**
148
170
 
149
171
  ```haml
150
- = render IronAdmin::Resources::BulkActionsComponent.new(
151
- actions: UserResource.defined_bulk_actions,
152
- resource_class: UserResource
153
- )
172
+ = render IronAdmin::Resources::BulkActionsComponent.new(actions: @permitted_bulk_actions,
173
+ resource_class: @resource_class)
154
174
  ```
155
175
 
156
176
  ---
@@ -182,7 +202,8 @@ IronAdmin::Resources::RelatedListComponent.new(
182
202
 
183
203
  `Resource.has_many_associations` returns hashes in this shape, `reflection:` included.
184
204
 
185
- The list renders nothing when there are no records. The card has no border, rows are divided
205
+ The list renders nothing when there are no records. The card is a panel like the show page's
206
+ (`card_bg`, `border_width`, `card_border`, `border_radius` and `card_shadow`), rows are divided
186
207
  with `theme.table_border`, the table scrolls horizontally inside an `overflow-x-auto`
187
208
  container, and the "View all" label comes from `iron_admin.resources.show.view_all`.
188
209
 
@@ -200,10 +221,8 @@ the plain index link.
200
221
  ```haml
201
222
  -# In a show view: @resource_class is OrderResource and @record the order
202
223
  - association = @resource_class.has_many_associations.find { |assoc| assoc[:name] == :line_items }
203
- = render IronAdmin::Resources::RelatedListComponent.new(
204
- association: association,
224
+ = render IronAdmin::Resources::RelatedListComponent.new(association: association,
205
225
  records: @record.line_items,
206
226
  limit: 10,
207
- parent: @record
208
- )
227
+ parent: @record)
209
228
  ```