activeadmin 2.9.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +284 -1
  3. data/CONTRIBUTING.md +4 -12
  4. data/README.md +2 -2
  5. data/app/assets/javascripts/active_admin/base.js +13 -9
  6. data/app/assets/stylesheets/active_admin/_base.scss +53 -37
  7. data/app/assets/stylesheets/active_admin/_forms.scss +1 -11
  8. data/app/assets/stylesheets/active_admin/_normalize.scss +25 -123
  9. data/app/assets/stylesheets/active_admin/components/_date_picker.scss +1 -2
  10. data/app/assets/stylesheets/active_admin/components/_dropdown_menu.scss +0 -1
  11. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +9 -0
  12. data/app/assets/stylesheets/active_admin/structure/_footer.scss +6 -1
  13. data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -1
  14. data/app/javascript/active_admin/initializers/has-many.js +4 -1
  15. data/app/views/active_admin/devise/shared/_links.erb +1 -1
  16. data/app/views/active_admin/page/index.html.arb +1 -0
  17. data/app/views/active_admin/resource/edit.html.arb +1 -0
  18. data/app/views/active_admin/resource/index.html.arb +1 -0
  19. data/app/views/active_admin/resource/new.html.arb +1 -0
  20. data/app/views/active_admin/resource/show.html.arb +1 -0
  21. data/app/views/layouts/active_admin.html.arb +1 -0
  22. data/app/views/layouts/active_admin_logged_out.html.erb +5 -4
  23. data/config/locales/ar.yml +0 -7
  24. data/config/locales/az.yml +0 -7
  25. data/config/locales/bg.yml +0 -7
  26. data/config/locales/bs.yml +0 -7
  27. data/config/locales/ca.yml +0 -7
  28. data/config/locales/cs.yml +0 -7
  29. data/config/locales/da.yml +0 -7
  30. data/config/locales/de-CH.yml +0 -7
  31. data/config/locales/de.yml +0 -8
  32. data/config/locales/el.yml +0 -7
  33. data/config/locales/en-CA.yml +0 -7
  34. data/config/locales/en-GB.yml +0 -7
  35. data/config/locales/en.yml +0 -8
  36. data/config/locales/eo.yml +0 -8
  37. data/config/locales/es-MX.yml +0 -7
  38. data/config/locales/es.yml +0 -8
  39. data/config/locales/fa.yml +0 -7
  40. data/config/locales/fi.yml +0 -7
  41. data/config/locales/fr.yml +3 -11
  42. data/config/locales/he.yml +0 -9
  43. data/config/locales/hr.yml +0 -7
  44. data/config/locales/hu.yml +0 -8
  45. data/config/locales/id.yml +0 -7
  46. data/config/locales/it.yml +0 -8
  47. data/config/locales/ja.yml +0 -8
  48. data/config/locales/ko.yml +1 -8
  49. data/config/locales/lt.yml +0 -8
  50. data/config/locales/lv.yml +0 -7
  51. data/config/locales/mk.yml +0 -8
  52. data/config/locales/nb.yml +0 -8
  53. data/config/locales/nl.yml +1 -9
  54. data/config/locales/pl.yml +0 -8
  55. data/config/locales/pt-BR.yml +0 -8
  56. data/config/locales/pt-PT.yml +0 -7
  57. data/config/locales/ro.yml +3 -9
  58. data/config/locales/ru.yml +0 -6
  59. data/config/locales/sk.yml +0 -8
  60. data/config/locales/sv-SE.yml +58 -39
  61. data/config/locales/tr.yml +0 -11
  62. data/config/locales/uk.yml +0 -6
  63. data/config/locales/vi.yml +34 -15
  64. data/config/locales/zh-CN.yml +34 -23
  65. data/config/locales/zh-TW.yml +0 -7
  66. data/lib/active_admin/abstract_view_factory.rb +1 -0
  67. data/lib/active_admin/application.rb +10 -10
  68. data/lib/active_admin/application_settings.rb +1 -0
  69. data/lib/active_admin/asset_registration.rb +4 -3
  70. data/lib/active_admin/authorization_adapter.rb +3 -0
  71. data/lib/active_admin/base_controller/authorization.rb +4 -3
  72. data/lib/active_admin/base_controller/menu.rb +1 -0
  73. data/lib/active_admin/base_controller.rb +2 -1
  74. data/lib/active_admin/batch_actions/controller.rb +1 -0
  75. data/lib/active_admin/batch_actions/resource_extension.rb +1 -0
  76. data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -0
  77. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -0
  78. data/lib/active_admin/batch_actions/views/selection_cells.rb +1 -0
  79. data/lib/active_admin/batch_actions.rb +1 -0
  80. data/lib/active_admin/callbacks.rb +1 -0
  81. data/lib/active_admin/cancan_adapter.rb +1 -0
  82. data/lib/active_admin/collection_decorator.rb +1 -0
  83. data/lib/active_admin/component.rb +1 -0
  84. data/lib/active_admin/controller_action.rb +1 -0
  85. data/lib/active_admin/csv_builder.rb +24 -16
  86. data/lib/active_admin/dependency.rb +1 -4
  87. data/lib/active_admin/devise.rb +11 -0
  88. data/lib/active_admin/dsl.rb +1 -0
  89. data/lib/active_admin/dynamic_setting.rb +1 -0
  90. data/lib/active_admin/dynamic_settings_node.rb +1 -0
  91. data/lib/active_admin/engine.rb +8 -2
  92. data/lib/active_admin/error.rb +1 -0
  93. data/lib/active_admin/filters/active.rb +1 -0
  94. data/lib/active_admin/filters/active_filter.rb +2 -1
  95. data/lib/active_admin/filters/active_sidebar.rb +2 -28
  96. data/lib/active_admin/filters/dsl.rb +1 -0
  97. data/lib/active_admin/filters/forms.rb +3 -2
  98. data/lib/active_admin/filters/formtastic_addons.rb +2 -1
  99. data/lib/active_admin/filters/resource_extension.rb +5 -4
  100. data/lib/active_admin/filters.rb +1 -0
  101. data/lib/active_admin/form_builder.rb +1 -0
  102. data/lib/active_admin/generators/boilerplate.rb +1 -0
  103. data/lib/active_admin/helpers/collection.rb +2 -0
  104. data/lib/active_admin/helpers/i18n.rb +1 -0
  105. data/lib/active_admin/helpers/optional_display.rb +1 -0
  106. data/lib/active_admin/helpers/routes/url_helpers.rb +1 -0
  107. data/lib/active_admin/helpers/scope_chain.rb +1 -0
  108. data/lib/active_admin/inputs/datepicker_input.rb +1 -0
  109. data/lib/active_admin/inputs/filters/base/search_method_select.rb +3 -2
  110. data/lib/active_admin/inputs/filters/base.rb +1 -0
  111. data/lib/active_admin/inputs/filters/boolean_input.rb +1 -0
  112. data/lib/active_admin/inputs/filters/check_boxes_input.rb +1 -0
  113. data/lib/active_admin/inputs/filters/date_picker_input.rb +1 -0
  114. data/lib/active_admin/inputs/filters/date_range_input.rb +3 -2
  115. data/lib/active_admin/inputs/filters/numeric_input.rb +2 -1
  116. data/lib/active_admin/inputs/filters/select_input.rb +3 -0
  117. data/lib/active_admin/inputs/filters/string_input.rb +2 -1
  118. data/lib/active_admin/inputs/filters/text_input.rb +1 -0
  119. data/lib/active_admin/inputs.rb +1 -0
  120. data/lib/active_admin/localizers/resource_localizer.rb +1 -0
  121. data/lib/active_admin/localizers.rb +1 -0
  122. data/lib/active_admin/menu.rb +2 -0
  123. data/lib/active_admin/menu_collection.rb +1 -0
  124. data/lib/active_admin/menu_item.rb +1 -0
  125. data/lib/active_admin/namespace.rb +4 -3
  126. data/lib/active_admin/namespace_settings.rb +2 -1
  127. data/lib/active_admin/order_clause.rb +1 -0
  128. data/lib/active_admin/orm/active_record/comments/comment.rb +9 -0
  129. data/lib/active_admin/orm/active_record/comments/namespace_helper.rb +1 -0
  130. data/lib/active_admin/orm/active_record/comments/resource_helper.rb +1 -0
  131. data/lib/active_admin/orm/active_record/comments/show_page_helper.rb +1 -0
  132. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +2 -1
  133. data/lib/active_admin/orm/active_record/comments/views.rb +1 -0
  134. data/lib/active_admin/orm/active_record/comments.rb +9 -8
  135. data/lib/active_admin/orm/active_record.rb +1 -0
  136. data/lib/active_admin/orm/mongoid.rb +1 -0
  137. data/lib/active_admin/page.rb +1 -0
  138. data/lib/active_admin/page_controller.rb +1 -0
  139. data/lib/active_admin/page_dsl.rb +1 -0
  140. data/lib/active_admin/page_presenter.rb +1 -0
  141. data/lib/active_admin/pundit_adapter.rb +55 -13
  142. data/lib/active_admin/resource/action_items.rb +3 -2
  143. data/lib/active_admin/resource/attributes.rb +1 -0
  144. data/lib/active_admin/resource/belongs_to.rb +1 -0
  145. data/lib/active_admin/resource/controllers.rb +1 -0
  146. data/lib/active_admin/resource/includes.rb +1 -0
  147. data/lib/active_admin/resource/menu.rb +1 -0
  148. data/lib/active_admin/resource/model.rb +1 -0
  149. data/lib/active_admin/resource/naming.rb +1 -0
  150. data/lib/active_admin/resource/ordering.rb +1 -0
  151. data/lib/active_admin/resource/page_presenters.rb +1 -0
  152. data/lib/active_admin/resource/pagination.rb +1 -0
  153. data/lib/active_admin/resource/routes.rb +1 -0
  154. data/lib/active_admin/resource/scope_to.rb +1 -0
  155. data/lib/active_admin/resource/scopes.rb +1 -0
  156. data/lib/active_admin/resource/sidebars.rb +1 -0
  157. data/lib/active_admin/resource.rb +3 -2
  158. data/lib/active_admin/resource_collection.rb +1 -0
  159. data/lib/active_admin/resource_controller/action_builder.rb +1 -0
  160. data/lib/active_admin/resource_controller/data_access.rb +30 -4
  161. data/lib/active_admin/resource_controller/decorators.rb +1 -0
  162. data/lib/active_admin/resource_controller/polymorphic_routes.rb +1 -0
  163. data/lib/active_admin/resource_controller/resource_class_methods.rb +1 -0
  164. data/lib/active_admin/resource_controller/scoping.rb +1 -0
  165. data/lib/active_admin/resource_controller/sidebars.rb +1 -0
  166. data/lib/active_admin/resource_controller/streaming.rb +3 -2
  167. data/lib/active_admin/resource_controller.rb +1 -0
  168. data/lib/active_admin/resource_dsl.rb +7 -21
  169. data/lib/active_admin/router.rb +1 -0
  170. data/lib/active_admin/scope.rb +1 -0
  171. data/lib/active_admin/settings_node.rb +1 -0
  172. data/lib/active_admin/sidebar_section.rb +1 -0
  173. data/lib/active_admin/version.rb +2 -1
  174. data/lib/active_admin/view_factory.rb +1 -0
  175. data/lib/active_admin/view_helpers/active_admin_application_helper.rb +1 -0
  176. data/lib/active_admin/view_helpers/auto_link_helper.rb +2 -1
  177. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -0
  178. data/lib/active_admin/view_helpers/display_helper.rb +19 -4
  179. data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -0
  180. data/lib/active_admin/view_helpers/fields_for.rb +1 -0
  181. data/lib/active_admin/view_helpers/flash_helper.rb +1 -0
  182. data/lib/active_admin/view_helpers/form_helper.rb +1 -0
  183. data/lib/active_admin/view_helpers/method_or_proc_helper.rb +1 -0
  184. data/lib/active_admin/view_helpers/scope_name_helper.rb +1 -0
  185. data/lib/active_admin/view_helpers/sidebar_helper.rb +1 -0
  186. data/lib/active_admin/view_helpers/title_helper.rb +1 -0
  187. data/lib/active_admin/view_helpers/view_factory_helper.rb +1 -0
  188. data/lib/active_admin/view_helpers.rb +1 -0
  189. data/lib/active_admin/views/action_items.rb +1 -0
  190. data/lib/active_admin/views/components/active_admin_form.rb +2 -5
  191. data/lib/active_admin/views/components/active_filters_sidebar_content.rb +59 -0
  192. data/lib/active_admin/views/components/attributes_table.rb +1 -0
  193. data/lib/active_admin/views/components/blank_slate.rb +1 -0
  194. data/lib/active_admin/views/components/columns.rb +1 -0
  195. data/lib/active_admin/views/components/dropdown_menu.rb +3 -5
  196. data/lib/active_admin/views/components/index_list.rb +1 -0
  197. data/lib/active_admin/views/components/menu.rb +1 -0
  198. data/lib/active_admin/views/components/menu_item.rb +1 -0
  199. data/lib/active_admin/views/components/paginated_collection.rb +1 -0
  200. data/lib/active_admin/views/components/panel.rb +1 -0
  201. data/lib/active_admin/views/components/scopes.rb +1 -0
  202. data/lib/active_admin/views/components/sidebar.rb +1 -0
  203. data/lib/active_admin/views/components/sidebar_section.rb +1 -0
  204. data/lib/active_admin/views/components/site_title.rb +1 -0
  205. data/lib/active_admin/views/components/status_tag.rb +1 -0
  206. data/lib/active_admin/views/components/table_for.rb +1 -0
  207. data/lib/active_admin/views/components/tabs.rb +1 -0
  208. data/lib/active_admin/views/components/unsupported_browser.rb +1 -0
  209. data/lib/active_admin/views/footer.rb +1 -0
  210. data/lib/active_admin/views/header.rb +1 -0
  211. data/lib/active_admin/views/index_as_block.rb +1 -0
  212. data/lib/active_admin/views/index_as_blog.rb +1 -0
  213. data/lib/active_admin/views/index_as_grid.rb +1 -0
  214. data/lib/active_admin/views/index_as_table.rb +2 -5
  215. data/lib/active_admin/views/pages/base.rb +8 -4
  216. data/lib/active_admin/views/pages/form.rb +1 -0
  217. data/lib/active_admin/views/pages/index.rb +2 -1
  218. data/lib/active_admin/views/pages/layout.rb +1 -0
  219. data/lib/active_admin/views/pages/page.rb +1 -0
  220. data/lib/active_admin/views/pages/show.rb +2 -7
  221. data/lib/active_admin/views/tabbed_navigation.rb +1 -0
  222. data/lib/active_admin/views/title_bar.rb +1 -0
  223. data/lib/active_admin/views.rb +1 -0
  224. data/lib/active_admin.rb +6 -3
  225. data/lib/activeadmin.rb +1 -0
  226. data/lib/generators/active_admin/assets/assets_generator.rb +1 -0
  227. data/lib/generators/active_admin/devise/devise_generator.rb +1 -0
  228. data/lib/generators/active_admin/install/install_generator.rb +1 -0
  229. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +18 -1
  230. data/lib/generators/active_admin/install/templates/dashboard.rb +1 -0
  231. data/lib/generators/active_admin/page/page_generator.rb +1 -0
  232. data/lib/generators/active_admin/page/templates/page.rb +1 -0
  233. data/lib/generators/active_admin/resource/resource_generator.rb +1 -0
  234. data/lib/generators/active_admin/webpacker/webpacker_generator.rb +1 -0
  235. metadata +26 -83
  236. data/docs/.gitignore +0 -1
  237. data/docs/0-installation.md +0 -142
  238. data/docs/1-general-configuration.md +0 -224
  239. data/docs/10-custom-pages.md +0 -150
  240. data/docs/11-decorators.md +0 -70
  241. data/docs/12-arbre-components.md +0 -214
  242. data/docs/13-authorization-adapter.md +0 -285
  243. data/docs/14-gotchas.md +0 -138
  244. data/docs/2-resource-customization.md +0 -475
  245. data/docs/3-index-pages/custom-index.md +0 -35
  246. data/docs/3-index-pages/index-as-block.md +0 -19
  247. data/docs/3-index-pages/index-as-blog.md +0 -69
  248. data/docs/3-index-pages/index-as-grid.md +0 -27
  249. data/docs/3-index-pages/index-as-table.md +0 -234
  250. data/docs/3-index-pages.md +0 -328
  251. data/docs/4-csv-format.md +0 -74
  252. data/docs/5-forms.md +0 -237
  253. data/docs/6-show-pages.md +0 -93
  254. data/docs/7-sidebars.md +0 -75
  255. data/docs/8-custom-actions.md +0 -177
  256. data/docs/9-batch-actions.md +0 -237
  257. data/docs/CNAME +0 -1
  258. data/docs/Gemfile +0 -3
  259. data/docs/Gemfile.lock +0 -259
  260. data/docs/README.md +0 -24
  261. data/docs/_config.yml +0 -4
  262. data/docs/_includes/footer.html +0 -8
  263. data/docs/_includes/google-analytics.html +0 -16
  264. data/docs/_includes/head.html +0 -7
  265. data/docs/_includes/toc.html +0 -98
  266. data/docs/_includes/top-menu.html +0 -17
  267. data/docs/_layouts/default.html +0 -21
  268. data/docs/documentation.md +0 -60
  269. data/docs/images/activeadmin.png +0 -0
  270. data/docs/images/code-header.png +0 -0
  271. data/docs/images/divider.png +0 -0
  272. data/docs/images/features.png +0 -0
  273. data/docs/images/tidelift.svg +0 -14
  274. data/docs/index.html +0 -226
  275. data/docs/stylesheets/main.css +0 -1205
  276. data/lib/active_admin/deprecation.rb +0 -10
  277. data/lib/ransack_ext.rb +0 -20
  278. /data/app/assets/stylesheets/active_admin/{print.scss → _print.scss} +0 -0
data/docs/5-forms.md DELETED
@@ -1,237 +0,0 @@
1
- ---
2
- redirect_from: /docs/5-forms.html
3
- ---
4
-
5
- # Forms
6
-
7
- Active Admin gives you complete control over the output of the form by creating
8
- a thin DSL on top of [Formtastic](https://github.com/justinfrench/formtastic):
9
-
10
- ```ruby
11
- ActiveAdmin.register Post do
12
-
13
- form title: 'A custom title' do |f|
14
- inputs 'Details' do
15
- input :title
16
- input :published_at, label: "Publish Post At"
17
- li "Created at #{f.object.created_at}" unless f.object.new_record?
18
- input :category
19
- end
20
- panel 'Markup' do
21
- "The following can be used in the content below..."
22
- end
23
- inputs 'Content', :body
24
- para "Press cancel to return to the list without saving."
25
- actions
26
- end
27
-
28
- end
29
- ```
30
-
31
- For more details, please see [Formtastic's documentation](https://github.com/justinfrench/formtastic/wiki).
32
-
33
- ## Default
34
-
35
- Resources come with a default form defined as such:
36
-
37
- ```ruby
38
- form do |f|
39
- f.semantic_errors # shows errors on :base
40
- f.inputs # builds an input field for every attribute
41
- f.actions # adds the 'Submit' and 'Cancel' buttons
42
- end
43
- ```
44
-
45
- ## Partials
46
-
47
- If you want to split a custom form into a separate partial use:
48
-
49
- ```ruby
50
- ActiveAdmin.register Post do
51
- form partial: 'form'
52
- end
53
- ```
54
-
55
- Which looks for something like this:
56
-
57
- ```ruby
58
- # app/views/admin/posts/_form.html.arb
59
- insert_tag active_admin_form_for resource do |f|
60
- inputs :title, :body
61
- actions
62
- end
63
- ```
64
-
65
- This is a regular Rails partial so any template engine may be used.
66
-
67
- You can also use the `ActiveAdmin::FormBuilder` as builder in your Formtastic
68
- Form for use the same helpers are used in the admin file:
69
-
70
- ```ruby
71
- = semantic_form_for [:admin, @post], builder: ActiveAdmin::FormBuilder do |f|
72
- = f.inputs "Details" do
73
- = f.input :title
74
- - f.has_many :taggings, sortable: :position, sortable_start: 1 do |t|
75
- - t.input :tag
76
- = f.actions
77
-
78
- ```
79
-
80
- ## Nested Resources
81
-
82
- You can create forms with nested models using the `has_many` method, even if
83
- your model uses `has_one`:
84
-
85
- ```ruby
86
- ActiveAdmin.register Post do
87
- permit_params :title,
88
- :published_at,
89
- :body,
90
- categories_attributes: [:id, :title, :_destroy],
91
- taggings_attributes: [:id, :tag],
92
- comment_attributes: [:id, :body, :_destroy]
93
-
94
- form do |f|
95
- f.inputs 'Details' do
96
- f.input :title
97
- f.input :published_at, label: 'Publish Post At'
98
- end
99
- f.inputs 'Content', :body
100
- f.inputs do
101
- f.has_many :categories, heading: 'Themes',
102
- allow_destroy: true,
103
- new_record: false do |a|
104
- a.input :title
105
- end
106
- end
107
- f.inputs do
108
- f.has_many :taggings, sortable: :position, sortable_start: 1 do |t|
109
- t.input :tag
110
- end
111
- end
112
- f.inputs do
113
- f.has_many :comments,
114
- new_record: 'Leave Comment',
115
- remove_record: 'Remove Comment',
116
- allow_destroy: -> (c) { c.author?(current_admin_user) } do |b|
117
- b.input :body
118
- end
119
- end
120
- f.actions
121
- end
122
-
123
- end
124
- ```
125
-
126
- *NOTE*: In addition to using `has_many` as illustrated above, you'll need to add
127
- `accepts_nested_attributes` to your parent model and [configure strong parameters](https://activeadmin.info/2-resource-customization.html)
128
-
129
- The `:allow_destroy` option adds a checkbox to the end of the nested form allowing
130
- removal of the child object upon submission. Be sure to set `allow_destroy: true`
131
- on the association to use this option. It is possible to associate
132
- `:allow_destroy` with a string or a symbol, corresponding to the name of a child
133
- object's method that will get called, or with a Proc object. The Proc object
134
- receives the child object as a parameter and should return either true or false.
135
-
136
- The `:heading` option adds a custom heading. You can hide it entirely by passing
137
- `false`.
138
-
139
- The `:new_record` option controls the visibility of the new record button (shown
140
- by default). If you pass a string, it will be used as the text for the new
141
- record button.
142
-
143
- The `:remove_record` option controls the text of the remove button (shown after
144
- the new record button is pressed). If you pass a string, it will be used as the
145
- text for the remove button.
146
-
147
- The `:sortable` option adds a hidden field and will enable drag & drop sorting
148
- of the children. It expects the name of the column that will store the index of
149
- each child.
150
-
151
- The `:sortable_start` option sets the value (0 by default) of the first position
152
- in the list.
153
-
154
- ## Datepicker
155
-
156
- ActiveAdmin offers the `datepicker` input, which uses the [jQuery UI
157
- datepicker](http://jqueryui.com/datepicker/). The datepicker input accepts any
158
- of the options available to the standard jQueryUI Datepicker. For example:
159
-
160
- ```ruby
161
- form do |f|
162
- f.input :starts_at, as: :datepicker,
163
- datepicker_options: {
164
- min_date: "2013-10-8",
165
- max_date: "+3D"
166
- }
167
-
168
- f.input :ends_at, as: :datepicker,
169
- datepicker_options: {
170
- min_date: 3.days.ago.to_date,
171
- max_date: "+1W +5D"
172
- }
173
- end
174
- ```
175
-
176
- Datepicker also accepts the `:label` option as a string or proc to display.
177
- If it's a proc, it will be called each time the datepicker is rendered.
178
-
179
- ## Displaying Errors
180
-
181
- To display a list of all validation errors:
182
-
183
- ```ruby
184
- form do |f|
185
- f.semantic_errors *f.object.errors.keys
186
- # ...
187
- end
188
- ```
189
-
190
- This is particularly useful to display errors on virtual or hidden attributes.
191
-
192
- # Tabs
193
-
194
- You can arrange content in tabs as shown below:
195
-
196
- ```ruby
197
- form do |f|
198
- tabs do
199
- tab 'Basic' do
200
- f.inputs 'Basic Details' do
201
- f.input :email
202
- f.input :password
203
- f.input :password_confirmation
204
- end
205
- end
206
-
207
- tab 'Advanced', html_options: { class: 'specific_css_class' } do
208
- f.inputs 'Advanced Details' do
209
- f.input :role
210
- end
211
- end
212
- end
213
- f.actions
214
- end
215
- ```
216
-
217
- `html_options` allows you set additional html params for tab's menu item.
218
-
219
- # Customize the Create Another checkbox
220
-
221
- In order to simplify creating multiple resources you may enable ActiveAdmin to
222
- show nice "Create Another" checkbox alongside of Create Model button. It may be
223
- enabled for the whole application:
224
-
225
- ```ruby
226
- ActiveAdmin.setup do |config|
227
- config.create_another = true
228
- end
229
- ```
230
-
231
- or for the particular resource:
232
-
233
- ```ruby
234
- ActiveAdmin.register Post do
235
- config.create_another = true
236
- end
237
- ```
data/docs/6-show-pages.md DELETED
@@ -1,93 +0,0 @@
1
- ---
2
- redirect_from: /docs/6-show-pages.html
3
- ---
4
- # Customize the Show Page
5
-
6
- The show block is rendered within the context of the view and uses
7
- [Arbre](https://github.com/activeadmin/arbre) syntax.
8
-
9
- With the `show` block, you can render anything you want.
10
-
11
- ```ruby
12
- ActiveAdmin.register Post do
13
- show do
14
- h3 post.title
15
- div do
16
- simple_format post.body
17
- end
18
- end
19
- end
20
- ```
21
-
22
- You can render a partial at any point:
23
-
24
- ```ruby
25
- ActiveAdmin.register Post do
26
- show do
27
- # renders app/views/admin/posts/_some_partial.html.erb
28
- render 'some_partial', { post: post }
29
- end
30
- end
31
- ```
32
-
33
- If you'd like to keep the default AA look, you can use `attributes_table`:
34
-
35
- ```ruby
36
- ActiveAdmin.register Ad do
37
- show do
38
- attributes_table do
39
- row :title
40
- row :image do |ad|
41
- image_tag ad.image.url
42
- end
43
- end
44
- active_admin_comments
45
- end
46
- end
47
- ```
48
-
49
- You can also customize the title of the object in the show screen:
50
-
51
- ```ruby
52
- show title: :name do
53
- # ...
54
- end
55
- ```
56
-
57
- If you want a more data-dense page, you can combine a sidebar:
58
-
59
- ```ruby
60
- ActiveAdmin.register Book do
61
- show do
62
- panel "Table of Contents" do
63
- table_for book.chapters do
64
- column :number
65
- column :title
66
- column :page
67
- end
68
- end
69
- active_admin_comments
70
- end
71
-
72
- sidebar "Details", only: :show do
73
- attributes_table_for book do
74
- row :title
75
- row :author
76
- row :publisher
77
- row('Published?') { |b| status_tag b.published? }
78
- end
79
- end
80
- end
81
- ```
82
-
83
- If you want to keep the default show data, but add something extra to it:
84
-
85
- ```ruby
86
- show do
87
- div do
88
- h3 'Some custom charts about this object'
89
- render partial: 'charts'
90
- end
91
- default_main_content
92
- end
93
- ```
data/docs/7-sidebars.md DELETED
@@ -1,75 +0,0 @@
1
- ---
2
- redirect_from: /docs/7-sidebars.html
3
- ---
4
- # Sidebar Sections
5
-
6
- Sidebars allow you to put whatever content you want on the side the page.
7
-
8
- ```ruby
9
- sidebar :help do
10
- "Need help? Email us at help@example.com"
11
- end
12
- ```
13
-
14
- This will generate a sidebar on every page for that resource. The first
15
- argument is used as the title, and can be a symbol, string, or lambda.
16
-
17
- You can also use [Arbre](https://github.com/activeadmin/arbre) to define HTML content.
18
-
19
- ```ruby
20
- sidebar :help do
21
- ul do
22
- li "Second List First Item"
23
- li "Second List Second Item"
24
- end
25
- end
26
- ```
27
-
28
- Sidebars can be rendered on a specific action by passing `:only` or `:except`.
29
-
30
- ```ruby
31
- sidebar :help, only: :index do
32
- "Need help? Email us at help@example.com"
33
- end
34
- ```
35
-
36
- If you want to conditionally display a sidebar section, use the :if option and
37
- pass it a proc which will be rendered within the view context.
38
-
39
- ```ruby
40
- sidebar :help, if: proc{ current_admin_user.super_admin? } do
41
- "Only for super admins!"
42
- end
43
- ```
44
-
45
- You can access your model as resource in the sidebar too:
46
-
47
- ```ruby
48
- sidebar :custom, only: :show do
49
- resource.a_method
50
- end
51
- ```
52
-
53
- You can also render a partial:
54
-
55
- ```ruby
56
- sidebar :help # app/views/admin/posts/_help_sidebar.html.erb
57
- sidebar :help, partial: 'custom' # app/views/admin/posts/_custom.html.erb
58
- ```
59
-
60
- It's possible to add custom class name to the sidebar parent element by passing
61
- `class` option:
62
-
63
- ```ruby
64
- sidebar :help, class: 'custom_class'
65
- ```
66
-
67
- By default sidebars are positioned in the same order as they defined, but it's also
68
- possible to specify their position manually:
69
-
70
- ```ruby
71
- # will push Help section to the top (above default Filters section)
72
- sidebar :help, priority: 0
73
- ```
74
-
75
- Default sidebar priority is `10`.
@@ -1,177 +0,0 @@
1
- ---
2
- redirect_from: /docs/8-custom-actions.html
3
- ---
4
-
5
- # Custom Controller Actions
6
-
7
- Active Admin allows you to override and modify the underlying controller which
8
- is generated for you. There are helpers to add collection and member actions, or
9
- you can drop right in to the controller and modify its behavior.
10
-
11
- ## Collection Actions
12
-
13
- A collection action is a controller action which operates on the collection of
14
- resources. This method adds both the action to the controller as well as
15
- generating a route for you.
16
-
17
- To add a collection action, use the collection_action method:
18
-
19
- ```ruby
20
- ActiveAdmin.register Post do
21
-
22
- collection_action :import_csv, method: :post do
23
- # Do some CSV importing work here...
24
- redirect_to collection_path, notice: "CSV imported successfully!"
25
- end
26
-
27
- end
28
- ```
29
-
30
- This collection action will generate a route at `/admin/posts/import_csv`
31
- pointing to the `Admin::PostsController#import_csv` controller action.
32
-
33
- ## Member Actions
34
-
35
- A member action is a controller action which operates on a single resource.
36
-
37
- For example, to add a lock action to a user resource, you would do the
38
- following:
39
-
40
- ```ruby
41
- ActiveAdmin.register User do
42
-
43
- member_action :lock, method: :put do
44
- resource.lock!
45
- redirect_to resource_path, notice: "Locked!"
46
- end
47
-
48
- end
49
- ```
50
-
51
- This will generate a route at `/admin/users/:id/lock` pointing to the
52
- `Admin::UserController#lock` controller action.
53
-
54
- ## HTTP Verbs
55
-
56
- The `collection_action` and `member_action` methods both accept the `:method`
57
- argument to set the HTTP verb for the controller action and route.
58
-
59
- Sometimes you want to create an action with the same name, that handles multiple
60
- HTTP verbs. In that case, this is the suggested approach:
61
-
62
- ```ruby
63
- member_action :foo, method: [:get, :post] do
64
- if request.post?
65
- resource.update_attributes! foo: params[:foo] || {}
66
- head :ok
67
- else
68
- render :foo
69
- end
70
- end
71
- ```
72
-
73
- ## Rendering
74
-
75
- Custom controller actions support rendering within the standard Active Admin
76
- layout.
77
-
78
- ```ruby
79
- ActiveAdmin.register Post do
80
-
81
- # /admin/posts/:id/comments
82
- member_action :comments do
83
- @comments = resource.comments
84
- # This will render app/views/admin/posts/comments.html.erb
85
- end
86
-
87
- end
88
- ```
89
-
90
- If you would like to use the same view syntax as the rest of Active Admin, you
91
- can use the Arbre file extension: .arb.
92
-
93
- For example, create `app/views/admin/posts/comments.html.arb` with:
94
-
95
- ```ruby
96
- table_for assigns[:post].comments do
97
- column :id
98
- column :author
99
- column :body do |comment|
100
- simple_format comment.body
101
- end
102
- end
103
- ```
104
-
105
- ## Page Titles
106
-
107
- The page title for the custom action will be the translated version of
108
- the controller action name. For example, a member_action named "upload_csv" will
109
- look up a translation key of `active_admin.upload_csv`. If none are found, it
110
- defaults to the name of the controller action.
111
-
112
- If this doesn't work for you, you can always set the `@page_title` instance
113
- variable in your controller action to customize the page title.
114
-
115
- ```ruby
116
- ActiveAdmin.register Post do
117
-
118
- member_action :comments do
119
- @comments = resource.comments
120
- @page_title = "#{resource.title}: Comments" # Sets the page title
121
- end
122
-
123
- end
124
- ```
125
-
126
- # Action Items
127
-
128
- To include your own action items (like the New, Edit and Delete buttons), add an
129
- `action_item` block. The first parameter is just a name to identify the action,
130
- and is required. For example, to add a "View on site" button to view a blog
131
- post:
132
-
133
- ```ruby
134
- action_item :view, only: :show do
135
- link_to 'View on site', post_path(post) if post.published?
136
- end
137
- ```
138
-
139
- Actions items also accept the `:if` option to conditionally display them:
140
-
141
- ```ruby
142
- action_item :super_action,
143
- only: :show,
144
- if: proc{ current_admin_user.super_admin? } do
145
- "Only display this to super admins on the show screen"
146
- end
147
- ```
148
-
149
- By default action items are positioned in the same order as they defined (after default actions),
150
- but it’s also possible to specify their position manually:
151
-
152
- ```ruby
153
- action_item :help, priority: 0 do
154
- "Display this action to the first position"
155
- end
156
- ```
157
-
158
- Default action item priority is 10.
159
-
160
- # Modifying the Controller
161
-
162
- The generated controller is available to you within the registration block by
163
- using the `controller` method.
164
-
165
- ```ruby
166
- ActiveAdmin.register Post do
167
-
168
- controller do
169
- # This code is evaluated within the controller class
170
-
171
- def define_a_method
172
- # Instance method
173
- end
174
- end
175
-
176
- end
177
- ```