activeadmin 2.8.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 +11 -0
- data/app/assets/javascripts/active_admin/base.js +1 -1
- data/docs/Gemfile +2 -2
- data/lib/active_admin.rb +56 -56
- data/lib/active_admin/application.rb +8 -8
- data/lib/active_admin/application_settings.rb +3 -3
- data/lib/active_admin/base_controller.rb +4 -4
- data/lib/active_admin/base_controller/authorization.rb +4 -3
- data/lib/active_admin/batch_actions/controller.rb +1 -1
- data/lib/active_admin/batch_actions/resource_extension.rb +9 -8
- data/lib/active_admin/batch_actions/views/batch_action_form.rb +2 -2
- data/lib/active_admin/batch_actions/views/batch_action_selector.rb +1 -1
- 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/dependency.rb +4 -4
- 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 +6 -6
- 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 +3 -3
- data/lib/active_admin/filters/formtastic_addons.rb +1 -6
- data/lib/active_admin/form_builder.rb +18 -16
- data/lib/active_admin/generators/boilerplate.rb +1 -1
- 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 +2 -2
- 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/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 +1 -1
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +7 -7
- data/lib/active_admin/namespace_settings.rb +5 -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 +13 -13
- 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 +17 -17
- data/lib/active_admin/page.rb +1 -1
- data/lib/active_admin/pundit_adapter.rb +1 -1
- data/lib/active_admin/resource.rb +17 -17
- data/lib/active_admin/resource/action_items.rb +4 -4
- 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/naming.rb +2 -2
- data/lib/active_admin/resource/routes.rb +1 -1
- data/lib/active_admin/resource/sidebars.rb +1 -1
- data/lib/active_admin/resource_controller.rb +9 -9
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_controller/streaming.rb +7 -6
- data/lib/active_admin/scope.rb +1 -1
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -1
- data/lib/active_admin/view_helpers.rb +1 -1
- data/lib/active_admin/view_helpers/breadcrumb_helper.rb +2 -2
- data/lib/active_admin/view_helpers/display_helper.rb +2 -2
- data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -1
- data/lib/active_admin/view_helpers/fields_for.rb +1 -1
- 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 +3 -3
- data/lib/active_admin/views/components/blank_slate.rb +1 -1
- data/lib/active_admin/views/components/dropdown_menu.rb +6 -6
- data/lib/active_admin/views/components/index_list.rb +2 -2
- data/lib/active_admin/views/components/menu.rb +1 -1
- data/lib/active_admin/views/components/menu_item.rb +3 -3
- data/lib/active_admin/views/components/paginated_collection.rb +6 -6
- data/lib/active_admin/views/components/panel.rb +1 -1
- data/lib/active_admin/views/components/scopes.rb +5 -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 +7 -7
- data/lib/active_admin/views/components/tabs.rb +2 -2
- 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 +11 -11
- data/lib/active_admin/views/pages/base.rb +6 -6
- data/lib/active_admin/views/pages/index.rb +10 -9
- 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/devise/devise_generator.rb +1 -1
- data/lib/generators/active_admin/install/install_generator.rb +7 -7
- data/lib/generators/active_admin/page/page_generator.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +2 -2
- data/lib/generators/active_admin/webpacker/webpacker_generator.rb +7 -7
- data/lib/ransack_ext.rb +8 -8
- metadata +2 -2
@@ -10,7 +10,7 @@ module ActiveAdmin
|
|
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.
|
@@ -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
|
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
|
@@ -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)
|
@@ -44,21 +44,21 @@ module ActiveAdmin
|
|
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
|
@@ -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
|
@@ -92,7 +92,7 @@ module ActiveAdmin
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def build_pagination
|
95
|
-
options = { theme: @display_total ?
|
95
|
+
options = { theme: @display_total ? "active_admin" : "active_admin_countless" }
|
96
96
|
options[:params] = @params if @params
|
97
97
|
options[:param_name] = @param_name if @param_name
|
98
98
|
|
@@ -119,12 +119,12 @@ module ActiveAdmin
|
|
119
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 = I18n.t "active_admin.pagination.entry", count: 1, default:
|
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 = I18n.translate key, count: 1, default: collection.first.class.name.underscore.sub(
|
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
|
|
@@ -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 = {})
|
@@ -38,9 +38,9 @@ module ActiveAdmin
|
|
38
38
|
li class: classes_for_scope(scope) do
|
39
39
|
params = request.query_parameters.except :page, :scope, :commit, :format
|
40
40
|
|
41
|
-
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
|
42
42
|
text_node scope_name(scope)
|
43
|
-
span class:
|
43
|
+
span class: "count" do
|
44
44
|
"(#{get_scope_count(scope)})"
|
45
45
|
end if options[:scope_count] && scope.show_count
|
46
46
|
end
|
@@ -5,11 +5,11 @@ module ActiveAdmin
|
|
5
5
|
builder_method :status_tag
|
6
6
|
|
7
7
|
def tag_name
|
8
|
-
|
8
|
+
"span"
|
9
9
|
end
|
10
10
|
|
11
11
|
def default_class_name
|
12
|
-
|
12
|
+
"status_tag"
|
13
13
|
end
|
14
14
|
|
15
15
|
# @overload status_tag(status, options = {})
|
@@ -49,12 +49,12 @@ module ActiveAdmin
|
|
49
49
|
|
50
50
|
def convert_to_boolean_status(status)
|
51
51
|
case status
|
52
|
-
when true,
|
53
|
-
|
54
|
-
when false,
|
55
|
-
|
52
|
+
when true, "true"
|
53
|
+
"Yes"
|
54
|
+
when false, "false"
|
55
|
+
"No"
|
56
56
|
when nil
|
57
|
-
|
57
|
+
"Unset"
|
58
58
|
else
|
59
59
|
status
|
60
60
|
end
|
@@ -62,12 +62,12 @@ module ActiveAdmin
|
|
62
62
|
|
63
63
|
def status_to_class(status)
|
64
64
|
case status
|
65
|
-
when
|
66
|
-
|
65
|
+
when "Unset"
|
66
|
+
"unset no"
|
67
67
|
when String, Symbol
|
68
|
-
status.to_s.titleize.gsub(/\s/,
|
68
|
+
status.to_s.titleize.gsub(/\s/, "").underscore
|
69
69
|
else
|
70
|
-
|
70
|
+
""
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -4,7 +4,7 @@ module ActiveAdmin
|
|
4
4
|
builder_method :table_for
|
5
5
|
|
6
6
|
def tag_name
|
7
|
-
|
7
|
+
"table"
|
8
8
|
end
|
9
9
|
|
10
10
|
def build(obj, *attrs)
|
@@ -69,7 +69,7 @@ module ActiveAdmin
|
|
69
69
|
sort_key = sortable? && col.sortable? && col.sort_key
|
70
70
|
params = request.query_parameters.except :page, :order, :commit, :format
|
71
71
|
|
72
|
-
classes <<
|
72
|
+
classes << "sortable" if sort_key
|
73
73
|
classes << "sorted-#{current_sort[1]}" if sort_key && current_sort[0] == sort_key
|
74
74
|
classes << col.html_class
|
75
75
|
|
@@ -86,13 +86,13 @@ module ActiveAdmin
|
|
86
86
|
@tbody = tbody do
|
87
87
|
# Build enough rows for our collection
|
88
88
|
@collection.each do |elem|
|
89
|
-
classes = [helpers.cycle(
|
89
|
+
classes = [helpers.cycle("odd", "even")]
|
90
90
|
|
91
91
|
if @row_class
|
92
92
|
classes << @row_class.call(elem)
|
93
93
|
end
|
94
94
|
|
95
|
-
tr(class: classes.flatten.join(
|
95
|
+
tr(class: classes.flatten.join(" "), id: dom_id_for(elem))
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -126,8 +126,8 @@ module ActiveAdmin
|
|
126
126
|
# 'desc' it will return 'asc'
|
127
127
|
def order_for_sort_key(sort_key)
|
128
128
|
current_key, current_order = current_sort
|
129
|
-
return
|
130
|
-
current_order ==
|
129
|
+
return "desc" unless current_key == sort_key
|
130
|
+
current_order == "desc" ? "asc" : "desc"
|
131
131
|
end
|
132
132
|
|
133
133
|
def default_options
|
@@ -150,7 +150,7 @@ module ActiveAdmin
|
|
150
150
|
elsif @title.present?
|
151
151
|
html_classes << "col-#{@title.to_s.parameterize(separator: "_")}"
|
152
152
|
end
|
153
|
-
@html_class = html_classes.join(
|
153
|
+
@html_class = html_classes.join(" ")
|
154
154
|
@data = args[1] || args[0]
|
155
155
|
@data = block if block
|
156
156
|
@resource_class = args[2]
|
@@ -10,8 +10,8 @@ module ActiveAdmin
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def build(&block)
|
13
|
-
@menu = ul(class:
|
14
|
-
@tabs_content = div(class:
|
13
|
+
@menu = ul(class: "nav nav-tabs", role: "tablist")
|
14
|
+
@tabs_content = div(class: "tab-content")
|
15
15
|
end
|
16
16
|
|
17
17
|
def build_menu_item(title, options, &block)
|
@@ -10,8 +10,8 @@ module ActiveAdmin
|
|
10
10
|
@utility_menu = @namespace.fetch_menu(:utility_navigation)
|
11
11
|
|
12
12
|
site_title @namespace
|
13
|
-
global_navigation @menu, class:
|
14
|
-
utility_navigation @utility_menu, id: "utility_nav", class:
|
13
|
+
global_navigation @menu, class: "header-item tabs"
|
14
|
+
utility_navigation @utility_menu, id: "utility_nav", class: "header-item tabs"
|
15
15
|
end
|
16
16
|
|
17
17
|
end
|
@@ -278,13 +278,13 @@ module ActiveAdmin
|
|
278
278
|
# Display a column for checkbox
|
279
279
|
def selectable_column
|
280
280
|
return unless active_admin_config.batch_actions.any?
|
281
|
-
column resource_selection_toggle_cell, class:
|
281
|
+
column resource_selection_toggle_cell, class: "col-selectable", sortable: false do |resource|
|
282
282
|
resource_selection_cell resource
|
283
283
|
end
|
284
284
|
end
|
285
285
|
|
286
286
|
def index_column(start_value = 1)
|
287
|
-
column
|
287
|
+
column "#", class: "col-index", sortable: false do |resource|
|
288
288
|
@collection.offset_value + @collection.index(resource) + start_value
|
289
289
|
end
|
290
290
|
end
|
@@ -293,9 +293,9 @@ module ActiveAdmin
|
|
293
293
|
def id_column
|
294
294
|
raise "#{resource_class.name} has no primary_key!" unless resource_class.primary_key
|
295
295
|
column(resource_class.human_attribute_name(resource_class.primary_key), sortable: resource_class.primary_key) do |resource|
|
296
|
-
if controller.action_methods.include?(
|
296
|
+
if controller.action_methods.include?("show")
|
297
297
|
link_to resource.id, resource_path(resource), class: "resource_id_link"
|
298
|
-
elsif controller.action_methods.include?(
|
298
|
+
elsif controller.action_methods.include?("edit")
|
299
299
|
link_to resource.id, edit_resource_path(resource), class: "resource_id_link"
|
300
300
|
else
|
301
301
|
resource.id
|
@@ -304,7 +304,7 @@ module ActiveAdmin
|
|
304
304
|
end
|
305
305
|
|
306
306
|
def default_actions
|
307
|
-
raise
|
307
|
+
raise "`default_actions` is no longer provided in ActiveAdmin 1.x. Use `actions` instead."
|
308
308
|
end
|
309
309
|
|
310
310
|
# Add links to perform actions.
|
@@ -344,12 +344,12 @@ module ActiveAdmin
|
|
344
344
|
#
|
345
345
|
# ```
|
346
346
|
def actions(options = {}, &block)
|
347
|
-
name = options.delete(:name) {
|
347
|
+
name = options.delete(:name) { "" }
|
348
348
|
defaults = options.delete(:defaults) { true }
|
349
349
|
dropdown = options.delete(:dropdown) { false }
|
350
|
-
dropdown_name = options.delete(:dropdown_name) { I18n.t
|
350
|
+
dropdown_name = options.delete(:dropdown_name) { I18n.t "active_admin.dropdown_actions.button_label", default: "Actions" }
|
351
351
|
|
352
|
-
options[:class] ||=
|
352
|
+
options[:class] ||= "col-actions"
|
353
353
|
|
354
354
|
column name, options do |resource|
|
355
355
|
if dropdown
|
@@ -373,13 +373,13 @@ module ActiveAdmin
|
|
373
373
|
|
374
374
|
def defaults(resource, options = {})
|
375
375
|
localizer = ActiveAdmin::Localizers.resource(active_admin_config)
|
376
|
-
if controller.action_methods.include?(
|
376
|
+
if controller.action_methods.include?("show") && authorized?(ActiveAdmin::Auth::READ, resource)
|
377
377
|
item localizer.t(:view), resource_path(resource), class: "view_link #{options[:css_class]}", title: localizer.t(:view)
|
378
378
|
end
|
379
|
-
if controller.action_methods.include?(
|
379
|
+
if controller.action_methods.include?("edit") && authorized?(ActiveAdmin::Auth::UPDATE, resource)
|
380
380
|
item localizer.t(:edit), edit_resource_path(resource), class: "edit_link #{options[:css_class]}", title: localizer.t(:edit)
|
381
381
|
end
|
382
|
-
if controller.action_methods.include?(
|
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
|