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
data/lib/active_admin/version.rb
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
require
|
1
|
+
require "active_admin/abstract_view_factory"
|
2
2
|
|
3
3
|
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
|
@@ -2,7 +2,7 @@ module ActiveAdmin
|
|
2
2
|
module ViewHelpers
|
3
3
|
|
4
4
|
# Require all ruby files in the view helpers dir
|
5
|
-
Dir[File.expand_path(
|
5
|
+
Dir[File.expand_path("view_helpers", __dir__) + "/*.rb"].each { |f| require f }
|
6
6
|
|
7
7
|
include ActiveAdminApplicationHelper
|
8
8
|
include AutoLinkHelper
|
@@ -6,7 +6,7 @@ module ActiveAdmin
|
|
6
6
|
def breadcrumb_links(path = request.path)
|
7
7
|
# remove leading "/" and split up the URL
|
8
8
|
# and remove last since it's used as the page title
|
9
|
-
parts = path.split(
|
9
|
+
parts = path.split("/").select(&:present?)[0..-2]
|
10
10
|
|
11
11
|
parts.each_with_index.map do |part, index|
|
12
12
|
# 1. try using `display_name` if we can locate a DB object
|
@@ -15,13 +15,13 @@ 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
|
|
22
22
|
# Don't create a link if the resource's show action is disabled
|
23
23
|
if !config || config.defined_actions.include?(:show)
|
24
|
-
link_to name,
|
24
|
+
link_to name, "/" + parts[0..index].join("/")
|
25
25
|
else
|
26
26
|
name
|
27
27
|
end
|
@@ -5,12 +5,12 @@ 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
|
}
|
12
12
|
def DISPLAY_NAME_FALLBACK.inspect
|
13
|
-
|
13
|
+
"DISPLAY_NAME_FALLBACK"
|
14
14
|
end
|
15
15
|
|
16
16
|
# Attempts to call any known display name methods on the resource.
|
@@ -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)
|
@@ -85,7 +85,7 @@ module ActiveAdmin
|
|
85
85
|
end
|
86
86
|
|
87
87
|
def format_collection(collection)
|
88
|
-
safe_join(collection.map { |item| pretty_format(item) },
|
88
|
+
safe_join(collection.map { |item| pretty_format(item) }, ", ")
|
89
89
|
end
|
90
90
|
|
91
91
|
def boolean_attr?(resource, attr, value)
|
@@ -18,7 +18,7 @@ module ActiveAdmin
|
|
18
18
|
def build_download_format_links(formats = self.class.formats)
|
19
19
|
params = request.query_parameters.except :format, :commit
|
20
20
|
div class: "download_links" do
|
21
|
-
span I18n.t(
|
21
|
+
span I18n.t("active_admin.download")
|
22
22
|
formats.each do |format|
|
23
23
|
a format.upcase, href: url_for(params: params, format: format)
|
24
24
|
end
|
@@ -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)
|
@@ -37,7 +37,7 @@ module ActiveAdmin
|
|
37
37
|
{ "#{k}[]" => v }
|
38
38
|
end
|
39
39
|
when nil
|
40
|
-
{ k =>
|
40
|
+
{ k => "" }
|
41
41
|
when TrueClass, FalseClass
|
42
42
|
{ k => v }
|
43
43
|
else
|
data/lib/active_admin/views.rb
CHANGED
@@ -111,14 +111,14 @@ module ActiveAdmin
|
|
111
111
|
create_another = params[:create_another]
|
112
112
|
label = @resource.class.model_name.human
|
113
113
|
Arbre::Context.new do
|
114
|
-
li class:
|
114
|
+
li class: "create_another" do
|
115
115
|
input(
|
116
116
|
checked: create_another,
|
117
|
-
id:
|
118
|
-
name:
|
119
|
-
type:
|
117
|
+
id: "create_another",
|
118
|
+
name: "create_another",
|
119
|
+
type: "checkbox"
|
120
120
|
)
|
121
|
-
label(I18n.t(
|
121
|
+
label(I18n.t("active_admin.create_another", model: label), for: "create_another")
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
@@ -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]
|
@@ -28,7 +28,7 @@ module ActiveAdmin
|
|
28
28
|
elsif title.present?
|
29
29
|
classes << "row-#{title.to_s.parameterize(separator: "_")}"
|
30
30
|
end
|
31
|
-
options[:class] = classes.join(
|
31
|
+
options[:class] = classes.join(" ")
|
32
32
|
|
33
33
|
@table << tr(options) do
|
34
34
|
th do
|
@@ -45,7 +45,7 @@ module ActiveAdmin
|
|
45
45
|
protected
|
46
46
|
|
47
47
|
def default_id_for_prefix
|
48
|
-
|
48
|
+
"attributes_table"
|
49
49
|
end
|
50
50
|
|
51
51
|
# Build Colgroups
|
@@ -75,7 +75,7 @@ module ActiveAdmin
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def empty_value
|
78
|
-
span I18n.t(
|
78
|
+
span I18n.t("active_admin.empty"), class: "empty"
|
79
79
|
end
|
80
80
|
|
81
81
|
def content_for(record, attr)
|
@@ -35,30 +35,30 @@ module ActiveAdmin
|
|
35
35
|
super(options)
|
36
36
|
end
|
37
37
|
|
38
|
-
def item(*args)
|
38
|
+
def item(*args, **kwargs)
|
39
39
|
within @menu do
|
40
|
-
li link_to(*args)
|
40
|
+
li link_to(*args, **kwargs)
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def build_button(name, button_options)
|
47
|
-
button_options[:class] ||=
|
48
|
-
button_options[:class] <<
|
47
|
+
button_options[:class] ||= ""
|
48
|
+
button_options[:class] << " dropdown_menu_button"
|
49
49
|
|
50
|
-
button_options[:href] =
|
50
|
+
button_options[:href] = "#"
|
51
51
|
|
52
52
|
a name, button_options
|
53
53
|
end
|
54
54
|
|
55
55
|
def build_menu(options)
|
56
|
-
options[:class] ||=
|
57
|
-
options[:class] <<
|
56
|
+
options[:class] ||= ""
|
57
|
+
options[:class] << " dropdown_menu_list"
|
58
58
|
|
59
59
|
menu_list = nil
|
60
60
|
|
61
|
-
div class:
|
61
|
+
div class: "dropdown_menu_list_wrapper" do
|
62
62
|
menu_list = ul(options)
|
63
63
|
end
|
64
64
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "active_admin/helpers/collection"
|
2
2
|
|
3
3
|
module ActiveAdmin
|
4
4
|
module Views
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def tag_name
|
18
|
-
|
18
|
+
"ul"
|
19
19
|
end
|
20
20
|
|
21
21
|
# Builds the links for presenting different index views to the user
|
@@ -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
|
@@ -18,7 +18,7 @@ module ActiveAdmin
|
|
18
18
|
add_class "current" if item.current? assigns[:current_tab]
|
19
19
|
|
20
20
|
if url
|
21
|
-
text_node link_to label, url, item.html_options
|
21
|
+
text_node link_to label, url, **item.html_options
|
22
22
|
else
|
23
23
|
span label, item.html_options
|
24
24
|
end
|
@@ -30,7 +30,7 @@ module ActiveAdmin
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def tag_name
|
33
|
-
|
33
|
+
"li"
|
34
34
|
end
|
35
35
|
|
36
36
|
# Sorts by priority first, then alphabetically by label if needed.
|
@@ -44,14 +44,14 @@ module ActiveAdmin
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def to_s
|
47
|
-
visible? ? super :
|
47
|
+
visible? ? super : ""
|
48
48
|
end
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
52
|
# URL is not nil, empty, or '#'
|
53
53
|
def real_url?
|
54
|
-
url && url.present? && url !=
|
54
|
+
url && url.present? && url != "#"
|
55
55
|
end
|
56
56
|
end
|
57
57
|
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_admin/helpers/collection"
|
2
|
+
require "active_admin/view_helpers/download_format_links_helper"
|
3
3
|
|
4
4
|
module ActiveAdmin
|
5
5
|
module Views
|
@@ -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.")
|
@@ -92,8 +92,8 @@ module ActiveAdmin
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def build_pagination
|
95
|
-
options = { theme: @display_total ?
|
96
|
-
options[:params]
|
95
|
+
options = { theme: @display_total ? "active_admin" : "active_admin_countless" }
|
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
|
123
|
-
entries_name = I18n.t "active_admin.pagination.entry", count: 2, default:
|
122
|
+
entry_name = I18n.t "active_admin.pagination.entry", count: 1, default: "entry"
|
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,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "active_admin/helpers/collection"
|
2
|
+
require "active_admin/view_helpers/method_or_proc_helper"
|
3
3
|
|
4
4
|
module ActiveAdmin
|
5
5
|
module Views
|
@@ -17,7 +17,7 @@ module ActiveAdmin
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def tag_name
|
20
|
-
|
20
|
+
"div"
|
21
21
|
end
|
22
22
|
|
23
23
|
def build(scopes, options = {})
|
@@ -26,6 +26,8 @@ module ActiveAdmin
|
|
26
26
|
group_scopes.each do |scope|
|
27
27
|
build_scope(scope, options) if call_method_or_exec_proc(scope.display_if_block)
|
28
28
|
end
|
29
|
+
|
30
|
+
nil
|
29
31
|
end
|
30
32
|
end
|
31
33
|
end
|
@@ -36,9 +38,9 @@ module ActiveAdmin
|
|
36
38
|
li class: classes_for_scope(scope) do
|
37
39
|
params = request.query_parameters.except :page, :scope, :commit, :format
|
38
40
|
|
39
|
-
a href: url_for(scope: scope.id, params: params), class:
|
41
|
+
a href: url_for(scope: scope.id, params: params), class: "table_tools_button" do
|
40
42
|
text_node scope_name(scope)
|
41
|
-
span class:
|
43
|
+
span class: "count" do
|
42
44
|
"(#{get_scope_count(scope)})"
|
43
45
|
end if options[:scope_count] && scope.show_count
|
44
46
|
end
|