activeadmin 2.6.0 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +90 -7
- data/CONTRIBUTING.md +5 -33
- data/README.md +1 -1
- data/app/assets/javascripts/active_admin/base.js +13 -15
- 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/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 +2 -2
- 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/Gemfile.lock +42 -31
- data/docs/_includes/top-menu.html +1 -1
- data/docs/documentation.md +1 -1
- data/docs/index.html +6 -6
- 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 +11 -7
- data/lib/active_admin/dependency.rb +7 -7
- data/lib/active_admin/filters/forms.rb +3 -3
- data/lib/active_admin/filters/resource_extension.rb +1 -1
- data/lib/active_admin/filters.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/localizers/resource_localizer.rb +1 -1
- data/lib/active_admin/menu.rb +5 -2
- data/lib/active_admin/menu_item.rb +7 -7
- data/lib/active_admin/namespace.rb +7 -7
- data/lib/active_admin/namespace_settings.rb +3 -0
- 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/orm/active_record/comments.rb +11 -11
- 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 +4 -4
- 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/data_access.rb +1 -1
- data/lib/active_admin/resource_controller/decorators.rb +5 -25
- data/lib/active_admin/resource_controller.rb +4 -3
- 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/scopes.rb +2 -0
- data/lib/active_admin/views/components/table_for.rb +11 -11
- 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 +4 -2
- data/lib/active_admin/views/pages/index.rb +8 -8
- data/lib/active_admin.rb +43 -43
- 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/install_generator.rb +7 -1
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +9 -2
- data/lib/generators/active_admin/resource/resource_generator.rb +1 -1
- 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
- metadata +20 -8
|
@@ -183,16 +183,16 @@ module ActiveAdmin
|
|
|
183
183
|
# == Before / After Destroy
|
|
184
184
|
# Called before and after the object is destroyed from the database.
|
|
185
185
|
#
|
|
186
|
-
delegate :before_build,
|
|
187
|
-
delegate :before_create,
|
|
188
|
-
delegate :before_update,
|
|
189
|
-
delegate :before_save,
|
|
186
|
+
delegate :before_build, :after_build, to: :controller
|
|
187
|
+
delegate :before_create, :after_create, to: :controller
|
|
188
|
+
delegate :before_update, :after_update, to: :controller
|
|
189
|
+
delegate :before_save, :after_save, to: :controller
|
|
190
190
|
delegate :before_destroy, :after_destroy, to: :controller
|
|
191
191
|
|
|
192
192
|
# This code defines both *_filter and *_action for Rails 5.0 and *_action for Rails >= 5.1
|
|
193
193
|
phases = [
|
|
194
194
|
:before, :skip_before,
|
|
195
|
-
:after,
|
|
195
|
+
:after, :skip_after,
|
|
196
196
|
:around, :skip
|
|
197
197
|
]
|
|
198
198
|
keywords = if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1
|
data/lib/active_admin/scope.rb
CHANGED
|
@@ -45,11 +45,11 @@ module ActiveAdmin
|
|
|
45
45
|
@scope_block = block
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
@localizer
|
|
49
|
-
@show_count
|
|
50
|
-
@display_if_block = options[:if]
|
|
51
|
-
@default_block
|
|
52
|
-
@group
|
|
48
|
+
@localizer = options[:localizer]
|
|
49
|
+
@show_count = options.fetch(:show_count, true)
|
|
50
|
+
@display_if_block = options[:if] || proc { true }
|
|
51
|
+
@default_block = options[:default] || proc { false }
|
|
52
|
+
@group = options[:group].try(:to_sym)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def name
|
data/lib/active_admin/version.rb
CHANGED
|
@@ -4,24 +4,24 @@ module ActiveAdmin
|
|
|
4
4
|
class ViewFactory < AbstractViewFactory
|
|
5
5
|
|
|
6
6
|
# Register Helper Renderers
|
|
7
|
-
register
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
register global_navigation: ActiveAdmin::Views::TabbedNavigation,
|
|
8
|
+
utility_navigation: ActiveAdmin::Views::TabbedNavigation,
|
|
9
|
+
site_title: ActiveAdmin::Views::SiteTitle,
|
|
10
|
+
unsupported_browser: ActiveAdmin::Views::UnsupportedBrowser,
|
|
11
|
+
action_items: ActiveAdmin::Views::ActionItems,
|
|
12
|
+
title_bar: ActiveAdmin::Views::TitleBar,
|
|
13
|
+
header: ActiveAdmin::Views::Header,
|
|
14
|
+
footer: ActiveAdmin::Views::Footer,
|
|
15
|
+
index_scopes: ActiveAdmin::Views::Scopes,
|
|
16
|
+
blank_slate: ActiveAdmin::Views::BlankSlate
|
|
17
17
|
|
|
18
18
|
# Register All The Pages
|
|
19
|
-
register
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
19
|
+
register index_page: ActiveAdmin::Views::Pages::Index,
|
|
20
|
+
show_page: ActiveAdmin::Views::Pages::Show,
|
|
21
|
+
new_page: ActiveAdmin::Views::Pages::Form,
|
|
22
|
+
edit_page: ActiveAdmin::Views::Pages::Form,
|
|
23
|
+
layout: ActiveAdmin::Views::Pages::Layout,
|
|
24
|
+
page: ActiveAdmin::Views::Pages::Page
|
|
25
25
|
|
|
26
26
|
end
|
|
27
27
|
end
|
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
|
15
15
|
if part =~ /\A(\d+|[a-f0-9]{24}|(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}))\z/ && parts[index - 1]
|
|
16
16
|
parent = active_admin_config.belongs_to_config.try :target
|
|
17
17
|
config = parent && parent.resource_name.route_key == parts[index - 1] ? parent : active_admin_config
|
|
18
|
-
name
|
|
18
|
+
name = display_name config.find_resource part
|
|
19
19
|
end
|
|
20
20
|
name ||= I18n.t "activerecord.models.#{part.singularize}", count: ::ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT, default: part.titlecase
|
|
21
21
|
|
|
@@ -5,7 +5,7 @@ module ActiveAdmin
|
|
|
5
5
|
DISPLAY_NAME_FALLBACK = -> {
|
|
6
6
|
name = ""
|
|
7
7
|
klass = self.class
|
|
8
|
-
name << klass.model_name.human
|
|
8
|
+
name << klass.model_name.human if klass.respond_to? :model_name
|
|
9
9
|
name << " ##{send(klass.primary_key)}" if klass.respond_to? :primary_key
|
|
10
10
|
name.present? ? name : to_s
|
|
11
11
|
}
|
|
@@ -26,7 +26,7 @@ module ActiveAdmin
|
|
|
26
26
|
@@display_name_methods_cache ||= {}
|
|
27
27
|
@@display_name_methods_cache[resource.class] ||= begin
|
|
28
28
|
methods = active_admin_application.display_name_methods - association_methods_for(resource)
|
|
29
|
-
method
|
|
29
|
+
method = methods.detect { |method| resource.respond_to? method }
|
|
30
30
|
|
|
31
31
|
if method != :to_s || resource.method(method).source_location
|
|
32
32
|
method
|
|
@@ -74,7 +74,7 @@ module ActiveAdmin
|
|
|
74
74
|
format_collection(object)
|
|
75
75
|
else
|
|
76
76
|
if defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Base) ||
|
|
77
|
-
defined?(::Mongoid)
|
|
77
|
+
defined?(::Mongoid) && object.class.include?(Mongoid::Document)
|
|
78
78
|
auto_link object
|
|
79
79
|
elsif defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Relation)
|
|
80
80
|
format_collection(object)
|
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
|
15
15
|
#
|
|
16
16
|
def fields_for_params(params, options = {})
|
|
17
17
|
namespace = options[:namespace]
|
|
18
|
-
except
|
|
18
|
+
except = Array.wrap(options[:except]).map &:to_s
|
|
19
19
|
|
|
20
20
|
params.flat_map do |k, v|
|
|
21
21
|
next if namespace.nil? && %w(controller action commit utf8).include?(k.to_s)
|
|
@@ -5,7 +5,7 @@ module ActiveAdmin
|
|
|
5
5
|
builder_method :attributes_table_for
|
|
6
6
|
|
|
7
7
|
def build(obj, *attrs)
|
|
8
|
-
@collection
|
|
8
|
+
@collection = Array.wrap(obj)
|
|
9
9
|
@resource_class = @collection.first.class
|
|
10
10
|
options = {}
|
|
11
11
|
options[:for] = @collection.first if single_record?
|
|
@@ -20,7 +20,7 @@ module ActiveAdmin
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def row(*args, &block)
|
|
23
|
-
title
|
|
23
|
+
title = args[0]
|
|
24
24
|
options = args.extract_options!
|
|
25
25
|
classes = [:row]
|
|
26
26
|
if options[:class]
|
|
@@ -37,7 +37,7 @@ module ActiveAdmin
|
|
|
37
37
|
def build_index_list(index_class)
|
|
38
38
|
li class: classes_for_index(index_class) do
|
|
39
39
|
params = request.query_parameters.except :page, :commit, :format
|
|
40
|
-
url_with_params = url_for(params.merge(as: index_class.index_name.to_sym))
|
|
40
|
+
url_with_params = url_for(**params.merge(as: index_class.index_name.to_sym).symbolize_keys)
|
|
41
41
|
|
|
42
42
|
a href: url_with_params, class: "table_tools_button" do
|
|
43
43
|
name = index_class.index_name
|
|
@@ -38,12 +38,12 @@ module ActiveAdmin
|
|
|
38
38
|
# download_links => Download links override (false or [:csv, :pdf])
|
|
39
39
|
#
|
|
40
40
|
def build(collection, options = {})
|
|
41
|
-
@collection
|
|
42
|
-
@params
|
|
43
|
-
@param_name
|
|
41
|
+
@collection = collection
|
|
42
|
+
@params = options.delete(:params)
|
|
43
|
+
@param_name = options.delete(:param_name)
|
|
44
44
|
@download_links = options.delete(:download_links)
|
|
45
|
-
@display_total
|
|
46
|
-
@per_page
|
|
45
|
+
@display_total = options.delete(:pagination_total) { true }
|
|
46
|
+
@per_page = options.delete(:per_page)
|
|
47
47
|
|
|
48
48
|
unless collection.respond_to?(:total_pages)
|
|
49
49
|
raise(StandardError, "Collection is not a paginated scope. Set collection.page(params[:page]).per(10) before calling :paginated_collection.")
|
|
@@ -93,7 +93,7 @@ module ActiveAdmin
|
|
|
93
93
|
|
|
94
94
|
def build_pagination
|
|
95
95
|
options = { theme: @display_total ? 'active_admin' : 'active_admin_countless' }
|
|
96
|
-
options[:params]
|
|
96
|
+
options[:params] = @params if @params
|
|
97
97
|
options[:param_name] = @param_name if @param_name
|
|
98
98
|
|
|
99
99
|
if !@display_total
|
|
@@ -107,7 +107,7 @@ module ActiveAdmin
|
|
|
107
107
|
options[:right] = 0
|
|
108
108
|
end
|
|
109
109
|
|
|
110
|
-
text_node paginate collection, options
|
|
110
|
+
text_node paginate collection, **options
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
include ::ActiveAdmin::Helpers::Collection
|
|
@@ -116,28 +116,28 @@ module ActiveAdmin
|
|
|
116
116
|
# modified from will_paginate
|
|
117
117
|
def page_entries_info(options = {})
|
|
118
118
|
if options[:entry_name]
|
|
119
|
-
entry_name
|
|
119
|
+
entry_name = options[:entry_name]
|
|
120
120
|
entries_name = options[:entries_name] || entry_name.pluralize
|
|
121
121
|
elsif collection_is_empty?
|
|
122
|
-
entry_name
|
|
122
|
+
entry_name = I18n.t "active_admin.pagination.entry", count: 1, default: 'entry'
|
|
123
123
|
entries_name = I18n.t "active_admin.pagination.entry", count: 2, default: 'entries'
|
|
124
124
|
else
|
|
125
125
|
key = "activerecord.models." + collection.first.class.model_name.i18n_key.to_s
|
|
126
126
|
|
|
127
|
-
entry_name
|
|
127
|
+
entry_name = I18n.translate key, count: 1, default: collection.first.class.name.underscore.sub('_', ' ')
|
|
128
128
|
entries_name = I18n.translate key, count: collection.size, default: entry_name.pluralize
|
|
129
129
|
end
|
|
130
130
|
|
|
131
131
|
if @display_total
|
|
132
132
|
if collection.total_pages < 2
|
|
133
133
|
case collection_size
|
|
134
|
-
when 0; I18n.t("active_admin.pagination.empty",
|
|
135
|
-
when 1; I18n.t("active_admin.pagination.one",
|
|
136
|
-
else;
|
|
134
|
+
when 0; I18n.t("active_admin.pagination.empty", model: entries_name)
|
|
135
|
+
when 1; I18n.t("active_admin.pagination.one", model: entry_name)
|
|
136
|
+
else; I18n.t("active_admin.pagination.one_page", model: entries_name, n: collection.total_count)
|
|
137
137
|
end
|
|
138
138
|
else
|
|
139
139
|
offset = (collection.current_page - 1) * collection.limit_value
|
|
140
|
-
total
|
|
140
|
+
total = collection.total_count
|
|
141
141
|
I18n.t "active_admin.pagination.multiple",
|
|
142
142
|
model: entries_name,
|
|
143
143
|
total: total,
|
|
@@ -8,14 +8,14 @@ module ActiveAdmin
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def build(obj, *attrs)
|
|
11
|
-
options
|
|
12
|
-
@sortable
|
|
13
|
-
@collection
|
|
11
|
+
options = attrs.extract_options!
|
|
12
|
+
@sortable = options.delete(:sortable)
|
|
13
|
+
@collection = obj.respond_to?(:each) && !obj.is_a?(Hash) ? obj : [obj]
|
|
14
14
|
@resource_class = options.delete(:i18n)
|
|
15
15
|
@resource_class ||= @collection.klass if @collection.respond_to? :klass
|
|
16
16
|
|
|
17
|
-
@columns
|
|
18
|
-
@row_class
|
|
17
|
+
@columns = []
|
|
18
|
+
@row_class = options.delete(:row_class)
|
|
19
19
|
|
|
20
20
|
build_table
|
|
21
21
|
super(options)
|
|
@@ -29,7 +29,7 @@ module ActiveAdmin
|
|
|
29
29
|
def column(*args, &block)
|
|
30
30
|
options = default_options.merge(args.extract_options!)
|
|
31
31
|
title = args[0]
|
|
32
|
-
data
|
|
32
|
+
data = args[1] || args[0]
|
|
33
33
|
|
|
34
34
|
col = Column.new(title, data, @resource_class, options, &block)
|
|
35
35
|
@columns << col
|
|
@@ -65,12 +65,12 @@ module ActiveAdmin
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
def build_table_header(col)
|
|
68
|
-
classes
|
|
68
|
+
classes = Arbre::HTML::ClassList.new
|
|
69
69
|
sort_key = sortable? && col.sortable? && col.sort_key
|
|
70
|
-
params
|
|
70
|
+
params = request.query_parameters.except :page, :order, :commit, :format
|
|
71
71
|
|
|
72
|
-
classes << 'sortable'
|
|
73
|
-
classes << "sorted-#{current_sort[1]}"
|
|
72
|
+
classes << 'sortable' if sort_key
|
|
73
|
+
classes << "sorted-#{current_sort[1]}" if sort_key && current_sort[0] == sort_key
|
|
74
74
|
classes << col.html_class
|
|
75
75
|
|
|
76
76
|
if sort_key
|
|
@@ -138,7 +138,7 @@ module ActiveAdmin
|
|
|
138
138
|
|
|
139
139
|
class Column
|
|
140
140
|
|
|
141
|
-
attr_accessor :title, :data
|
|
141
|
+
attr_accessor :title, :data, :html_class
|
|
142
142
|
|
|
143
143
|
def initialize(*args, &block)
|
|
144
144
|
@options = args.extract_options!
|
|
@@ -344,9 +344,9 @@ module ActiveAdmin
|
|
|
344
344
|
#
|
|
345
345
|
# ```
|
|
346
346
|
def actions(options = {}, &block)
|
|
347
|
-
name
|
|
348
|
-
defaults
|
|
349
|
-
dropdown
|
|
347
|
+
name = options.delete(:name) { '' }
|
|
348
|
+
defaults = options.delete(:defaults) { true }
|
|
349
|
+
dropdown = options.delete(:dropdown) { false }
|
|
350
350
|
dropdown_name = options.delete(:dropdown_name) { I18n.t 'active_admin.dropdown_actions.button_label', default: 'Actions' }
|
|
351
351
|
|
|
352
352
|
options[:class] ||= 'col-actions'
|
|
@@ -381,15 +381,15 @@ module ActiveAdmin
|
|
|
381
381
|
end
|
|
382
382
|
if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
|
|
383
383
|
item localizer.t(:delete), resource_path(resource), class: "delete_link #{options[:css_class]}", title: localizer.t(:delete),
|
|
384
|
-
|
|
384
|
+
method: :delete, data: { confirm: localizer.t(:delete_confirmation) }
|
|
385
385
|
end
|
|
386
386
|
end
|
|
387
387
|
|
|
388
388
|
class TableActions < ActiveAdmin::Component
|
|
389
389
|
builder_method :table_actions
|
|
390
390
|
|
|
391
|
-
def item *args
|
|
392
|
-
text_node link_to
|
|
391
|
+
def item *args, **kwargs
|
|
392
|
+
text_node link_to(*args, **kwargs)
|
|
393
393
|
end
|
|
394
394
|
end
|
|
395
395
|
end # IndexTableFor
|
|
@@ -29,7 +29,8 @@ module ActiveAdmin
|
|
|
29
29
|
text_node(active_admin_namespace.head)
|
|
30
30
|
|
|
31
31
|
active_admin_application.stylesheets.each do |style, options|
|
|
32
|
-
|
|
32
|
+
stylesheet_tag = active_admin_namespace.use_webpacker ? stylesheet_pack_tag(style, **options) : stylesheet_link_tag(style, **options)
|
|
33
|
+
text_node(stylesheet_tag.html_safe) if stylesheet_tag
|
|
33
34
|
end
|
|
34
35
|
|
|
35
36
|
active_admin_namespace.meta_tags.each do |name, content|
|
|
@@ -37,7 +38,8 @@ module ActiveAdmin
|
|
|
37
38
|
end
|
|
38
39
|
|
|
39
40
|
active_admin_application.javascripts.each do |path|
|
|
40
|
-
|
|
41
|
+
javascript_tag = active_admin_namespace.use_webpacker ? javascript_pack_tag(path) : javascript_include_tag(path)
|
|
42
|
+
text_node(javascript_tag)
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
if active_admin_namespace.favicon
|
|
@@ -125,16 +125,16 @@ module ActiveAdmin
|
|
|
125
125
|
def render_index
|
|
126
126
|
renderer_class = find_index_renderer_class(config[:as])
|
|
127
127
|
|
|
128
|
-
paginator
|
|
129
|
-
download_links
|
|
128
|
+
paginator = config.fetch(:paginator, true)
|
|
129
|
+
download_links = config.fetch(:download_links, active_admin_config.namespace.download_links)
|
|
130
130
|
pagination_total = config.fetch(:pagination_total, true)
|
|
131
|
-
per_page
|
|
131
|
+
per_page = config.fetch(:per_page, active_admin_config.per_page)
|
|
132
132
|
|
|
133
|
-
paginated_collection(collection, entry_name:
|
|
134
|
-
entries_name:
|
|
135
|
-
download_links:
|
|
136
|
-
paginator:
|
|
137
|
-
per_page:
|
|
133
|
+
paginated_collection(collection, entry_name: active_admin_config.resource_label,
|
|
134
|
+
entries_name: active_admin_config.plural_resource_label(count: collection_size),
|
|
135
|
+
download_links: download_links,
|
|
136
|
+
paginator: paginator,
|
|
137
|
+
per_page: per_page,
|
|
138
138
|
pagination_total: pagination_total) do
|
|
139
139
|
div class: 'index_content' do
|
|
140
140
|
insert_tag(renderer_class, config, collection)
|
data/lib/active_admin.rb
CHANGED
|
@@ -15,44 +15,44 @@ 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
|
|
@@ -130,4 +130,4 @@ require 'active_admin/filters'
|
|
|
130
130
|
|
|
131
131
|
# Require ORM-specific plugins
|
|
132
132
|
require 'active_admin/orm/active_record' if defined? ActiveRecord
|
|
133
|
-
require 'active_admin/orm/mongoid'
|
|
133
|
+
require 'active_admin/orm/mongoid' if defined? Mongoid
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Sass variable overrides must be declared before loading up Active Admin's styles.
|
|
2
2
|
//
|
|
3
3
|
// To view the variables that Active Admin provides, take a look at
|
|
4
4
|
// `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
@import "active_admin/mixins";
|
|
12
12
|
@import "active_admin/base";
|
|
13
13
|
|
|
14
|
-
// Overriding any non-variable
|
|
14
|
+
// Overriding any non-variable Sass must be done after the fact.
|
|
15
15
|
// For example, to change the default status-tag color:
|
|
16
16
|
//
|
|
17
17
|
// .status_tag { background: #6090DB; }
|
|
@@ -7,13 +7,13 @@ module ActiveAdmin
|
|
|
7
7
|
desc "Creates an admin user and uses Devise for authentication"
|
|
8
8
|
argument :name, type: :string, default: "AdminUser"
|
|
9
9
|
|
|
10
|
-
class_option
|
|
11
|
-
|
|
10
|
+
class_option :registerable, type: :boolean, default: false,
|
|
11
|
+
desc: "Should the generated resource be registerable?"
|
|
12
12
|
|
|
13
13
|
RESERVED_NAMES = [:active_admin_user]
|
|
14
14
|
|
|
15
|
-
class_option
|
|
16
|
-
|
|
15
|
+
class_option :default_user, type: :boolean, default: true,
|
|
16
|
+
desc: "Should a default user be created inside the migration?"
|
|
17
17
|
|
|
18
18
|
def install_devise
|
|
19
19
|
begin
|
|
@@ -8,6 +8,7 @@ module ActiveAdmin
|
|
|
8
8
|
|
|
9
9
|
hook_for :users, default: "devise", desc: "Admin user generator to run. Skip with --skip-users"
|
|
10
10
|
class_option :skip_comments, type: :boolean, default: false, desc: "Skip installation of comments"
|
|
11
|
+
class_option :use_webpacker, type: :boolean, default: false, desc: "Use Webpacker assets instead of Sprockets"
|
|
11
12
|
|
|
12
13
|
source_root File.expand_path('templates', __dir__)
|
|
13
14
|
|
|
@@ -15,6 +16,7 @@ module ActiveAdmin
|
|
|
15
16
|
@underscored_user_name = name.underscore.gsub('/', '_')
|
|
16
17
|
@use_authentication_method = options[:users].present?
|
|
17
18
|
@skip_comments = options[:skip_comments]
|
|
19
|
+
@use_webpacker = options[:use_webpacker]
|
|
18
20
|
template 'active_admin.rb.erb', 'config/initializers/active_admin.rb'
|
|
19
21
|
end
|
|
20
22
|
|
|
@@ -36,7 +38,11 @@ module ActiveAdmin
|
|
|
36
38
|
end
|
|
37
39
|
|
|
38
40
|
def create_assets
|
|
39
|
-
|
|
41
|
+
if options[:use_webpacker]
|
|
42
|
+
generate "active_admin:webpacker"
|
|
43
|
+
else
|
|
44
|
+
generate "active_admin:assets"
|
|
45
|
+
end
|
|
40
46
|
end
|
|
41
47
|
|
|
42
48
|
def create_migrations
|
|
@@ -294,7 +294,7 @@ ActiveAdmin.setup do |config|
|
|
|
294
294
|
# config.include_default_association_filters = true
|
|
295
295
|
|
|
296
296
|
# config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version
|
|
297
|
-
# config.filter_columns_for_large_association
|
|
297
|
+
# config.filter_columns_for_large_association = [
|
|
298
298
|
# :display_name,
|
|
299
299
|
# :full_name,
|
|
300
300
|
# :name,
|
|
@@ -303,7 +303,7 @@ ActiveAdmin.setup do |config|
|
|
|
303
303
|
# :title,
|
|
304
304
|
# :email,
|
|
305
305
|
# ]
|
|
306
|
-
# config.filter_method_for_large_association
|
|
306
|
+
# config.filter_method_for_large_association = '_starts_with'
|
|
307
307
|
|
|
308
308
|
# == Head
|
|
309
309
|
#
|
|
@@ -325,4 +325,11 @@ ActiveAdmin.setup do |config|
|
|
|
325
325
|
# You can inherit it with own class and inject it for all resources
|
|
326
326
|
#
|
|
327
327
|
# config.order_clause = MyOrderClause
|
|
328
|
+
|
|
329
|
+
# == Webpacker
|
|
330
|
+
#
|
|
331
|
+
# By default, Active Admin uses Sprocket's asset pipeline.
|
|
332
|
+
# You can switch to using Webpacker here.
|
|
333
|
+
#
|
|
334
|
+
<% unless @use_webpacker %># <% end %>config.use_webpacker = true
|
|
328
335
|
end
|
|
@@ -6,7 +6,7 @@ module ActiveAdmin
|
|
|
6
6
|
desc "Registers resources with Active Admin"
|
|
7
7
|
|
|
8
8
|
class_option :include_boilerplate, type: :boolean, default: false,
|
|
9
|
-
|
|
9
|
+
desc: "Generate boilerplate code for your resource."
|
|
10
10
|
|
|
11
11
|
source_root File.expand_path('templates', __dir__)
|
|
12
12
|
|