activeadmin 2.7.0 → 2.8.0
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 +54 -8
- data/CONTRIBUTING.md +1 -17
- data/app/assets/javascripts/active_admin/base.js +13 -15
- data/app/assets/stylesheets/active_admin/components/_comments.scss +2 -2
- 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 +2 -2
- data/config/locales/ar.yml +6 -6
- data/config/locales/es-MX.yml +2 -1
- data/config/locales/es.yml +2 -2
- data/config/locales/it.yml +18 -0
- data/config/locales/ja.yml +3 -3
- data/docs/11-decorators.md +16 -5
- data/docs/Gemfile.lock +36 -26
- data/lib/active_admin.rb +43 -43
- data/lib/active_admin/application.rb +6 -6
- data/lib/active_admin/authorization_adapter.rb +3 -3
- data/lib/active_admin/base_controller/authorization.rb +9 -9
- data/lib/active_admin/batch_actions/controller.rb +3 -3
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +1 -1
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +5 -5
- data/lib/active_admin/collection_decorator.rb +31 -0
- data/lib/active_admin/csv_builder.rb +4 -4
- data/lib/active_admin/dependency.rb +7 -7
- data/lib/active_admin/filters.rb +1 -1
- data/lib/active_admin/filters/forms.rb +3 -3
- data/lib/active_admin/filters/resource_extension.rb +1 -1
- data/lib/active_admin/form_builder.rb +5 -5
- data/lib/active_admin/helpers/optional_display.rb +2 -2
- data/lib/active_admin/inputs/filters/base/search_method_select.rb +2 -2
- data/lib/active_admin/menu_item.rb +7 -7
- data/lib/active_admin/namespace.rb +7 -7
- data/lib/active_admin/orm/active_record/comments.rb +11 -11
- data/lib/active_admin/orm/active_record/comments/comment.rb +3 -3
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +3 -3
- data/lib/active_admin/pundit_adapter.rb +4 -4
- data/lib/active_admin/resource/action_items.rb +1 -1
- data/lib/active_admin/resource/menu.rb +4 -4
- data/lib/active_admin/resource/naming.rb +3 -3
- data/lib/active_admin/resource/routes.rb +5 -5
- data/lib/active_admin/resource/scope_to.rb +7 -7
- data/lib/active_admin/resource_controller.rb +4 -3
- data/lib/active_admin/resource_controller/data_access.rb +1 -1
- data/lib/active_admin/resource_controller/decorators.rb +5 -25
- data/lib/active_admin/resource_dsl.rb +5 -5
- data/lib/active_admin/scope.rb +5 -5
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +16 -16
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +1 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -3
- data/lib/active_admin/view_helpers/fields_for.rb +1 -1
- data/lib/active_admin/views/components/attributes_table.rb +2 -2
- data/lib/active_admin/views/components/dropdown_menu.rb +2 -2
- data/lib/active_admin/views/components/index_list.rb +1 -1
- data/lib/active_admin/views/components/menu_item.rb +1 -1
- data/lib/active_admin/views/components/paginated_collection.rb +14 -14
- data/lib/active_admin/views/components/table_for.rb +10 -10
- data/lib/active_admin/views/components/tabs.rb +1 -1
- data/lib/active_admin/views/index_as_table.rb +6 -6
- data/lib/active_admin/views/pages/base.rb +1 -1
- data/lib/active_admin/views/pages/index.rb +8 -8
- data/lib/generators/active_admin/assets/templates/active_admin.scss +2 -2
- data/lib/generators/active_admin/devise/devise_generator.rb +4 -4
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +2 -2
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- data/lib/generators/active_admin/webpacker/templates/active_admin.scss +2 -2
- metadata +15 -8
@@ -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]}\""
|
@@ -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)
|
@@ -31,17 +31,17 @@ module ActiveAdmin
|
|
31
31
|
confirmation_text = render_or_call_method_or_proc_on(self, batch_action.confirm)
|
32
32
|
|
33
33
|
options = {
|
34
|
-
:
|
35
|
-
"data-action"
|
36
|
-
"data-confirm"
|
37
|
-
"data-inputs"
|
34
|
+
class: "batch_action",
|
35
|
+
"data-action": batch_action.sym,
|
36
|
+
"data-confirm": confirmation_text,
|
37
|
+
"data-inputs": render_in_context(self, batch_action.inputs).to_json
|
38
38
|
}
|
39
39
|
|
40
40
|
default_title = render_or_call_method_or_proc_on(self, batch_action.title)
|
41
41
|
title = I18n.t("active_admin.batch_actions.labels.#{batch_action.sym}", default: default_title)
|
42
42
|
label = I18n.t("active_admin.batch_actions.action_label", title: title)
|
43
43
|
|
44
|
-
item label, "#", options
|
44
|
+
item label, "#", **options
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ActiveAdmin
|
2
|
+
# This class decorates a collection of objects delegating
|
3
|
+
# mehods to behave like an Array. It's used to decouple ActiveAdmin
|
4
|
+
# from Draper and thus being able to use PORO decorators as well.
|
5
|
+
#
|
6
|
+
# It's implementation is heavily based on the Draper::CollectionDecorator
|
7
|
+
# https://github.com/drapergem/draper/blob/aaa06bd2f1e219838b241a5534e7ca513edd1fe2/lib/draper/collection_decorator.rb
|
8
|
+
class CollectionDecorator
|
9
|
+
# @return the collection being decorated.
|
10
|
+
attr_reader :object
|
11
|
+
|
12
|
+
# @return [Class] the decorator class used to decorate each item, as set by {#initialize}.
|
13
|
+
attr_reader :decorator_class
|
14
|
+
|
15
|
+
array_methods = Array.instance_methods - Object.instance_methods
|
16
|
+
delegate :==, :as_json, *array_methods, to: :decorated_collection
|
17
|
+
|
18
|
+
def initialize(object, with:)
|
19
|
+
@object = object
|
20
|
+
@decorator_class = with
|
21
|
+
end
|
22
|
+
|
23
|
+
class << self
|
24
|
+
alias_method :decorate, :new
|
25
|
+
end
|
26
|
+
|
27
|
+
def decorated_collection
|
28
|
+
@decorated_collection ||= object.map { |item| decorator_class.new(item) }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -42,11 +42,11 @@ module ActiveAdmin
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def build(controller, csv)
|
45
|
-
@collection
|
46
|
-
columns
|
47
|
-
bom
|
45
|
+
@collection = controller.send :find_collection, except: :pagination
|
46
|
+
columns = exec_columns controller.view_context
|
47
|
+
bom = options.delete :byte_order_mark
|
48
48
|
column_names = options.delete(:column_names) { true }
|
49
|
-
csv_options
|
49
|
+
csv_options = options.except :encoding_options, :humanize_name
|
50
50
|
|
51
51
|
csv << bom if bom
|
52
52
|
|
@@ -6,22 +6,22 @@ module ActiveAdmin
|
|
6
6
|
|
7
7
|
# Provides a clean interface to check for gem dependencies at runtime.
|
8
8
|
#
|
9
|
-
# ActiveAdmin::Dependency.
|
10
|
-
# => #<ActiveAdmin::Dependency::Matcher for
|
9
|
+
# ActiveAdmin::Dependency.rails
|
10
|
+
# => #<ActiveAdmin::Dependency::Matcher for rails 6.0.3.2>
|
11
11
|
#
|
12
|
-
# ActiveAdmin::Dependency.
|
12
|
+
# ActiveAdmin::Dependency.rails?
|
13
13
|
# => true
|
14
14
|
#
|
15
|
-
# ActiveAdmin::Dependency.
|
15
|
+
# ActiveAdmin::Dependency.rails? '>= 6.1'
|
16
16
|
# => false
|
17
17
|
#
|
18
|
-
# ActiveAdmin::Dependency.
|
18
|
+
# ActiveAdmin::Dependency.rails? '= 6.0.3.2'
|
19
19
|
# => true
|
20
20
|
#
|
21
|
-
# ActiveAdmin::Dependency.
|
21
|
+
# ActiveAdmin::Dependency.rails? '~> 6.0.3'
|
22
22
|
# => true
|
23
23
|
#
|
24
|
-
# ActiveAdmin::Dependency.rails? '>=
|
24
|
+
# ActiveAdmin::Dependency.rails? '>= 6.0.3', '<= 6.1.0'
|
25
25
|
# => true
|
26
26
|
#
|
27
27
|
# ActiveAdmin::Dependency.rails! '5'
|
data/lib/active_admin/filters.rb
CHANGED
@@ -7,5 +7,5 @@ require 'active_admin/filters/active_sidebar'
|
|
7
7
|
|
8
8
|
# Add our Extensions
|
9
9
|
ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
|
10
|
-
ActiveAdmin::Resource.send
|
10
|
+
ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
|
11
11
|
ActiveAdmin::ViewHelpers.send :include, ActiveAdmin::Filters::ViewHelper
|
@@ -51,12 +51,12 @@ module ActiveAdmin
|
|
51
51
|
html: { class: 'filter_form' } }
|
52
52
|
required = { html: { method: :get },
|
53
53
|
as: :q }
|
54
|
-
options
|
54
|
+
options = defaults.deep_merge(options).deep_merge(required)
|
55
55
|
|
56
56
|
form_for search, options do |f|
|
57
57
|
filters.each do |attribute, opts|
|
58
|
-
next if opts.key?(:if)
|
59
|
-
next if opts.key?(:unless) &&
|
58
|
+
next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
|
59
|
+
next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
|
60
60
|
|
61
61
|
filter_opts = opts.except(:if, :unless)
|
62
62
|
filter_opts[:input_html] = instance_exec(&filter_opts[:input_html]) if filter_opts[:input_html].is_a?(Proc)
|
@@ -165,7 +165,7 @@ module ActiveAdmin
|
|
165
165
|
|
166
166
|
def filters_sidebar_section
|
167
167
|
ActiveAdmin::SidebarSection.new :filters, only: :index, if: -> { active_admin_config.filters.any? } do
|
168
|
-
active_admin_filters_form_for assigns[:search], active_admin_config.filters
|
168
|
+
active_admin_filters_form_for assigns[:search], **active_admin_config.filters
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -69,7 +69,7 @@ module ActiveAdmin
|
|
69
69
|
def extract_custom_settings!(options)
|
70
70
|
@heading = options.key?(:heading) ? options.delete(:heading) : default_heading
|
71
71
|
@sortable_column = options.delete(:sortable)
|
72
|
-
@sortable_start
|
72
|
+
@sortable_start = options.delete(:sortable_start) || 0
|
73
73
|
@new_record = options.key?(:new_record) ? options.delete(:new_record) : true
|
74
74
|
@destroy_option = options.delete(:allow_destroy)
|
75
75
|
options
|
@@ -111,8 +111,8 @@ module ActiveAdmin
|
|
111
111
|
end
|
112
112
|
elsif allow_destroy?(form_builder.object)
|
113
113
|
form_builder.input(:_destroy, as: :boolean,
|
114
|
-
|
115
|
-
|
114
|
+
wrapper_html: { class: 'has_many_delete' },
|
115
|
+
label: I18n.t('active_admin.has_many_delete'))
|
116
116
|
end
|
117
117
|
|
118
118
|
if sortable_column
|
@@ -156,8 +156,8 @@ module ActiveAdmin
|
|
156
156
|
|
157
157
|
# Capture the ADD JS
|
158
158
|
def js_for_has_many(class_string, &form_block)
|
159
|
-
assoc_name
|
160
|
-
placeholder
|
159
|
+
assoc_name = assoc_klass.model_name
|
160
|
+
placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.gsub(/\//, '_')}_RECORD"
|
161
161
|
opts = {
|
162
162
|
for: [assoc, assoc_klass.new],
|
163
163
|
class: class_string,
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
|
16
16
|
module OptionalDisplay
|
17
17
|
def display_on?(action, render_context = self)
|
18
|
-
return false if @options[:only]
|
18
|
+
return false if @options[:only] && !@options[:only].include?(action.to_sym)
|
19
19
|
return false if @options[:except] && @options[:except].include?(action.to_sym)
|
20
20
|
|
21
21
|
case condition = @options[:if]
|
@@ -31,7 +31,7 @@ module ActiveAdmin
|
|
31
31
|
private
|
32
32
|
|
33
33
|
def normalize_display_options!
|
34
|
-
@options[:only]
|
34
|
+
@options[:only] = Array(@options[:only]) if @options[:only]
|
35
35
|
@options[:except] = Array(@options[:except]) if @options[:except]
|
36
36
|
end
|
37
37
|
end
|
@@ -37,9 +37,9 @@ module ActiveAdmin
|
|
37
37
|
|
38
38
|
def to_html
|
39
39
|
input_wrapping do
|
40
|
-
label_html
|
40
|
+
label_html << # your label
|
41
41
|
select_html << # the dropdown that holds the available search methods
|
42
|
-
input_html
|
42
|
+
input_html # your input field
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -45,13 +45,13 @@ module ActiveAdmin
|
|
45
45
|
#
|
46
46
|
def initialize(options = {})
|
47
47
|
super() # MenuNode
|
48
|
-
@label
|
49
|
-
@dirty_id
|
50
|
-
@url
|
51
|
-
@priority
|
52
|
-
@html_options
|
53
|
-
@should_display = options[:if]
|
54
|
-
@parent
|
48
|
+
@label = options[:label]
|
49
|
+
@dirty_id = options[:id] || options[:label]
|
50
|
+
@url = options[:url] || '#'
|
51
|
+
@priority = options[:priority] || 10
|
52
|
+
@html_options = options[:html_options] || {}
|
53
|
+
@should_display = options[:if] || proc { true }
|
54
|
+
@parent = options[:parent]
|
55
55
|
|
56
56
|
yield(self) if block_given? # Builder style syntax
|
57
57
|
end
|
@@ -150,9 +150,9 @@ module ActiveAdmin
|
|
150
150
|
if logout_link_path
|
151
151
|
html_options = html_options.reverse_merge(method: logout_link_method || :get)
|
152
152
|
menu.add id: 'logout', priority: priority, html_options: html_options,
|
153
|
-
|
154
|
-
|
155
|
-
|
153
|
+
label: -> { I18n.t 'active_admin.logout' },
|
154
|
+
url: -> { render_or_call_method_or_proc_on self, active_admin_namespace.logout_link_path },
|
155
|
+
if: :current_active_admin_user?
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -165,9 +165,9 @@ module ActiveAdmin
|
|
165
165
|
def add_current_user_to_menu(menu, priority = 10, html_options = {})
|
166
166
|
if current_user_method
|
167
167
|
menu.add id: 'current_user', priority: priority, html_options: html_options,
|
168
|
-
|
169
|
-
|
170
|
-
|
168
|
+
label: -> { display_name current_active_admin_user },
|
169
|
+
url: -> { auto_url_for(current_active_admin_user) },
|
170
|
+
if: :current_active_admin_user?
|
171
171
|
end
|
172
172
|
end
|
173
173
|
|
@@ -212,7 +212,7 @@ module ActiveAdmin
|
|
212
212
|
def unload_resources!
|
213
213
|
resources.each do |resource|
|
214
214
|
parent = (module_name || 'Object').constantize
|
215
|
-
name
|
215
|
+
name = resource.controller_name.split('::').last
|
216
216
|
parent.send(:remove_const, name) if parent.const_defined?(name, false)
|
217
217
|
|
218
218
|
# Remove circular references
|
@@ -4,14 +4,14 @@ require 'active_admin/orm/active_record/comments/namespace_helper'
|
|
4
4
|
require 'active_admin/orm/active_record/comments/resource_helper'
|
5
5
|
|
6
6
|
# Add the comments configuration
|
7
|
-
ActiveAdmin::Application.inheritable_setting :comments,
|
7
|
+
ActiveAdmin::Application.inheritable_setting :comments, true
|
8
8
|
ActiveAdmin::Application.inheritable_setting :comments_registration_name, 'Comment'
|
9
|
-
ActiveAdmin::Application.inheritable_setting :comments_order,
|
10
|
-
ActiveAdmin::Application.inheritable_setting :comments_menu,
|
9
|
+
ActiveAdmin::Application.inheritable_setting :comments_order, "created_at ASC"
|
10
|
+
ActiveAdmin::Application.inheritable_setting :comments_menu, {}
|
11
11
|
|
12
12
|
# Insert helper modules
|
13
13
|
ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
|
14
|
-
ActiveAdmin::Resource.send
|
14
|
+
ActiveAdmin::Resource.send :include, ActiveAdmin::Comments::ResourceHelper
|
15
15
|
ActiveAdmin.application.view_factory.show_page.send :include, ActiveAdmin::Comments::ShowPageHelper
|
16
16
|
|
17
17
|
# Load the model as soon as it's referenced. By that point, Rails & Kaminari will be ready
|
@@ -36,7 +36,7 @@ ActiveAdmin.after_load do |app|
|
|
36
36
|
|
37
37
|
menu namespace.comments ? namespace.comments_menu : false
|
38
38
|
|
39
|
-
config.comments
|
39
|
+
config.comments = false # Don't allow comments on comments
|
40
40
|
config.batch_actions = false # The default destroy batch action isn't showing up anyway...
|
41
41
|
|
42
42
|
scope :all, show_count: false
|
@@ -51,7 +51,7 @@ ActiveAdmin.after_load do |app|
|
|
51
51
|
# Store the author and namespace
|
52
52
|
before_save do |comment|
|
53
53
|
comment.namespace = active_admin_config.namespace.name
|
54
|
-
comment.author
|
54
|
+
comment.author = current_active_admin_user
|
55
55
|
end
|
56
56
|
|
57
57
|
controller do
|
@@ -89,11 +89,11 @@ ActiveAdmin.after_load do |app|
|
|
89
89
|
|
90
90
|
index do
|
91
91
|
column I18n.t('active_admin.comments.resource_type'), :resource_type
|
92
|
-
column I18n.t('active_admin.comments.author_type'),
|
93
|
-
column I18n.t('active_admin.comments.resource'),
|
94
|
-
column I18n.t('active_admin.comments.author'),
|
95
|
-
column I18n.t('active_admin.comments.body'),
|
96
|
-
column I18n.t('active_admin.comments.created_at'),
|
92
|
+
column I18n.t('active_admin.comments.author_type'), :author_type
|
93
|
+
column I18n.t('active_admin.comments.resource'), :resource
|
94
|
+
column I18n.t('active_admin.comments.author'), :author
|
95
|
+
column I18n.t('active_admin.comments.body'), :body
|
96
|
+
column I18n.t('active_admin.comments.created_at'), :created_at
|
97
97
|
actions
|
98
98
|
end
|
99
99
|
end
|
@@ -4,7 +4,7 @@ module ActiveAdmin
|
|
4
4
|
self.table_name = "#{table_name_prefix}active_admin_comments#{table_name_suffix}"
|
5
5
|
|
6
6
|
belongs_to :resource, polymorphic: true, optional: true
|
7
|
-
belongs_to :author,
|
7
|
+
belongs_to :author, polymorphic: true
|
8
8
|
|
9
9
|
validates_presence_of :body, :namespace, :resource
|
10
10
|
|
@@ -18,8 +18,8 @@ module ActiveAdmin
|
|
18
18
|
def self.find_for_resource_in_namespace(resource, namespace)
|
19
19
|
where(
|
20
20
|
resource_type: resource_type(resource),
|
21
|
-
resource_id:
|
22
|
-
namespace:
|
21
|
+
resource_id: resource.id,
|
22
|
+
namespace: namespace.to_s
|
23
23
|
).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order)
|
24
24
|
end
|
25
25
|
|
@@ -80,9 +80,9 @@ module ActiveAdmin
|
|
80
80
|
def build_comment_form
|
81
81
|
active_admin_form_for(ActiveAdmin::Comment.new, url: comment_form_url) do |f|
|
82
82
|
f.inputs do
|
83
|
-
f.input :resource_type, as: :hidden,
|
84
|
-
f.input :resource_id,
|
85
|
-
f.input :body,
|
83
|
+
f.input :resource_type, as: :hidden, input_html: { value: ActiveAdmin::Comment.resource_type(parent.resource) }
|
84
|
+
f.input :resource_id, as: :hidden, input_html: { value: parent.resource.id }
|
85
|
+
f.input :body, label: false, input_html: { size: '80x8' }
|
86
86
|
end
|
87
87
|
f.actions do
|
88
88
|
f.action :submit, label: I18n.t('active_admin.comments.add')
|
@@ -31,7 +31,7 @@ module ActiveAdmin
|
|
31
31
|
|
32
32
|
def retrieve_policy(subject)
|
33
33
|
case subject
|
34
|
-
when nil
|
34
|
+
when nil then Pundit.policy!(user, namespace(resource))
|
35
35
|
when Class then Pundit.policy!(user, namespace(subject.new))
|
36
36
|
else Pundit.policy!(user, namespace(subject))
|
37
37
|
end
|
@@ -46,9 +46,9 @@ module ActiveAdmin
|
|
46
46
|
def format_action(action, subject)
|
47
47
|
# https://github.com/varvet/pundit/blob/master/lib/generators/pundit/install/templates/application_policy.rb
|
48
48
|
case action
|
49
|
-
when Auth::CREATE
|
50
|
-
when Auth::UPDATE
|
51
|
-
when Auth::READ
|
49
|
+
when Auth::CREATE then :create?
|
50
|
+
when Auth::UPDATE then :update?
|
51
|
+
when Auth::READ then subject.is_a?(Class) ? :index? : :show?
|
52
52
|
when Auth::DESTROY then subject.is_a?(Class) ? :destroy_all? : :destroy?
|
53
53
|
else "#{action}?"
|
54
54
|
end
|
@@ -87,7 +87,7 @@ module ActiveAdmin
|
|
87
87
|
if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
|
88
88
|
localizer = ActiveAdmin::Localizers.resource(active_admin_config)
|
89
89
|
link_to localizer.t(:delete_model), resource_path(resource), method: :delete,
|
90
|
-
|
90
|
+
data: { confirm: localizer.t(:delete_confirmation) }
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
@@ -7,12 +7,12 @@ module ActiveAdmin
|
|
7
7
|
# To disable this menu item, call `menu(false)` from the DSL
|
8
8
|
def menu_item_options=(options)
|
9
9
|
if options == false
|
10
|
-
@include_in_menu
|
10
|
+
@include_in_menu = false
|
11
11
|
@menu_item_options = {}
|
12
12
|
else
|
13
13
|
@include_in_menu = true
|
14
14
|
@navigation_menu_name = options[:menu_name]
|
15
|
-
@menu_item_options
|
15
|
+
@menu_item_options = default_menu_options.merge options
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -27,8 +27,8 @@ module ActiveAdmin
|
|
27
27
|
{
|
28
28
|
id: resource_name.plural,
|
29
29
|
label: proc { resource.plural_resource_label },
|
30
|
-
url:
|
31
|
-
if:
|
30
|
+
url: proc { resource.route_collection_path(params, url_options) },
|
31
|
+
if: proc { authorized?(Auth::READ, menu_resource_class) }
|
32
32
|
}
|
33
33
|
end
|
34
34
|
|
@@ -17,13 +17,13 @@ module ActiveAdmin
|
|
17
17
|
# Returns the name to call this resource such as "Bank Account"
|
18
18
|
def resource_label
|
19
19
|
resource_name.translate count: 1,
|
20
|
-
|
20
|
+
default: resource_name.to_s.gsub('::', ' ').titleize
|
21
21
|
end
|
22
22
|
|
23
23
|
# Returns the plural version of this resource such as "Bank Accounts"
|
24
24
|
def plural_resource_label(options = {})
|
25
|
-
defaults = { count:
|
26
|
-
|
25
|
+
defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,
|
26
|
+
default: resource_label.pluralize.titleize }
|
27
27
|
resource_name.translate defaults.merge options
|
28
28
|
end
|
29
29
|
|
@@ -98,13 +98,13 @@ module ActiveAdmin
|
|
98
98
|
suffix = options[:suffix] || "path"
|
99
99
|
route = []
|
100
100
|
|
101
|
-
route << options[:action]
|
102
|
-
route << resource.route_prefix
|
101
|
+
route << options[:action] # "batch_action", "edit" or "new"
|
102
|
+
route << resource.route_prefix # "admin"
|
103
103
|
route << belongs_to_name if nested? # "category"
|
104
|
-
route << resource_path_name
|
105
|
-
route << suffix
|
104
|
+
route << resource_path_name # "posts" or "post"
|
105
|
+
route << suffix # "path" or "index path"
|
106
106
|
|
107
|
-
route.compact.join('_').to_sym
|
107
|
+
route.compact.join('_').to_sym # :admin_category_posts_path
|
108
108
|
end
|
109
109
|
|
110
110
|
# @return params to pass to instance path
|