activeadmin 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE.md +20 -0
- data/.mdlrc +1 -0
- data/.rubocop.yml +52 -3
- data/.simplecov +13 -0
- data/.travis.yml +9 -24
- data/.yardopts +0 -1
- data/CHANGELOG.md +85 -4
- data/CONTRIBUTING.md +33 -57
- data/Gemfile +26 -17
- data/Rakefile +1 -12
- data/activeadmin.gemspec +9 -11
- data/app/assets/javascripts/active_admin/base.js.coffee +6 -2
- data/app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/datepicker.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/filters.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/initializers/tabs.js.coffee +5 -1
- data/app/assets/javascripts/active_admin/lib/batch_actions.js.coffee +6 -3
- data/app/assets/javascripts/active_admin/lib/checkbox-toggler.js.coffee +9 -7
- data/app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee +5 -2
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +6 -2
- data/app/assets/javascripts/active_admin/lib/table-checkbox-toggler.js.coffee +3 -5
- data/app/assets/stylesheets/active_admin/_base.scss +2 -2
- data/app/assets/stylesheets/active_admin/_forms.scss +6 -12
- data/app/assets/stylesheets/active_admin/components/_batch_actions.scss +0 -5
- data/app/assets/stylesheets/active_admin/components/_pagination.scss +11 -0
- data/app/assets/stylesheets/active_admin/components/_status_tags.scss +1 -0
- data/app/assets/stylesheets/active_admin/components/_tables.scss +4 -1
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -2
- data/app/assets/stylesheets/active_admin/print.scss +2 -3
- data/app/views/active_admin/devise/sessions/new.html.erb +1 -1
- data/app/views/active_admin/devise/shared/_links.erb +12 -6
- data/app/views/kaminari/active_admin/_first_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_gap.html.erb +8 -0
- data/app/views/kaminari/active_admin/_last_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_next_page.html.erb +11 -0
- data/app/views/kaminari/active_admin/_page.html.erb +12 -0
- data/app/views/kaminari/active_admin/_paginator.html.erb +25 -0
- data/app/views/kaminari/active_admin/_prev_page.html.erb +11 -0
- data/codecov.yml +14 -12
- data/config/i18n-tasks.yml +26 -0
- data/config/locales/ar.yml +1 -3
- data/config/locales/bg.yml +0 -2
- data/config/locales/bs.yml +0 -2
- data/config/locales/ca.yml +0 -2
- data/config/locales/cs.yml +0 -2
- data/config/locales/da.yml +1 -3
- data/config/locales/de-CH.yml +1 -3
- data/config/locales/de.yml +1 -3
- data/config/locales/el.yml +1 -3
- data/config/locales/en-CA.yml +138 -0
- data/config/locales/en-GB.yml +43 -3
- data/config/locales/en.yml +8 -4
- data/config/locales/es-MX.yml +3 -2
- data/config/locales/es.yml +10 -4
- data/config/locales/fa.yml +0 -2
- data/config/locales/fi.yml +0 -2
- data/config/locales/fr.yml +9 -2
- data/config/locales/he.yml +53 -7
- data/config/locales/hr.yml +0 -2
- data/config/locales/hu.yml +0 -2
- data/config/locales/id.yml +1 -3
- data/config/locales/it.yml +2 -4
- data/config/locales/ja.yml +1 -3
- data/config/locales/ko.yml +0 -2
- data/config/locales/lt.yml +24 -4
- data/config/locales/lv.yml +0 -2
- data/config/locales/nb.yml +0 -2
- data/config/locales/nl.yml +1 -3
- data/config/locales/pl.yml +3 -2
- data/config/locales/pt-BR.yml +1 -3
- data/config/locales/pt-PT.yml +0 -2
- data/config/locales/ro.yml +0 -2
- data/config/locales/ru.yml +1 -3
- data/config/locales/sk.yml +0 -2
- data/config/locales/sv-SE.yml +1 -3
- data/config/locales/tr.yml +0 -2
- data/config/locales/uk.yml +1 -3
- data/config/locales/vi.yml +0 -2
- data/config/locales/zh-CN.yml +0 -2
- data/config/locales/zh-TW.yml +1 -3
- data/config/mdl_style.rb +9 -0
- data/cucumber.yml +3 -3
- data/docs/0-installation.md +15 -12
- data/docs/1-general-configuration.md +10 -3
- data/docs/10-custom-pages.md +10 -5
- data/docs/11-decorators.md +1 -0
- data/docs/12-arbre-components.md +7 -9
- data/docs/13-authorization-adapter.md +39 -24
- data/docs/14-gotchas.md +41 -22
- data/docs/2-resource-customization.md +41 -18
- data/docs/3-index-pages.md +30 -12
- data/docs/3-index-pages/custom-index.md +1 -0
- data/docs/3-index-pages/index-as-block.md +0 -5
- data/docs/3-index-pages/index-as-blog.md +0 -5
- data/docs/3-index-pages/index-as-grid.md +0 -5
- data/docs/3-index-pages/index-as-table.md +1 -9
- data/docs/4-csv-format.md +2 -1
- data/docs/5-forms.md +45 -21
- data/docs/6-show-pages.md +2 -1
- data/docs/7-sidebars.md +2 -1
- data/docs/8-custom-actions.md +4 -1
- data/docs/9-batch-actions.md +4 -2
- data/docs/documentation.md +19 -21
- data/features/comments/commenting.feature +20 -0
- data/features/index/filters.feature +41 -1
- data/features/index/format_as_csv.feature +17 -0
- data/features/index/index_scopes.feature +15 -0
- data/features/registering_assets.feature +8 -4
- data/features/show/attributes_table_title.feature +54 -0
- data/features/show/tabs.feature +10 -4
- data/features/step_definitions/action_link_steps.rb +0 -1
- data/features/step_definitions/attributes_table_title_steps.rb +11 -0
- data/features/step_definitions/batch_action_steps.rb +2 -2
- data/features/step_definitions/comment_steps.rb +21 -1
- data/features/step_definitions/configuration_steps.rb +1 -1
- data/features/step_definitions/filter_steps.rb +9 -0
- data/features/step_definitions/format_steps.rb +1 -1
- data/features/step_definitions/index_scope_steps.rb +4 -0
- data/features/support/env.rb +5 -4
- data/features/support/regular_env.rb +7 -0
- data/features/support/reload_env.rb +7 -0
- data/gemfiles/rails_42.gemfile +2 -37
- data/gemfiles/rails_50.gemfile +5 -40
- data/gemfiles/rails_51.gemfile +5 -40
- data/lib/active_admin.rb +0 -3
- data/lib/active_admin/application.rb +6 -4
- data/lib/active_admin/asset_registration.rb +8 -0
- data/lib/active_admin/authorization_adapter.rb +0 -3
- data/lib/active_admin/base_controller.rb +1 -2
- data/lib/active_admin/base_controller/authorization.rb +0 -1
- data/lib/active_admin/base_controller/menu.rb +9 -9
- data/lib/active_admin/batch_actions/controller.rb +1 -1
- data/lib/active_admin/batch_actions/views/selection_cells.rb +6 -5
- data/lib/active_admin/csv_builder.rb +3 -3
- data/lib/active_admin/dependency.rb +1 -1
- data/lib/active_admin/devise.rb +2 -2
- data/lib/active_admin/dsl.rb +2 -2
- data/lib/active_admin/filters.rb +2 -0
- data/lib/active_admin/filters/active.rb +13 -14
- data/lib/active_admin/filters/active_filter.rb +87 -0
- data/lib/active_admin/filters/active_sidebar.rb +50 -0
- data/lib/active_admin/filters/forms.rb +1 -2
- data/lib/active_admin/filters/resource_extension.rb +2 -30
- data/lib/active_admin/helpers/settings.rb +0 -1
- data/lib/active_admin/inputs/datepicker_input.rb +5 -5
- data/lib/active_admin/inputs/filters/date_range_input.rb +12 -4
- data/lib/active_admin/inputs/filters/text_input.rb +0 -1
- data/lib/active_admin/menu.rb +4 -4
- data/lib/active_admin/menu_collection.rb +0 -2
- data/lib/active_admin/namespace.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -5
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +4 -2
- data/lib/active_admin/page_controller.rb +1 -1
- data/lib/active_admin/resource/action_items.rb +4 -0
- data/lib/active_admin/resource/attributes.rb +1 -1
- data/lib/active_admin/resource/page_presenters.rb +1 -1
- data/lib/active_admin/resource/routes.rb +0 -1
- data/lib/active_admin/resource/scopes.rb +2 -1
- data/lib/active_admin/resource_controller.rb +1 -1
- data/lib/active_admin/resource_controller/data_access.rb +8 -9
- data/lib/active_admin/resource_dsl.rb +10 -10
- data/lib/active_admin/router.rb +1 -1
- data/lib/active_admin/scope.rb +3 -3
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_helpers.rb +1 -0
- data/lib/active_admin/view_helpers/display_helper.rb +1 -1
- data/lib/active_admin/view_helpers/form_helper.rb +1 -1
- data/lib/active_admin/view_helpers/scope_name_helper.rb +16 -0
- data/lib/active_admin/views/action_items.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +1 -1
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +2 -10
- data/lib/active_admin/views/components/status_tag.rb +19 -11
- data/lib/active_admin/views/components/tabs.rb +2 -2
- data/lib/active_admin/views/header.rb +0 -1
- data/lib/active_admin/views/index_as_blog.rb +1 -2
- data/lib/active_admin/views/index_as_grid.rb +2 -2
- data/lib/active_admin/views/index_as_table.rb +19 -1
- data/lib/active_admin/views/pages/base.rb +4 -4
- data/lib/active_admin/views/pages/show.rb +6 -1
- data/lib/active_admin/views/title_bar.rb +4 -4
- data/lib/bug_report_templates/{rails_5_master.rb → active_admin_master.rb} +35 -40
- data/lib/generators/active_admin/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/templates/admin_user.rb.erb +1 -1
- data/spec/bug_report_templates_spec.rb +2 -3
- data/spec/rails_helper.rb +0 -3
- data/spec/spec_helper.rb +1 -12
- data/spec/support/active_admin_integration_spec_helper.rb +1 -1
- data/spec/support/rails_template.rb +5 -37
- data/spec/support/rails_template_with_data.rb +262 -3
- data/spec/support/templates/policies/active_admin/comment_policy.rb +1 -1
- data/spec/support/templates/policies/active_admin/page_policy.rb +1 -1
- data/spec/support/templates/policies/application_policy.rb +1 -2
- data/spec/support/templates/post_decorator.rb +0 -1
- data/spec/unit/abstract_view_factory_spec.rb +0 -1
- data/spec/unit/application_spec.rb +4 -0
- data/spec/unit/asset_registration_spec.rb +29 -0
- data/spec/unit/belongs_to_spec.rb +1 -2
- data/spec/unit/config_shared_examples.rb +1 -1
- data/spec/unit/csv_builder_spec.rb +2 -4
- data/spec/unit/dependency_spec.rb +7 -7
- data/spec/unit/dsl_spec.rb +0 -2
- data/spec/unit/filters/active_filter_spec.rb +135 -0
- data/spec/unit/filters/active_spec.rb +11 -1
- data/spec/unit/filters/filter_form_builder_spec.rb +9 -7
- data/spec/unit/form_builder_spec.rb +14 -14
- data/spec/unit/helpers/scope_chain_spec.rb +0 -1
- data/spec/unit/i18n_spec.rb +17 -0
- data/spec/unit/menu_item_spec.rb +1 -3
- data/spec/unit/namespace/register_page_spec.rb +1 -1
- data/spec/unit/namespace_spec.rb +0 -1
- data/spec/unit/page_spec.rb +0 -3
- data/spec/unit/resource/action_items_spec.rb +5 -1
- data/spec/unit/resource/attributes_spec.rb +1 -2
- data/spec/unit/resource/ordering_spec.rb +0 -3
- data/spec/unit/resource/scopes_spec.rb +1 -1
- data/spec/unit/resource_controller/data_access_spec.rb +2 -2
- data/spec/unit/resource_controller_spec.rb +1 -2
- data/spec/unit/resource_spec.rb +9 -2
- data/spec/unit/routing_spec.rb +0 -2
- data/spec/unit/scope_spec.rb +3 -3
- data/spec/unit/settings_spec.rb +0 -1
- data/spec/unit/view_factory_spec.rb +1 -1
- data/spec/unit/view_helpers/flash_helper_spec.rb +0 -1
- data/spec/unit/view_helpers/form_helper_spec.rb +3 -4
- data/spec/unit/view_helpers/method_or_proc_helper_spec.rb +0 -1
- data/spec/unit/views/components/attributes_table_spec.rb +0 -1
- data/spec/unit/views/components/columns_spec.rb +0 -2
- data/spec/unit/views/components/site_title_spec.rb +0 -2
- data/spec/unit/views/components/status_tag_spec.rb +23 -7
- data/spec/unit/views/components/tabs_spec.rb +29 -1
- data/spec/unit/views/pages/index_spec.rb +1 -1
- data/tasks/docs.rake +37 -10
- data/tasks/lint.rake +14 -1
- data/tasks/local.rake +2 -2
- data/tasks/test.rake +8 -25
- data/vendor/assets/javascripts/jquery-ui/data.js +41 -0
- data/vendor/assets/javascripts/jquery-ui/disable-selection.js +48 -0
- data/vendor/assets/javascripts/jquery-ui/escape-selector.js +23 -0
- data/vendor/assets/javascripts/jquery-ui/focusable.js +86 -0
- data/vendor/assets/javascripts/jquery-ui/ie.js +17 -0
- data/vendor/assets/javascripts/jquery-ui/keycode.js +47 -0
- data/vendor/assets/javascripts/jquery-ui/plugin.js +46 -0
- data/vendor/assets/javascripts/jquery-ui/position.js +500 -0
- data/vendor/assets/javascripts/jquery-ui/safe-active-element.js +42 -0
- data/vendor/assets/javascripts/jquery-ui/safe-blur.js +23 -0
- data/vendor/assets/javascripts/jquery-ui/scroll-parent.js +47 -0
- data/vendor/assets/javascripts/jquery-ui/tabbable.js +38 -0
- data/vendor/assets/javascripts/jquery-ui/unique-id.js +51 -0
- data/vendor/assets/javascripts/jquery-ui/version.js +17 -0
- data/vendor/assets/javascripts/jquery-ui/widget.js +735 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/button.js +391 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/checkboxradio.js +300 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/controlgroup.js +300 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/datepicker.js +2123 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/dialog.js +954 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/draggable.js +1259 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/mouse.js +230 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/resizable.js +1207 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/sortable.js +1561 -0
- data/vendor/assets/javascripts/jquery-ui/widgets/tabs.js +931 -0
- data/vendor/assets/stylesheets/active_admin/_normalize.scss +447 -0
- metadata +62 -51
- data/.hound.yml +0 -14
- data/Appraisals +0 -41
- data/app/assets/images/active_admin/datepicker/datepicker-input-icon.png +0 -0
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +0 -18
- data/app/assets/stylesheets/active_admin/mixins/_reset.scss +0 -165
- data/lib/active_admin/filters/humanized.rb +0 -68
- data/spec/requests/javascript_spec.rb +0 -22
- data/spec/support/jslint.yml +0 -80
- data/spec/unit/filters/humanized_spec.rb +0 -64
- data/tasks/yard.rake +0 -9
data/config/locales/zh-TW.yml
CHANGED
|
@@ -68,7 +68,6 @@
|
|
|
68
68
|
one: "成功刪除 1 %{model}"
|
|
69
69
|
other: "成功刪除 %{count} %{plural_model}"
|
|
70
70
|
selection_toggle_explanation: "(切換選取)"
|
|
71
|
-
link: "建立一個"
|
|
72
71
|
action_label: "%{title} 已選取"
|
|
73
72
|
labels:
|
|
74
73
|
destroy: "刪除"
|
|
@@ -78,7 +77,6 @@
|
|
|
78
77
|
author_type: "作者身份"
|
|
79
78
|
body: "內文"
|
|
80
79
|
author: "作者"
|
|
81
|
-
title: "評論"
|
|
82
80
|
add: "新增評論"
|
|
83
81
|
delete: "刪除評論"
|
|
84
82
|
delete_confirmation: "你確定要刪除這些評論嗎?"
|
|
@@ -126,7 +124,7 @@
|
|
|
126
124
|
unsupported_browser:
|
|
127
125
|
headline: "很抱歉,ActiveAdmin 已不再支援 Internet Explorer 8 以下版本的瀏覽器。"
|
|
128
126
|
recommendation: "建議您升級到最新版本的<a href=\"http://windows.microsoft.com/ie\">Internet Explorer</a>,<a href=\"https://chrome.google.com/\">Google Chrome</a>,或是 <a href=\"https://mozilla.org/firefox/\">Firefox</a>。"
|
|
129
|
-
turn_off_compatibility_view: "若您是使用 IE 9 或更新的版本,請確認<a href=\"
|
|
127
|
+
turn_off_compatibility_view: "若您是使用 IE 9 或更新的版本,請確認<a href=\"https://support.microsoft.com/zh-tw/help/17471\">「相容性檢視」是關閉的</a>。"
|
|
130
128
|
access_denied:
|
|
131
129
|
message: "您沒有權限執行此項操作"
|
|
132
130
|
index_list:
|
data/config/mdl_style.rb
ADDED
data/cucumber.yml
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
default: --format 'progress' --require features/support/
|
|
2
|
-
wip: --format 'progress' --require features/support/env.rb
|
|
3
|
-
class-reloading: CLASS_RELOADING=true --format 'progress' --require features/support/
|
|
1
|
+
default: --format 'progress' --require features/support/regular_env.rb features --tags ~@requires-reloading --tags ~@wip
|
|
2
|
+
wip: --format 'progress' --require features/support/env.rb features --tags @wip:3 --wip features
|
|
3
|
+
class-reloading: CLASS_RELOADING=true --format 'progress' --require features/support/reload_env.rb features --tags @requires-reloading
|
data/docs/0-installation.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/0-installation.html
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Installation
|
|
5
6
|
|
|
6
7
|
Active Admin is a Ruby Gem.
|
|
@@ -22,29 +23,30 @@ that can be injected into your existing Ruby on Rails application.
|
|
|
22
23
|
|
|
23
24
|
After installing the gem, you need to run the generator. Here are your options:
|
|
24
25
|
|
|
25
|
-
|
|
26
|
+
* If you don't want to use Devise, run it with `--skip-users`:
|
|
27
|
+
|
|
26
28
|
```sh
|
|
27
29
|
rails g active_admin:install --skip-users
|
|
28
30
|
```
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
* If you want to use an existing user class, provide it as an argument:
|
|
33
|
+
|
|
31
34
|
```sh
|
|
32
35
|
rails g active_admin:install User
|
|
33
36
|
```
|
|
34
37
|
|
|
35
|
-
|
|
38
|
+
* Otherwise, with no arguments we will create an `AdminUser` class to use with Devise:
|
|
39
|
+
|
|
36
40
|
```sh
|
|
37
41
|
rails g active_admin:install
|
|
38
42
|
```
|
|
39
43
|
|
|
40
44
|
The generator adds these core files, among others:
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
app/
|
|
44
|
-
app/assets/
|
|
45
|
-
|
|
46
|
-
config/initializers/active_admin.rb
|
|
47
|
-
```
|
|
46
|
+
* `app/admin/dashboard.rb`
|
|
47
|
+
* `app/assets/javascripts/active_admin.js.coffee`
|
|
48
|
+
* `app/assets/stylesheets/active_admin.scss`
|
|
49
|
+
* `config/initializers/active_admin.rb`
|
|
48
50
|
|
|
49
51
|
Now, migrate and seed your database before starting the server:
|
|
50
52
|
|
|
@@ -67,7 +69,8 @@ To register an existing model with Active Admin:
|
|
|
67
69
|
rails generate active_admin:resource MyModel
|
|
68
70
|
```
|
|
69
71
|
|
|
70
|
-
This creates a file at `app/admin/my_model.rb` to set up the UI; refresh your
|
|
72
|
+
This creates a file at `app/admin/my_model.rb` to set up the UI; refresh your
|
|
73
|
+
browser to see it.
|
|
71
74
|
|
|
72
75
|
# Upgrading
|
|
73
76
|
|
|
@@ -98,8 +101,8 @@ Kaminari.configure do |config|
|
|
|
98
101
|
end
|
|
99
102
|
```
|
|
100
103
|
|
|
101
|
-
If you are also using [Draper](https://github.com/drapergem/draper), you may
|
|
102
|
-
make sure `per_page_kaminari` is delegated correctly:
|
|
104
|
+
If you are also using [Draper](https://github.com/drapergem/draper), you may
|
|
105
|
+
want to make sure `per_page_kaminari` is delegated correctly:
|
|
103
106
|
|
|
104
107
|
```ruby
|
|
105
108
|
Draper::CollectionDecorator.send :delegate, :per_page_kaminari
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/1-general-configuration.html
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# General Configuration
|
|
5
6
|
|
|
6
7
|
You can configure Active Admin settings in `config/initializers/active_admin.rb`.
|
|
@@ -45,10 +46,12 @@ config.site_title_image = ->(context) { context.current_user.company.logo_url }
|
|
|
45
46
|
|
|
46
47
|
## Internationalization (I18n)
|
|
47
48
|
|
|
48
|
-
To translate Active Admin to a new language or customize an existing
|
|
49
|
+
To translate Active Admin to a new language or customize an existing
|
|
50
|
+
translation, you can copy
|
|
49
51
|
[config/locales/en.yml](https://github.com/activeadmin/activeadmin/blob/master/config/locales/en.yml)
|
|
50
|
-
to your application's `config/locales` folder and update it. We welcome
|
|
51
|
-
so feel free to
|
|
52
|
+
to your application's `config/locales` folder and update it. We welcome
|
|
53
|
+
new/updated translations, so feel free to
|
|
54
|
+
[contribute](https://github.com/activeadmin/activeadmin/blob/master/CONTRIBUTING.md)!
|
|
52
55
|
To translate third party gems like devise, use for example devise-i18n.
|
|
53
56
|
|
|
54
57
|
## Localize Format For Dates and Times
|
|
@@ -140,16 +143,19 @@ config.comments_registration_name = 'AdminComment'
|
|
|
140
143
|
|
|
141
144
|
You can change the order for the comments and you can change the column to be
|
|
142
145
|
used for ordering:
|
|
146
|
+
|
|
143
147
|
```ruby
|
|
144
148
|
config.comments_order = 'created_at ASC'
|
|
145
149
|
```
|
|
146
150
|
|
|
147
151
|
You can disable the menu item for the comments index page:
|
|
152
|
+
|
|
148
153
|
```ruby
|
|
149
154
|
config.comments_menu = false
|
|
150
155
|
```
|
|
151
156
|
|
|
152
157
|
You can customize the comment menu:
|
|
158
|
+
|
|
153
159
|
```ruby
|
|
154
160
|
config.comments_menu = { parent: 'Admin', priority: 1 }
|
|
155
161
|
```
|
|
@@ -177,6 +183,7 @@ end
|
|
|
177
183
|
|
|
178
184
|
By default, Active Admin displays a "Powered by ActiveAdmin" message on every
|
|
179
185
|
page. You can override this message and show domain-specific messaging:
|
|
186
|
+
|
|
180
187
|
```ruby
|
|
181
188
|
config.footer = "MyApp Revision v1.3"
|
|
182
189
|
```
|
data/docs/10-custom-pages.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/10-custom-pages.html
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Custom Pages
|
|
5
6
|
|
|
6
7
|
If you have data you want on a standalone page that isn't tied to a resource,
|
|
@@ -52,7 +53,7 @@ end
|
|
|
52
53
|
|
|
53
54
|
See the [Menu](2-resource-customization.md#customize-the-menu) documentation.
|
|
54
55
|
|
|
55
|
-
##
|
|
56
|
+
## Customize the breadcrumbs
|
|
56
57
|
|
|
57
58
|
```ruby
|
|
58
59
|
ActiveAdmin.register_page "Calendar" do
|
|
@@ -85,7 +86,8 @@ ActiveAdmin.register_page "Status" do
|
|
|
85
86
|
end
|
|
86
87
|
```
|
|
87
88
|
|
|
88
|
-
See also the [Belongs To](2-resource-customization.md#belongs-to) documentation
|
|
89
|
+
See also the [Belongs To](2-resource-customization.md#belongs-to) documentation
|
|
90
|
+
and examples.
|
|
89
91
|
|
|
90
92
|
## Add a Sidebar
|
|
91
93
|
|
|
@@ -104,7 +106,8 @@ end
|
|
|
104
106
|
|
|
105
107
|
## Add a Page Action
|
|
106
108
|
|
|
107
|
-
Page actions are custom controller actions (which mirror the resource DSL for
|
|
109
|
+
Page actions are custom controller actions (which mirror the resource DSL for
|
|
110
|
+
the same feature).
|
|
108
111
|
|
|
109
112
|
```ruby
|
|
110
113
|
page_action :add_event, method: :post do
|
|
@@ -119,7 +122,8 @@ end
|
|
|
119
122
|
|
|
120
123
|
This defines the route `/admin/calendar/add_event` which can handle HTTP POST requests.
|
|
121
124
|
|
|
122
|
-
Clicking on the action item will reload page and display the message "Your event
|
|
125
|
+
Clicking on the action item will reload page and display the message "Your event
|
|
126
|
+
was added"
|
|
123
127
|
|
|
124
128
|
Page actions can handle multiple HTTP verbs.
|
|
125
129
|
|
|
@@ -128,4 +132,5 @@ page_action :add_event, method: [:get, :post] do
|
|
|
128
132
|
# ...
|
|
129
133
|
end
|
|
130
134
|
```
|
|
131
|
-
|
|
135
|
+
|
|
136
|
+
See also the [Custom Actions](8-custom-actions.md#http-verbs) example.
|
data/docs/11-decorators.md
CHANGED
data/docs/12-arbre-components.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/12-arbre-components.html
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Arbre Components
|
|
5
6
|
|
|
6
7
|
Arbre allows the creation of shareable and extendable HTML components and is
|
|
@@ -21,7 +22,7 @@ ActiveAdmin.register Post do
|
|
|
21
22
|
row :id
|
|
22
23
|
row 'Tags' do
|
|
23
24
|
post.tags.each do |tag|
|
|
24
|
-
a tag, href: admin_post_path(q: {tagged_with_contains: tag})
|
|
25
|
+
a tag, href: admin_post_path(q: {tagged_with_contains: tag})
|
|
25
26
|
text_node " ".html_safe
|
|
26
27
|
end
|
|
27
28
|
end
|
|
@@ -57,7 +58,7 @@ The Columns component allows you draw content into scalable columns. All you
|
|
|
57
58
|
need to do is define the number of columns and the component will take care of
|
|
58
59
|
the rest.
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
### Simple Columns
|
|
61
62
|
|
|
62
63
|
To create simple columns, use the `columns` method. Within the block, call
|
|
63
64
|
the #column method to create a new column.
|
|
@@ -138,18 +139,15 @@ takes a block.
|
|
|
138
139
|
Status tags provide convenient syntactic sugar for styling items that have
|
|
139
140
|
status. A common example of where the status tag could be useful is for orders
|
|
140
141
|
that are complete or in progress. `status_tag` takes a status, like
|
|
141
|
-
"In Progress",
|
|
142
|
-
|
|
142
|
+
"In Progress", and a hash of options. The status_tag will generate HTML markup
|
|
143
|
+
that Active Admin CSS uses in styling.
|
|
143
144
|
|
|
144
145
|
```ruby
|
|
145
146
|
status_tag 'In Progress'
|
|
146
147
|
# => <span class='status_tag in_progress'>In Progress</span>
|
|
147
148
|
|
|
148
|
-
status_tag 'active', :
|
|
149
|
-
# => <span class='status_tag active
|
|
150
|
-
|
|
151
|
-
status_tag 'active', :ok, class: 'important', id: 'status_123', label: 'on'
|
|
152
|
-
# => <span class='status_tag active ok important' id='status_123'>on</span>
|
|
149
|
+
status_tag 'active', class: 'important', id: 'status_123', label: 'on'
|
|
150
|
+
# => <span class='status_tag active important' id='status_123'>on</span>
|
|
153
151
|
```
|
|
154
152
|
|
|
155
153
|
## Tabs
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/13-authorization-adapter.html
|
|
3
3
|
---
|
|
4
|
+
|
|
4
5
|
# Authorization Adapter
|
|
5
6
|
|
|
6
7
|
Active Admin offers the ability to define and use your own authorization
|
|
@@ -40,7 +41,8 @@ application's `config/initializers/active_admin.rb` and add/modify the line:
|
|
|
40
41
|
config.authorization_adapter = "OnlyAuthorsAuthorization"
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
Authorization adapters can be configured per ActiveAdmin namespace as well, for
|
|
44
|
+
Authorization adapters can be configured per ActiveAdmin namespace as well, for
|
|
45
|
+
example:
|
|
44
46
|
|
|
45
47
|
```ruby
|
|
46
48
|
ActiveAdmin.setup do |config|
|
|
@@ -73,9 +75,9 @@ end
|
|
|
73
75
|
|
|
74
76
|
## Scoping Collections in Authorization Adapters
|
|
75
77
|
|
|
76
|
-
`ActiveAdmin::AuthorizationAdapter` also provides a hook method
|
|
77
|
-
for the adapter to scope the resource's collection. For
|
|
78
|
-
centralize the scoping:
|
|
78
|
+
`ActiveAdmin::AuthorizationAdapter` also provides a hook method
|
|
79
|
+
(`#scope_collection`) for the adapter to scope the resource's collection. For
|
|
80
|
+
example, you may want to centralize the scoping:
|
|
79
81
|
|
|
80
82
|
```ruby
|
|
81
83
|
class OnlyMyAccount < ActiveAdmin::AuthorizationAdapter
|
|
@@ -104,7 +106,9 @@ class OnlyDashboard < ActiveAdmin::AuthorizationAdapter
|
|
|
104
106
|
def authorized?(action, subject = nil)
|
|
105
107
|
case subject
|
|
106
108
|
when ActiveAdmin::Page
|
|
107
|
-
action == :read &&
|
|
109
|
+
action == :read &&
|
|
110
|
+
subject.name == "Dashboard" &&
|
|
111
|
+
subject.namespace.name == :admin
|
|
108
112
|
else
|
|
109
113
|
false
|
|
110
114
|
end
|
|
@@ -116,24 +120,23 @@ end
|
|
|
116
120
|
|
|
117
121
|
By default Active Admin simplifies the controller actions into 4 actions:
|
|
118
122
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
123
|
+
* `:read` - This controls if the user can view the menu item as well as the
|
|
124
|
+
index and show screens.
|
|
125
|
+
* `:create` - This controls if the user can view the new screen and submit
|
|
126
|
+
the form to the create action.
|
|
127
|
+
* `:update` - This controls if the user can view the edit screen and submit
|
|
128
|
+
the form to the update action.
|
|
129
|
+
* `:destroy` - This controls if the user can delete a resource.
|
|
126
130
|
|
|
127
131
|
Each of these actions is available as a constant. Eg: `:read` is available as
|
|
128
132
|
`ActiveAdmin::Authorization::READ`.
|
|
129
133
|
|
|
130
|
-
|
|
131
134
|
## Checking for Authorization in Controllers and Views
|
|
132
135
|
|
|
133
136
|
Active Admin provides a helper method to check if the current user is
|
|
134
137
|
authorized to perform an action on a subject.
|
|
135
138
|
|
|
136
|
-
Simply use the `#authorized?(action, subject) method to check.
|
|
139
|
+
Simply use the `#authorized?(action, subject)` method to check.
|
|
137
140
|
|
|
138
141
|
```ruby
|
|
139
142
|
ActiveAdmin.register Post do
|
|
@@ -187,18 +190,19 @@ initializer:
|
|
|
187
190
|
config.authorization_adapter = ActiveAdmin::CanCanAdapter
|
|
188
191
|
```
|
|
189
192
|
|
|
190
|
-
You can also specify a method to be called on unauthorized access. This is
|
|
191
|
-
in order to prevent a redirect loop that can happen if a user tries to
|
|
192
|
-
they don't have permissions for (see
|
|
193
|
+
You can also specify a method to be called on unauthorized access. This is
|
|
194
|
+
necessary in order to prevent a redirect loop that can happen if a user tries to
|
|
195
|
+
access a page they don't have permissions for (see
|
|
196
|
+
[#2081](https://github.com/activeadmin/activeadmin/issues/2081)).
|
|
193
197
|
|
|
194
198
|
```ruby
|
|
195
199
|
config.on_unauthorized_access = :access_denied
|
|
196
200
|
```
|
|
197
201
|
|
|
198
|
-
The method `access_denied` would be defined in `application_controller.rb`. Here
|
|
199
|
-
example that redirects the user from the page they don't have permission
|
|
200
|
-
access to a resource they have permission to access (organizations in this
|
|
201
|
-
also displays the error message in the browser:
|
|
202
|
+
The method `access_denied` would be defined in `application_controller.rb`. Here
|
|
203
|
+
is one example that redirects the user from the page they don't have permission
|
|
204
|
+
to access to a resource they have permission to access (organizations in this
|
|
205
|
+
case), and also displays the error message in the browser:
|
|
202
206
|
|
|
203
207
|
```ruby
|
|
204
208
|
class ApplicationController < ActionController::Base
|
|
@@ -235,11 +239,14 @@ class Ability
|
|
|
235
239
|
end
|
|
236
240
|
```
|
|
237
241
|
|
|
238
|
-
To view more details about the API's, visit project pages of
|
|
242
|
+
To view more details about the API's, visit project pages of
|
|
243
|
+
[CanCan](https://github.com/ryanb/cancan) and
|
|
244
|
+
[CanCanCan](https://github.com/CanCanCommunity/cancancan).
|
|
239
245
|
|
|
240
246
|
## Using the Pundit Adapter
|
|
241
247
|
|
|
242
|
-
Active Admin provides an adapter out of the box also for
|
|
248
|
+
Active Admin provides an adapter out of the box also for
|
|
249
|
+
[Pundit](https://github.com/elabs/pundit).
|
|
243
250
|
|
|
244
251
|
To use the Pundit adapter, simply update the configuration in the Active Admin
|
|
245
252
|
initializer:
|
|
@@ -248,4 +255,12 @@ initializer:
|
|
|
248
255
|
config.authorization_adapter = ActiveAdmin::PunditAdapter
|
|
249
256
|
```
|
|
250
257
|
|
|
251
|
-
You can simply use Pundit the way that you would expect and Active Admin will
|
|
258
|
+
You can simply use Pundit the way that you would expect and Active Admin will
|
|
259
|
+
use it for authorization. Check Pundit's documentation to [set up Pundit in your
|
|
260
|
+
application](https://github.com/elabs/pundit#installation). If you want to use
|
|
261
|
+
batch actions just ensure that `destroy_all?` method is defined in your policy
|
|
262
|
+
class. You can use this [template
|
|
263
|
+
policy](https://github.com/activeadmin/activeadmin/blob/master/spec/support/templates/policies/application_policy.rb)
|
|
264
|
+
in your application instead of default one generated by Pundit's `rails g
|
|
265
|
+
pundit:install` command.
|
|
266
|
+
|
data/docs/14-gotchas.md
CHANGED
|
@@ -1,24 +1,29 @@
|
|
|
1
1
|
---
|
|
2
2
|
redirect_from: /docs/14-gotchas.html
|
|
3
3
|
---
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
# Gotchas
|
|
5
6
|
|
|
6
7
|
## Security
|
|
7
8
|
|
|
8
9
|
### Spreadsheet applications vulnerable to unescaped CSV data
|
|
9
10
|
|
|
10
|
-
If your CSV export includes untrusted data provided by your users, it's possible
|
|
11
|
+
If your CSV export includes untrusted data provided by your users, it's possible
|
|
12
|
+
that they could include an executable formula that could call arbitrary commands
|
|
13
|
+
on your computer. See
|
|
14
|
+
[#4256](https://github.com/activeadmin/activeadmin/issues/4256) for more
|
|
15
|
+
details.
|
|
11
16
|
|
|
12
17
|
## Session Commits & Asset Pipeline
|
|
13
18
|
|
|
14
|
-
When configuring the asset pipeline ensure that the asset prefix
|
|
15
|
-
(`config.assets.prefix`) is not the same as the namespace of ActiveAdmin
|
|
16
|
-
(default namespace is `/admin`). If they are the same Sprockets will prevent the
|
|
17
|
-
session from being committed. Flash messages won't work and you will be unable to
|
|
19
|
+
When configuring the asset pipeline ensure that the asset prefix
|
|
20
|
+
(`config.assets.prefix`) is not the same as the namespace of ActiveAdmin
|
|
21
|
+
(default namespace is `/admin`). If they are the same Sprockets will prevent the
|
|
22
|
+
session from being committed. Flash messages won't work and you will be unable to
|
|
18
23
|
use the session for storing anything.
|
|
19
24
|
|
|
20
|
-
For more information see the following
|
|
21
|
-
|
|
25
|
+
For more information see [the following
|
|
26
|
+
post](http://www.intridea.com/blog/2013/3/20/rails-assets-prefix-may-disable-your-session).
|
|
22
27
|
|
|
23
28
|
## Helpers
|
|
24
29
|
|
|
@@ -27,13 +32,14 @@ find a solution.
|
|
|
27
32
|
|
|
28
33
|
### Helpers are not reloading in development
|
|
29
34
|
|
|
30
|
-
This is a known and still open
|
|
31
|
-
the only way is
|
|
35
|
+
This is a known and still open
|
|
36
|
+
[issue](https://github.com/activeadmin/activeadmin/issues/697) the only way is
|
|
37
|
+
to restart your server each time you change a helper.
|
|
32
38
|
|
|
33
39
|
### Helper maybe not included by default
|
|
34
40
|
|
|
35
|
-
If you use `config.action_controller.include_all_helpers = false` in your
|
|
36
|
-
you need to include it by hand.
|
|
41
|
+
If you use `config.action_controller.include_all_helpers = false` in your
|
|
42
|
+
application config, you need to include it by hand.
|
|
37
43
|
|
|
38
44
|
#### Solutions
|
|
39
45
|
|
|
@@ -62,23 +68,27 @@ end
|
|
|
62
68
|
|
|
63
69
|
## CSS
|
|
64
70
|
|
|
65
|
-
In order to avoid the override of your application style with the Active Admin
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
In order to avoid the override of your application style with the Active Admin
|
|
72
|
+
one, you can do one of these things:
|
|
73
|
+
|
|
74
|
+
* You can properly move the generated file `active_admin.scss` from
|
|
75
|
+
`app/assets/stylesheets` to `vendor/assets/stylesheets`.
|
|
76
|
+
* You can remove all `require_tree` commands from your root level css files,
|
|
77
|
+
where the `active_admin.scss` is in the tree.
|
|
68
78
|
|
|
69
79
|
## Conflicts
|
|
70
80
|
|
|
71
81
|
### With gems that provides a `search` class method on a model
|
|
72
82
|
|
|
73
|
-
If a gem defines a `search` class method on a model, this can result in conflicts
|
|
83
|
+
If a gem defines a `search` class method on a model, this can result in conflicts
|
|
74
84
|
with the same method provided by `ransack` (a dependency of ActiveAdmin).
|
|
75
85
|
|
|
76
|
-
Each of this conflicts need to solved is a different way. Some solutions are
|
|
86
|
+
Each of this conflicts need to solved is a different way. Some solutions are
|
|
77
87
|
listed below.
|
|
78
88
|
|
|
79
89
|
#### `tire`, `retire` and `elasticsearch-rails`
|
|
80
90
|
|
|
81
|
-
This conflict can be solved, by using explicitly the `search` method of `tire`,
|
|
91
|
+
This conflict can be solved, by using explicitly the `search` method of `tire`,
|
|
82
92
|
`retire` or `elasticsearch-rails`:
|
|
83
93
|
|
|
84
94
|
##### For `tire` and `retire`
|
|
@@ -101,9 +111,12 @@ YourModel.solr_search
|
|
|
101
111
|
|
|
102
112
|
### Rails 5 scaffold generators
|
|
103
113
|
|
|
104
|
-
Active Admin requires the `inherited_resources` gem which may break scaffolding
|
|
114
|
+
Active Admin requires the `inherited_resources` gem which may break scaffolding
|
|
115
|
+
under Rails 5 as it replaces the default scaffold generator. The solution is to
|
|
116
|
+
configure the default controller in `config/application.rb` as outlined in
|
|
117
|
+
[activeadmin/inherited_resources#195](https://github.com/activeadmin/inherited_resources/issues/195)
|
|
105
118
|
|
|
106
|
-
```
|
|
119
|
+
```ruby
|
|
107
120
|
module SampleApp
|
|
108
121
|
class Application < Rails::Application
|
|
109
122
|
...
|
|
@@ -113,7 +126,13 @@ module SampleApp
|
|
|
113
126
|
end
|
|
114
127
|
```
|
|
115
128
|
|
|
116
|
-
|
|
117
129
|
## Authentication & Application Controller
|
|
118
130
|
|
|
119
|
-
The `ActiveAdmin::BaseController` inherits from the `ApplicationController`. Any
|
|
131
|
+
The `ActiveAdmin::BaseController` inherits from the `ApplicationController`. Any
|
|
132
|
+
authentication method(s) specified in the `ApplicationController` callbacks will
|
|
133
|
+
be called instead of the authentication method in the active admin config file.
|
|
134
|
+
For example, if the ApplicationController has a callback `before_action
|
|
135
|
+
:custom_authentication_method` and the config file's authentication method is
|
|
136
|
+
`config.authentication_method = :authenticate_active_admin_user`, then
|
|
137
|
+
`custom_authentication_method` will be called instead of
|
|
138
|
+
`authenticate_active_admin_user`.
|