activeadmin 2.5.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of activeadmin might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +120 -6
- data/CONTRIBUTING.md +11 -57
- data/README.md +2 -2
- data/app/assets/javascripts/active_admin/base.js +26 -18
- data/app/assets/stylesheets/active_admin/_header.scss +37 -3
- data/app/assets/stylesheets/active_admin/components/_comments.scss +2 -2
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +3 -0
- data/app/javascript/active_admin/base.js +9 -0
- data/app/javascript/active_admin/initializers/per-page.js +1 -1
- data/app/javascript/active_admin/lib/checkbox-toggler.js +3 -3
- data/app/javascript/active_admin/lib/dropdown-menu.js +1 -1
- data/app/javascript/active_admin/lib/modal-dialog.js +7 -7
- data/app/javascript/active_admin/lib/per-page.js +1 -1
- data/app/javascript/active_admin/lib/table-checkbox-toggler.js +1 -1
- data/app/views/layouts/active_admin_logged_out.html.erb +15 -5
- data/config/locales/ar.yml +6 -6
- data/config/locales/en-CA.yml +3 -3
- data/config/locales/en-GB.yml +3 -3
- data/config/locales/en.yml +3 -3
- data/config/locales/es-MX.yml +2 -1
- data/config/locales/es.yml +5 -5
- data/config/locales/fr.yml +4 -4
- data/config/locales/it.yml +18 -0
- data/config/locales/ja.yml +3 -3
- data/config/locales/lv.yml +2 -2
- data/config/locales/vi.yml +6 -5
- data/docs/0-installation.md +26 -2
- data/docs/11-decorators.md +16 -5
- data/docs/2-resource-customization.md +10 -1
- data/docs/3-index-pages.md +1 -1
- data/docs/9-batch-actions.md +2 -2
- data/docs/Gemfile +2 -2
- data/docs/Gemfile.lock +93 -84
- data/docs/_includes/top-menu.html +1 -1
- data/docs/documentation.md +1 -1
- data/docs/index.html +6 -6
- data/lib/active_admin.rb +60 -60
- data/lib/active_admin/application.rb +13 -13
- data/lib/active_admin/application_settings.rb +3 -3
- data/lib/active_admin/authorization_adapter.rb +3 -3
- data/lib/active_admin/base_controller.rb +4 -4
- data/lib/active_admin/base_controller/authorization.rb +13 -12
- data/lib/active_admin/batch_actions/controller.rb +3 -3
- data/lib/active_admin/batch_actions/resource_extension.rb +9 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +6 -6
- data/lib/active_admin/batch_actions/views/selection_cells.rb +3 -3
- data/lib/active_admin/cancan_adapter.rb +1 -1
- data/lib/active_admin/collection_decorator.rb +31 -0
- data/lib/active_admin/csv_builder.rb +11 -7
- data/lib/active_admin/dependency.rb +11 -11
- data/lib/active_admin/devise.rb +5 -5
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/dynamic_settings_node.rb +2 -2
- data/lib/active_admin/engine.rb +3 -3
- data/lib/active_admin/filters.rb +7 -7
- data/lib/active_admin/filters/active.rb +1 -1
- data/lib/active_admin/filters/active_filter.rb +5 -4
- data/lib/active_admin/filters/active_sidebar.rb +5 -5
- data/lib/active_admin/filters/forms.rb +6 -6
- data/lib/active_admin/filters/formtastic_addons.rb +1 -6
- data/lib/active_admin/filters/resource_extension.rb +1 -1
- data/lib/active_admin/form_builder.rb +21 -19
- data/lib/active_admin/generators/boilerplate.rb +1 -1
- data/lib/active_admin/helpers/optional_display.rb +2 -2
- data/lib/active_admin/inputs/datepicker_input.rb +1 -1
- data/lib/active_admin/inputs/filters/base.rb +1 -1
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +4 -4
- data/lib/active_admin/inputs/filters/boolean_input.rb +1 -1
- data/lib/active_admin/inputs/filters/check_boxes_input.rb +1 -1
- data/lib/active_admin/inputs/filters/date_range_input.rb +12 -9
- data/lib/active_admin/inputs/filters/select_input.rb +2 -2
- data/lib/active_admin/localizers.rb +1 -1
- data/lib/active_admin/localizers/resource_localizer.rb +3 -3
- data/lib/active_admin/menu.rb +6 -3
- data/lib/active_admin/menu_item.rb +7 -7
- data/lib/active_admin/namespace.rb +12 -12
- data/lib/active_admin/namespace_settings.rb +8 -5
- data/lib/active_admin/order_clause.rb +1 -1
- data/lib/active_admin/orm/active_record.rb +1 -1
- data/lib/active_admin/orm/active_record/comments.rb +19 -19
- data/lib/active_admin/orm/active_record/comments/comment.rb +3 -3
- data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +19 -19
- data/lib/active_admin/page.rb +1 -1
- data/lib/active_admin/pundit_adapter.rb +5 -5
- data/lib/active_admin/resource.rb +17 -17
- data/lib/active_admin/resource/action_items.rb +5 -5
- data/lib/active_admin/resource/attributes.rb +1 -1
- data/lib/active_admin/resource/belongs_to.rb +2 -2
- data/lib/active_admin/resource/controllers.rb +1 -1
- data/lib/active_admin/resource/menu.rb +4 -4
- data/lib/active_admin/resource/naming.rb +5 -5
- data/lib/active_admin/resource/routes.rb +5 -5
- data/lib/active_admin/resource/scope_to.rb +7 -7
- data/lib/active_admin/resource/sidebars.rb +1 -1
- data/lib/active_admin/resource_controller.rb +12 -11
- data/lib/active_admin/resource_controller/data_access.rb +1 -1
- data/lib/active_admin/resource_controller/decorators.rb +6 -26
- data/lib/active_admin/resource_controller/streaming.rb +7 -6
- data/lib/active_admin/resource_dsl.rb +5 -5
- data/lib/active_admin/scope.rb +6 -6
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +17 -17
- data/lib/active_admin/view_helpers.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +3 -3
- data/lib/active_admin/view_helpers/display_helper.rb +5 -5
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -1
- data/lib/active_admin/view_helpers/fields_for.rb +2 -2
- data/lib/active_admin/views.rb +1 -1
- data/lib/active_admin/views/components/active_admin_form.rb +5 -5
- data/lib/active_admin/views/components/attributes_table.rb +5 -5
- data/lib/active_admin/views/components/blank_slate.rb +1 -1
- data/lib/active_admin/views/components/dropdown_menu.rb +8 -8
- data/lib/active_admin/views/components/index_list.rb +3 -3
- data/lib/active_admin/views/components/menu.rb +1 -1
- data/lib/active_admin/views/components/menu_item.rb +4 -4
- data/lib/active_admin/views/components/paginated_collection.rb +18 -18
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +7 -5
- data/lib/active_admin/views/components/site_title.rb +1 -1
- data/lib/active_admin/views/components/status_tag.rb +11 -11
- data/lib/active_admin/views/components/table_for.rb +17 -17
- data/lib/active_admin/views/components/tabs.rb +3 -3
- data/lib/active_admin/views/footer.rb +2 -1
- data/lib/active_admin/views/header.rb +2 -2
- data/lib/active_admin/views/index_as_blog.rb +1 -1
- data/lib/active_admin/views/index_as_grid.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +16 -16
- data/lib/active_admin/views/pages/base.rb +14 -10
- data/lib/active_admin/views/pages/index.rb +14 -13
- data/lib/active_admin/views/tabbed_navigation.rb +2 -2
- data/lib/active_admin/views/title_bar.rb +1 -1
- data/lib/activeadmin.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
- data/lib/generators/active_admin/assets/templates/active_admin.scss +2 -2
- data/lib/generators/active_admin/devise/devise_generator.rb +5 -5
- data/lib/generators/active_admin/install/install_generator.rb +14 -8
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +9 -2
- data/lib/generators/active_admin/page/page_generator.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +3 -3
- data/lib/generators/active_admin/webpacker/plugins/jquery.js +7 -0
- data/lib/generators/active_admin/webpacker/templates/active_admin.js +5 -0
- data/lib/generators/active_admin/webpacker/templates/active_admin.scss +17 -0
- data/lib/generators/active_admin/webpacker/templates/print.scss +2 -0
- data/lib/generators/active_admin/webpacker/webpacker_generator.rb +26 -0
- data/lib/ransack_ext.rb +8 -8
- metadata +20 -8
@@ -8,7 +8,7 @@
|
|
8
8
|
</div>
|
9
9
|
|
10
10
|
<div id="tidelift">
|
11
|
-
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=
|
11
|
+
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise" target="_blank">
|
12
12
|
<span class="cta">
|
13
13
|
Active Admin for enterprise available via Tidelift
|
14
14
|
</span>
|
data/docs/documentation.md
CHANGED
data/docs/index.html
CHANGED
@@ -50,7 +50,7 @@
|
|
50
50
|
</h3>
|
51
51
|
|
52
52
|
<p>
|
53
|
-
Each resource that is registered
|
53
|
+
Each resource that is registered with Active Admin becomes available as <span class="caps">JSON</span>, <span class="caps">XML</span> and <span class="caps">CSV</span> download. Customize the output to meet your requirements.
|
54
54
|
</p>
|
55
55
|
</div>
|
56
56
|
|
@@ -133,7 +133,7 @@
|
|
133
133
|
</h2>
|
134
134
|
|
135
135
|
<p>
|
136
|
-
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=
|
136
|
+
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise">
|
137
137
|
Available as part of the Tidelift Subscription
|
138
138
|
</a>
|
139
139
|
</p>
|
@@ -150,11 +150,11 @@
|
|
150
150
|
</p>
|
151
151
|
|
152
152
|
<div class="tidelift-buttons">
|
153
|
-
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral" target="_blank">
|
153
|
+
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise" target="_blank">
|
154
154
|
<span>LEARN MORE</span>
|
155
155
|
</a>
|
156
156
|
|
157
|
-
<a href="https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-activeadmin&utm_medium=referral" target="_blank">
|
157
|
+
<a href="https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise" target="_blank">
|
158
158
|
<span>REQUEST A DEMO</span>
|
159
159
|
</a>
|
160
160
|
</div>
|
@@ -202,11 +202,11 @@
|
|
202
202
|
</p>
|
203
203
|
|
204
204
|
<div class="tidelift-buttons">
|
205
|
-
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral" target="_blank">
|
205
|
+
<a href="https://tidelift.com/subscription/pkg/rubygems-activeadmin?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise" target="_blank">
|
206
206
|
<span>LEARN MORE</span>
|
207
207
|
</a>
|
208
208
|
|
209
|
-
<a href="https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-activeadmin&utm_medium=referral" target="_blank">
|
209
|
+
<a href="https://tidelift.com/subscription/request-a-demo?utm_source=rubygems-activeadmin&utm_medium=referral&utm_campaign=enterprise" target="_blank">
|
210
210
|
<span>REQUEST A DEMO</span>
|
211
211
|
</a>
|
212
212
|
</div>
|
data/lib/active_admin.rb
CHANGED
@@ -1,58 +1,58 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_support/core_ext"
|
2
|
+
require "set"
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
9
|
-
require
|
10
|
-
require
|
11
|
-
require
|
12
|
-
require
|
4
|
+
require "ransack"
|
5
|
+
require "ransack_ext"
|
6
|
+
require "kaminari"
|
7
|
+
require "formtastic"
|
8
|
+
require "formtastic_i18n"
|
9
|
+
require "inherited_resources"
|
10
|
+
require "jquery-rails"
|
11
|
+
require "sassc-rails"
|
12
|
+
require "arbre"
|
13
13
|
|
14
|
-
require
|
14
|
+
require "active_admin/helpers/i18n"
|
15
15
|
|
16
16
|
module ActiveAdmin
|
17
17
|
|
18
|
-
autoload :VERSION,
|
19
|
-
autoload :Application,
|
20
|
-
autoload :AssetRegistration,
|
21
|
-
autoload :Authorization,
|
22
|
-
autoload :AuthorizationAdapter,
|
23
|
-
autoload :Callbacks,
|
24
|
-
autoload :Component,
|
25
|
-
autoload :BaseController,
|
26
|
-
autoload :CanCanAdapter,
|
27
|
-
autoload :ControllerAction,
|
28
|
-
autoload :CSVBuilder,
|
29
|
-
autoload :Dependency,
|
30
|
-
autoload :Deprecation,
|
31
|
-
autoload :Devise,
|
32
|
-
autoload :DSL,
|
33
|
-
autoload :FormBuilder,
|
34
|
-
autoload :Inputs,
|
35
|
-
autoload :Localizers,
|
36
|
-
autoload :Menu,
|
37
|
-
autoload :MenuCollection,
|
38
|
-
autoload :MenuItem,
|
39
|
-
autoload :Namespace,
|
40
|
-
autoload :OrderClause,
|
41
|
-
autoload :Page,
|
42
|
-
autoload :PagePresenter,
|
43
|
-
autoload :PageController,
|
44
|
-
autoload :PageDSL,
|
45
|
-
autoload :PunditAdapter,
|
46
|
-
autoload :Resource,
|
47
|
-
autoload :ResourceController,
|
48
|
-
autoload :ResourceDSL,
|
49
|
-
autoload :Scope,
|
50
|
-
autoload :ScopeChain,
|
51
|
-
autoload :SidebarSection,
|
52
|
-
autoload :TableBuilder,
|
53
|
-
autoload :ViewFactory,
|
54
|
-
autoload :ViewHelpers,
|
55
|
-
autoload :Views,
|
18
|
+
autoload :VERSION, "active_admin/version"
|
19
|
+
autoload :Application, "active_admin/application"
|
20
|
+
autoload :AssetRegistration, "active_admin/asset_registration"
|
21
|
+
autoload :Authorization, "active_admin/authorization_adapter"
|
22
|
+
autoload :AuthorizationAdapter, "active_admin/authorization_adapter"
|
23
|
+
autoload :Callbacks, "active_admin/callbacks"
|
24
|
+
autoload :Component, "active_admin/component"
|
25
|
+
autoload :BaseController, "active_admin/base_controller"
|
26
|
+
autoload :CanCanAdapter, "active_admin/cancan_adapter"
|
27
|
+
autoload :ControllerAction, "active_admin/controller_action"
|
28
|
+
autoload :CSVBuilder, "active_admin/csv_builder"
|
29
|
+
autoload :Dependency, "active_admin/dependency"
|
30
|
+
autoload :Deprecation, "active_admin/deprecation"
|
31
|
+
autoload :Devise, "active_admin/devise"
|
32
|
+
autoload :DSL, "active_admin/dsl"
|
33
|
+
autoload :FormBuilder, "active_admin/form_builder"
|
34
|
+
autoload :Inputs, "active_admin/inputs"
|
35
|
+
autoload :Localizers, "active_admin/localizers"
|
36
|
+
autoload :Menu, "active_admin/menu"
|
37
|
+
autoload :MenuCollection, "active_admin/menu_collection"
|
38
|
+
autoload :MenuItem, "active_admin/menu_item"
|
39
|
+
autoload :Namespace, "active_admin/namespace"
|
40
|
+
autoload :OrderClause, "active_admin/order_clause"
|
41
|
+
autoload :Page, "active_admin/page"
|
42
|
+
autoload :PagePresenter, "active_admin/page_presenter"
|
43
|
+
autoload :PageController, "active_admin/page_controller"
|
44
|
+
autoload :PageDSL, "active_admin/page_dsl"
|
45
|
+
autoload :PunditAdapter, "active_admin/pundit_adapter"
|
46
|
+
autoload :Resource, "active_admin/resource"
|
47
|
+
autoload :ResourceController, "active_admin/resource_controller"
|
48
|
+
autoload :ResourceDSL, "active_admin/resource_dsl"
|
49
|
+
autoload :Scope, "active_admin/scope"
|
50
|
+
autoload :ScopeChain, "active_admin/helpers/scope_chain"
|
51
|
+
autoload :SidebarSection, "active_admin/sidebar_section"
|
52
|
+
autoload :TableBuilder, "active_admin/table_builder"
|
53
|
+
autoload :ViewFactory, "active_admin/view_factory"
|
54
|
+
autoload :ViewHelpers, "active_admin/view_helpers"
|
55
|
+
autoload :Views, "active_admin/views"
|
56
56
|
|
57
57
|
class << self
|
58
58
|
|
@@ -69,11 +69,11 @@ module ActiveAdmin
|
|
69
69
|
application.prepare!
|
70
70
|
end
|
71
71
|
|
72
|
-
delegate :register,
|
72
|
+
delegate :register, to: :application
|
73
73
|
delegate :register_page, to: :application
|
74
|
-
delegate :unload!,
|
75
|
-
delegate :load!,
|
76
|
-
delegate :routes,
|
74
|
+
delegate :unload!, to: :application
|
75
|
+
delegate :load!, to: :application
|
76
|
+
delegate :routes, to: :application
|
77
77
|
|
78
78
|
# A callback is triggered each time (before) Active Admin loads the configuration files.
|
79
79
|
# In development mode, this will happen whenever the user changes files. In production
|
@@ -121,13 +121,13 @@ module ActiveAdmin
|
|
121
121
|
end
|
122
122
|
|
123
123
|
# Require things that don't support autoload
|
124
|
-
require
|
125
|
-
require
|
124
|
+
require "active_admin/engine"
|
125
|
+
require "active_admin/error"
|
126
126
|
|
127
127
|
# Require internal plugins
|
128
|
-
require
|
129
|
-
require
|
128
|
+
require "active_admin/batch_actions"
|
129
|
+
require "active_admin/filters"
|
130
130
|
|
131
131
|
# Require ORM-specific plugins
|
132
|
-
require
|
133
|
-
require
|
132
|
+
require "active_admin/orm/active_record" if defined? ActiveRecord
|
133
|
+
require "active_admin/orm/mongoid" if defined? Mongoid
|
@@ -1,6 +1,6 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require "active_admin/router"
|
2
|
+
require "active_admin/application_settings"
|
3
|
+
require "active_admin/namespace_settings"
|
4
4
|
|
5
5
|
module ActiveAdmin
|
6
6
|
class Application
|
@@ -45,8 +45,8 @@ module ActiveAdmin
|
|
45
45
|
include AssetRegistration
|
46
46
|
|
47
47
|
# Event that gets triggered on load of Active Admin
|
48
|
-
BeforeLoadEvent =
|
49
|
-
AfterLoadEvent
|
48
|
+
BeforeLoadEvent = "active_admin.application.before_load".freeze
|
49
|
+
AfterLoadEvent = "active_admin.application.after_load".freeze
|
50
50
|
|
51
51
|
# Runs before the app's AA initializer
|
52
52
|
def setup!
|
@@ -112,9 +112,9 @@ module ActiveAdmin
|
|
112
112
|
def load!
|
113
113
|
unless loaded?
|
114
114
|
ActiveSupport::Notifications.publish BeforeLoadEvent, self # before_load hook
|
115
|
-
files.each { |file| load file }
|
116
|
-
namespace(default_namespace)
|
117
|
-
ActiveSupport::Notifications.publish AfterLoadEvent, self
|
115
|
+
files.each { |file| load file } # load files
|
116
|
+
namespace(default_namespace) # init AA resources
|
117
|
+
ActiveSupport::Notifications.publish AfterLoadEvent, self # after_load hook
|
118
118
|
@@loaded = true
|
119
119
|
end
|
120
120
|
end
|
@@ -125,7 +125,7 @@ module ActiveAdmin
|
|
125
125
|
|
126
126
|
# Returns ALL the files to be loaded
|
127
127
|
def files
|
128
|
-
load_paths.flatten.compact.uniq.flat_map { |path| Dir["#{path}/**/*.rb"] }
|
128
|
+
load_paths.flatten.compact.uniq.flat_map { |path| Dir["#{path}/**/*.rb"] }.sort
|
129
129
|
end
|
130
130
|
|
131
131
|
# Creates all the necessary routes for the ActiveAdmin configurations
|
@@ -164,9 +164,9 @@ module ActiveAdmin
|
|
164
164
|
private
|
165
165
|
|
166
166
|
def register_default_assets
|
167
|
-
register_stylesheet
|
168
|
-
register_stylesheet
|
169
|
-
register_javascript
|
167
|
+
register_stylesheet "active_admin.css", media: "screen"
|
168
|
+
register_stylesheet "active_admin/print.css", media: "print"
|
169
|
+
register_javascript "active_admin.js"
|
170
170
|
end
|
171
171
|
|
172
172
|
# Since app/admin is alphabetically before app/models, we have to remove it
|
@@ -176,7 +176,7 @@ module ActiveAdmin
|
|
176
176
|
# files from being loaded twice in production.
|
177
177
|
def remove_active_admin_load_paths_from_rails_autoload_and_eager_load
|
178
178
|
ActiveSupport::Dependencies.autoload_paths -= load_paths
|
179
|
-
Rails.application.config.eager_load_paths
|
179
|
+
Rails.application.config.eager_load_paths -= load_paths
|
180
180
|
end
|
181
181
|
|
182
182
|
# Hook into the Rails code reloading mechanism so that things are reloaded
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_admin/settings_node"
|
2
2
|
|
3
3
|
module ActiveAdmin
|
4
4
|
class ApplicationSettings < SettingsNode
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
# Load paths for admin configurations. Add folders to this load path
|
16
16
|
# to load up other resources for administration. External gems can
|
17
17
|
# include their paths in this load path to provide active_admin UIs
|
18
|
-
register :load_paths, [File.expand_path(
|
18
|
+
register :load_paths, [File.expand_path("app/admin", Rails.root)]
|
19
19
|
|
20
20
|
# Set default localize format for Date/Time values
|
21
21
|
register :localize_format, :long
|
@@ -34,7 +34,7 @@ module ActiveAdmin
|
|
34
34
|
:to_s ]
|
35
35
|
|
36
36
|
# To make debugging easier, by default don't stream in development
|
37
|
-
register :disable_streaming_in, [
|
37
|
+
register :disable_streaming_in, ["development"]
|
38
38
|
|
39
39
|
# Remove sensitive attributes from being displayed, made editable, or exported by default
|
40
40
|
register :filter_attributes, [:encrypted_password, :password, :password_confirmation]
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_admin/base_controller/authorization"
|
2
|
+
require "active_admin/base_controller/menu"
|
3
3
|
|
4
4
|
module ActiveAdmin
|
5
5
|
# BaseController for ActiveAdmin.
|
@@ -69,11 +69,11 @@ module ActiveAdmin
|
|
69
69
|
# 2. If we're rendering a custom action, we'll use the active_admin layout so
|
70
70
|
# that users can render any template inside Active Admin.
|
71
71
|
def determine_active_admin_layout
|
72
|
-
ACTIVE_ADMIN_ACTIONS.include?(params[:action].to_sym) ? false :
|
72
|
+
ACTIVE_ADMIN_ACTIONS.include?(params[:action].to_sym) ? false : "active_admin"
|
73
73
|
end
|
74
74
|
|
75
75
|
def active_admin_root
|
76
|
-
controller, action = active_admin_namespace.root_to.split
|
76
|
+
controller, action = active_admin_namespace.root_to.split "#"
|
77
77
|
{ controller: controller, action: action }
|
78
78
|
end
|
79
79
|
|
@@ -4,12 +4,12 @@ module ActiveAdmin
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
ACTIONS_DICTIONARY = {
|
7
|
-
index:
|
8
|
-
show:
|
9
|
-
new:
|
10
|
-
create:
|
11
|
-
edit:
|
12
|
-
update:
|
7
|
+
index: ActiveAdmin::Authorization::READ,
|
8
|
+
show: ActiveAdmin::Authorization::READ,
|
9
|
+
new: ActiveAdmin::Authorization::CREATE,
|
10
|
+
create: ActiveAdmin::Authorization::CREATE,
|
11
|
+
edit: ActiveAdmin::Authorization::UPDATE,
|
12
|
+
update: ActiveAdmin::Authorization::UPDATE,
|
13
13
|
destroy: ActiveAdmin::Authorization::DESTROY
|
14
14
|
}
|
15
15
|
|
@@ -52,9 +52,10 @@ module ActiveAdmin
|
|
52
52
|
# an ActiveAdmin::AccessDenied.
|
53
53
|
def authorize!(action, subject = nil)
|
54
54
|
unless authorized? action, subject
|
55
|
-
raise ActiveAdmin::AccessDenied.new(
|
56
|
-
|
57
|
-
|
55
|
+
raise ActiveAdmin::AccessDenied.new(
|
56
|
+
current_active_admin_user,
|
57
|
+
action,
|
58
|
+
subject)
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -112,9 +113,9 @@ module ActiveAdmin
|
|
112
113
|
redirect_backwards_or_to_root
|
113
114
|
end
|
114
115
|
|
115
|
-
format.csv
|
116
|
-
format.json { render json: { error: error },
|
117
|
-
format.xml
|
116
|
+
format.csv { render body: error, status: :unauthorized }
|
117
|
+
format.json { render json: { error: error }, status: :unauthorized }
|
118
|
+
format.xml { render xml: "<error>#{error}</error>", status: :unauthorized }
|
118
119
|
end
|
119
120
|
end
|
120
121
|
|
@@ -5,10 +5,10 @@ module ActiveAdmin
|
|
5
5
|
# Controller action that is called when submitting the batch action form
|
6
6
|
def batch_action
|
7
7
|
if action_present?
|
8
|
-
selection
|
9
|
-
inputs
|
8
|
+
selection = params[:collection_selection] || []
|
9
|
+
inputs = JSON.parse params[:batch_action_inputs] || "{}"
|
10
10
|
valid_keys = MethodOrProcHelper.render_in_context(self, current_batch_action.inputs).try(:keys)
|
11
|
-
inputs
|
11
|
+
inputs = inputs.with_indifferent_access.slice *valid_keys
|
12
12
|
instance_exec selection, inputs, ¤t_batch_action.block
|
13
13
|
else
|
14
14
|
raise "Couldn't find batch action \"#{params[:batch_action]}\""
|
@@ -57,21 +57,22 @@ module ActiveAdmin
|
|
57
57
|
def add_default_batch_action
|
58
58
|
destroy_options = {
|
59
59
|
priority: 100,
|
60
|
-
confirm: proc { I18n.t(
|
61
|
-
if: proc { controller.action_methods.include?(
|
60
|
+
confirm: proc { I18n.t("active_admin.batch_actions.delete_confirmation", plural_model: active_admin_config.plural_resource_label.downcase) },
|
61
|
+
if: proc { controller.action_methods.include?("destroy") && authorized?(ActiveAdmin::Auth::DESTROY, active_admin_config.resource_class) }
|
62
62
|
}
|
63
63
|
|
64
|
-
add_batch_action :destroy, proc { I18n.t(
|
64
|
+
add_batch_action :destroy, proc { I18n.t("active_admin.delete") }, destroy_options do |selected_ids|
|
65
65
|
batch_action_collection.find(selected_ids).each do |record|
|
66
66
|
authorize! ActiveAdmin::Auth::DESTROY, record
|
67
67
|
destroy_resource(record)
|
68
68
|
end
|
69
69
|
|
70
70
|
redirect_to active_admin_config.route_collection_path(params),
|
71
|
-
notice: I18n.t(
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
notice: I18n.t(
|
72
|
+
"active_admin.batch_actions.succesfully_destroyed",
|
73
|
+
count: selected_ids.count,
|
74
|
+
model: active_admin_config.resource_label.downcase,
|
75
|
+
plural_model: active_admin_config.plural_resource_label(count: selected_ids.count).downcase)
|
75
76
|
end
|
76
77
|
end
|
77
78
|
|
@@ -84,7 +85,7 @@ module ActiveAdmin
|
|
84
85
|
|
85
86
|
attr_reader :block, :title, :sym
|
86
87
|
|
87
|
-
DEFAULT_CONFIRM_MESSAGE = proc { I18n.t
|
88
|
+
DEFAULT_CONFIRM_MESSAGE = proc { I18n.t "active_admin.batch_actions.default_confirmation" }
|
88
89
|
|
89
90
|
# Create a Batch Action
|
90
91
|
#
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_admin/component"
|
2
2
|
|
3
3
|
module ActiveAdmin
|
4
4
|
module BatchActions
|
@@ -16,7 +16,7 @@ module ActiveAdmin
|
|
16
16
|
# batch_action => name of the specific action called
|
17
17
|
# batch_action_inputs => a JSON string of any requested confirmation values
|
18
18
|
text_node form_tag active_admin_config.route_batch_action_path(params, url_options), id: options[:id]
|
19
|
-
input name: :batch_action,
|
19
|
+
input name: :batch_action, id: :batch_action, type: :hidden
|
20
20
|
input name: :batch_action_inputs, id: :batch_action_inputs, type: :hidden
|
21
21
|
|
22
22
|
super(options)
|
@@ -30,7 +30,7 @@ module ActiveAdmin
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def closing_form_tag
|
33
|
-
|
33
|
+
"</form>".html_safe
|
34
34
|
end
|
35
35
|
|
36
36
|
end
|