activeadmin 2.8.0 → 2.9.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 +44 -0
- data/CONTRIBUTING.md +6 -6
- data/README.md +3 -3
- data/app/assets/javascripts/active_admin/base.js +1 -1
- data/app/views/active_admin/devise/mailer/reset_password_instructions.html.erb +1 -1
- data/app/views/active_admin/devise/mailer/unlock_instructions.html.erb +2 -2
- data/docs/5-forms.md +6 -1
- data/docs/6-show-pages.md +12 -0
- data/docs/Gemfile +2 -2
- data/docs/Gemfile.lock +23 -22
- data/lib/active_admin/application.rb +8 -8
- data/lib/active_admin/application_settings.rb +3 -3
- data/lib/active_admin/base_controller/authorization.rb +4 -3
- data/lib/active_admin/base_controller.rb +4 -4
- 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 +10 -8
- data/lib/active_admin/error.rb +0 -2
- data/lib/active_admin/filters/active.rb +1 -1
- data/lib/active_admin/filters/active_filter.rb +5 -6
- 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/filters.rb +6 -6
- data/lib/active_admin/form_builder.rb +21 -17
- 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/search_method_select.rb +2 -2
- data/lib/active_admin/inputs/filters/base.rb +1 -1
- 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/resource_localizer.rb +3 -3
- data/lib/active_admin/localizers.rb +1 -1
- 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/comments/views/active_admin_comments.rb +17 -17
- data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
- data/lib/active_admin/orm/active_record/comments.rb +13 -13
- data/lib/active_admin/orm/active_record.rb +1 -1
- data/lib/active_admin/page.rb +1 -1
- data/lib/active_admin/pundit_adapter.rb +1 -1
- 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 -3
- data/lib/active_admin/resource/sidebars.rb +1 -1
- data/lib/active_admin/resource.rb +17 -17
- data/lib/active_admin/resource_controller/decorators.rb +1 -3
- data/lib/active_admin/resource_controller/streaming.rb +7 -6
- data/lib/active_admin/resource_controller.rb +9 -9
- 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/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/view_helpers.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/active_admin/views.rb +1 -1
- data/lib/active_admin.rb +55 -56
- 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 +5 -39
data/lib/active_admin/dsl.rb
CHANGED
|
@@ -101,7 +101,7 @@ module ActiveAdmin
|
|
|
101
101
|
def batch_action(title, options = {}, &block)
|
|
102
102
|
# Create symbol & title information
|
|
103
103
|
if title.is_a? String
|
|
104
|
-
sym = title.titleize.tr(
|
|
104
|
+
sym = title.titleize.tr(" ", "").underscore.to_sym
|
|
105
105
|
else
|
|
106
106
|
sym = title
|
|
107
107
|
title = sym.to_s.titleize
|
data/lib/active_admin/engine.rb
CHANGED
|
@@ -2,20 +2,22 @@ module ActiveAdmin
|
|
|
2
2
|
class Engine < ::Rails::Engine
|
|
3
3
|
initializer "active_admin.load_app_path" do |app|
|
|
4
4
|
ActiveAdmin::Application.setting :app_path, app.root
|
|
5
|
-
ActiveAdmin::Application.setting :load_paths, [File.expand_path(
|
|
5
|
+
ActiveAdmin::Application.setting :load_paths, [File.expand_path("app/admin", app.root)]
|
|
6
6
|
end
|
|
7
7
|
|
|
8
8
|
initializer "active_admin.precompile", group: :all do |app|
|
|
9
|
-
ActiveAdmin.application.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
unless ActiveAdmin.application.use_webpacker
|
|
10
|
+
ActiveAdmin.application.stylesheets.each do |path, _|
|
|
11
|
+
app.config.assets.precompile << path
|
|
12
|
+
end
|
|
13
|
+
ActiveAdmin.application.javascripts.each do |path|
|
|
14
|
+
app.config.assets.precompile << path
|
|
15
|
+
end
|
|
14
16
|
end
|
|
15
17
|
end
|
|
16
18
|
|
|
17
|
-
initializer
|
|
18
|
-
require
|
|
19
|
+
initializer "active_admin.routes" do
|
|
20
|
+
require "active_admin/helpers/routes/url_helpers"
|
|
19
21
|
end
|
|
20
22
|
end
|
|
21
23
|
end
|
data/lib/active_admin/error.rb
CHANGED
|
@@ -39,8 +39,9 @@ module ActiveAdmin
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
def predicate_name
|
|
42
|
-
I18n.t(
|
|
43
|
-
|
|
42
|
+
I18n.t(
|
|
43
|
+
"active_admin.filters.predicates.#{condition.predicate.name}",
|
|
44
|
+
default: ransack_predicate_name)
|
|
44
45
|
end
|
|
45
46
|
|
|
46
47
|
def html_options
|
|
@@ -66,7 +67,7 @@ module ActiveAdmin
|
|
|
66
67
|
def filter_label
|
|
67
68
|
return unless filter
|
|
68
69
|
|
|
69
|
-
filter[:label] || I18n.t(name, scope: [
|
|
70
|
+
filter[:label] || I18n.t(name, scope: ["formtastic", "labels"], default: nil)
|
|
70
71
|
end
|
|
71
72
|
|
|
72
73
|
#@return Ransack::Nodes::Attribute
|
|
@@ -83,7 +84,7 @@ module ActiveAdmin
|
|
|
83
84
|
end
|
|
84
85
|
|
|
85
86
|
def find_class?
|
|
86
|
-
[
|
|
87
|
+
["eq", "in"].include? condition.predicate.arel_predicate
|
|
87
88
|
end
|
|
88
89
|
|
|
89
90
|
# detect related class for Ransack::Nodes::Attribute
|
|
@@ -112,8 +113,6 @@ module ActiveAdmin
|
|
|
112
113
|
@predicate_association
|
|
113
114
|
end
|
|
114
115
|
|
|
115
|
-
private
|
|
116
|
-
|
|
117
116
|
def find_predicate_association
|
|
118
117
|
condition_attribute.klass.reflect_on_all_associations.
|
|
119
118
|
reject { |r| r.options[:polymorphic] }. #skip polymorphic
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "active_admin/filters/active"
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
module Filters
|
|
5
5
|
class ActiveSidebar < ActiveAdmin::SidebarSection
|
|
6
6
|
|
|
7
7
|
def initialize
|
|
8
|
-
super
|
|
8
|
+
super "search_status", sidebar_options
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
def block
|
|
@@ -13,11 +13,11 @@ module ActiveAdmin
|
|
|
13
13
|
active_filters = ActiveAdmin::Filters::Active.new(active_admin_config, assigns[:search])
|
|
14
14
|
span do
|
|
15
15
|
if current_scope
|
|
16
|
-
h4 I18n.t("active_admin.search_status.current_scope"), style:
|
|
17
|
-
b scope_name(current_scope), class:
|
|
16
|
+
h4 I18n.t("active_admin.search_status.current_scope"), style: "display: inline"
|
|
17
|
+
b scope_name(current_scope), class: "current_scope_name", style: "display: inline"
|
|
18
18
|
end
|
|
19
19
|
div style: "margin-top: 10px" do
|
|
20
|
-
h4 I18n.t("active_admin.search_status.current_filters"), style:
|
|
20
|
+
h4 I18n.t("active_admin.search_status.current_filters"), style: "margin-bottom: 10px"
|
|
21
21
|
ul do
|
|
22
22
|
if active_filters.filters.blank?
|
|
23
23
|
li I18n.t("active_admin.search_status.no_current_filters")
|
|
@@ -48,7 +48,7 @@ module ActiveAdmin
|
|
|
48
48
|
def active_admin_filters_form_for(search, filters, options = {})
|
|
49
49
|
defaults = { builder: ActiveAdmin::Filters::FormBuilder,
|
|
50
50
|
url: collection_path,
|
|
51
|
-
html: { class:
|
|
51
|
+
html: { class: "filter_form" } }
|
|
52
52
|
required = { html: { method: :get },
|
|
53
53
|
as: :q }
|
|
54
54
|
options = defaults.deep_merge(options).deep_merge(required)
|
|
@@ -65,8 +65,8 @@ module ActiveAdmin
|
|
|
65
65
|
end
|
|
66
66
|
|
|
67
67
|
buttons = content_tag :div, class: "buttons" do
|
|
68
|
-
f.submit(I18n.t(
|
|
69
|
-
link_to(I18n.t(
|
|
68
|
+
f.submit(I18n.t("active_admin.filters.buttons.filter")) +
|
|
69
|
+
link_to(I18n.t("active_admin.filters.buttons.clear"), "#", class: "clear_filters_btn") +
|
|
70
70
|
hidden_field_tags_for(params, except: except_hidden_fields)
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -54,7 +54,7 @@ module ActiveAdmin
|
|
|
54
54
|
end
|
|
55
55
|
|
|
56
56
|
def seems_searchable?
|
|
57
|
-
has_predicate? || scope?
|
|
57
|
+
column_for(method).nil? && (has_predicate? || scope?)
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
# If the given method has a predicate (like _eq or _lteq), it's pretty
|
|
@@ -63,11 +63,6 @@ module ActiveAdmin
|
|
|
63
63
|
!!Ransack::Predicate.detect_from_string(method.to_s)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
# Ransack lets you define custom search methods, called ransackers.
|
|
67
|
-
def ransacker?
|
|
68
|
-
klass._ransackers.key? method.to_s
|
|
69
|
-
end
|
|
70
|
-
|
|
71
66
|
# Ransack supports exposing selected scopes on your model for advanced searches.
|
|
72
67
|
def scope?
|
|
73
68
|
context = Ransack::Context.for klass
|
data/lib/active_admin/filters.rb
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
1
|
+
require "active_admin/filters/dsl"
|
|
2
|
+
require "active_admin/filters/resource_extension"
|
|
3
|
+
require "active_admin/filters/formtastic_addons"
|
|
4
|
+
require "active_admin/filters/forms"
|
|
5
|
+
require "active_admin/helpers/optional_display"
|
|
6
|
+
require "active_admin/filters/active_sidebar"
|
|
7
7
|
|
|
8
8
|
# Add our Extensions
|
|
9
9
|
ActiveAdmin::ResourceDSL.send :include, ActiveAdmin::Filters::DSL
|
|
@@ -22,7 +22,7 @@ module ActiveAdmin
|
|
|
22
22
|
|
|
23
23
|
def cancel_link(url = { action: "index" }, html_options = {}, li_attrs = {})
|
|
24
24
|
li_attrs[:class] ||= "cancel"
|
|
25
|
-
li_content = template.link_to I18n.t(
|
|
25
|
+
li_content = template.link_to I18n.t("active_admin.cancel"), url, html_options
|
|
26
26
|
template.content_tag(:li, li_content, li_attrs)
|
|
27
27
|
end
|
|
28
28
|
|
|
@@ -40,14 +40,14 @@ module ActiveAdmin
|
|
|
40
40
|
attr_reader :assoc
|
|
41
41
|
attr_reader :options
|
|
42
42
|
attr_reader :heading, :sortable_column, :sortable_start
|
|
43
|
-
attr_reader :new_record, :destroy_option
|
|
43
|
+
attr_reader :new_record, :destroy_option, :remove_record
|
|
44
44
|
|
|
45
45
|
def initialize(has_many_form, assoc, options)
|
|
46
46
|
super has_many_form
|
|
47
47
|
@assoc = assoc
|
|
48
48
|
@options = extract_custom_settings!(options.dup)
|
|
49
49
|
@options.reverse_merge!(for: assoc)
|
|
50
|
-
@options[:class] = [options[:class], "inputs has_many_fields"].compact.join(
|
|
50
|
+
@options[:class] = [options[:class], "inputs has_many_fields"].compact.join(" ")
|
|
51
51
|
|
|
52
52
|
if sortable_column
|
|
53
53
|
@options[:for] = [assoc, sorted_children(sortable_column)]
|
|
@@ -72,6 +72,7 @@ module ActiveAdmin
|
|
|
72
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
|
+
@remove_record = options.delete(:remove_record)
|
|
75
76
|
options
|
|
76
77
|
end
|
|
77
78
|
|
|
@@ -93,7 +94,7 @@ module ActiveAdmin
|
|
|
93
94
|
contents = without_wrapper { inputs(options, &form_block) }
|
|
94
95
|
contents ||= "".html_safe
|
|
95
96
|
|
|
96
|
-
js = new_record ? js_for_has_many(options[:class], &form_block) :
|
|
97
|
+
js = new_record ? js_for_has_many(options[:class], &form_block) : ""
|
|
97
98
|
contents << js
|
|
98
99
|
end
|
|
99
100
|
|
|
@@ -107,19 +108,21 @@ module ActiveAdmin
|
|
|
107
108
|
def has_many_actions(form_builder, contents)
|
|
108
109
|
if form_builder.object.new_record?
|
|
109
110
|
contents << template.content_tag(:li) do
|
|
110
|
-
|
|
111
|
+
remove_text = remove_record.is_a?(String) ? remove_record : I18n.t("active_admin.has_many_remove")
|
|
112
|
+
template.link_to remove_text, "#", class: "button has_many_remove"
|
|
111
113
|
end
|
|
112
114
|
elsif allow_destroy?(form_builder.object)
|
|
113
|
-
form_builder.input(
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
form_builder.input(
|
|
116
|
+
:_destroy, as: :boolean,
|
|
117
|
+
wrapper_html: { class: "has_many_delete" },
|
|
118
|
+
label: I18n.t("active_admin.has_many_delete"))
|
|
116
119
|
end
|
|
117
120
|
|
|
118
121
|
if sortable_column
|
|
119
122
|
form_builder.input sortable_column, as: :hidden
|
|
120
123
|
|
|
121
|
-
contents << template.content_tag(:li, class:
|
|
122
|
-
I18n.t(
|
|
124
|
+
contents << template.content_tag(:li, class: "handle") do
|
|
125
|
+
I18n.t("active_admin.move")
|
|
123
126
|
end
|
|
124
127
|
end
|
|
125
128
|
|
|
@@ -164,19 +167,20 @@ module ActiveAdmin
|
|
|
164
167
|
for_options: { child_index: placeholder }
|
|
165
168
|
}
|
|
166
169
|
html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
|
|
167
|
-
text = new_record.is_a?(String) ? new_record : I18n.t(
|
|
170
|
+
text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
|
|
168
171
|
|
|
169
|
-
template.link_to text,
|
|
172
|
+
template.link_to text, "#", class: "button has_many_add", data: {
|
|
170
173
|
html: CGI.escapeHTML(html).html_safe, placeholder: placeholder
|
|
171
174
|
}
|
|
172
175
|
end
|
|
173
176
|
|
|
174
177
|
def wrap_div_or_li(html)
|
|
175
|
-
template.content_tag(
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
template.content_tag(
|
|
179
|
+
already_in_an_inputs_block ? :li : :div,
|
|
180
|
+
html,
|
|
181
|
+
class: "has_many_container #{assoc}",
|
|
182
|
+
"data-sortable" => sortable_column,
|
|
183
|
+
"data-sortable-start" => sortable_start)
|
|
180
184
|
end
|
|
181
185
|
end
|
|
182
186
|
end
|
|
@@ -3,7 +3,7 @@ module ActiveAdmin
|
|
|
3
3
|
class DatepickerInput < ::Formtastic::Inputs::StringInput
|
|
4
4
|
def input_html_options
|
|
5
5
|
super.tap do |options|
|
|
6
|
-
options[:class] = [options[:class], "datepicker"].compact.join(
|
|
6
|
+
options[:class] = [options[:class], "datepicker"].compact.join(" ")
|
|
7
7
|
options[:data] ||= {}
|
|
8
8
|
options[:data].merge! datepicker_options
|
|
9
9
|
end
|
|
@@ -31,7 +31,7 @@ module ActiveAdmin
|
|
|
31
31
|
|
|
32
32
|
def wrapper_html_options
|
|
33
33
|
opts = super
|
|
34
|
-
(opts[:class] ||=
|
|
34
|
+
(opts[:class] ||= "") << " select_and_search" unless seems_searchable?
|
|
35
35
|
opts
|
|
36
36
|
end
|
|
37
37
|
|
|
@@ -48,7 +48,7 @@ module ActiveAdmin
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def select_html
|
|
51
|
-
template.select_tag
|
|
51
|
+
template.select_tag "", template.options_for_select(filter_options, current_filter)
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def filters
|
|
@@ -7,7 +7,7 @@ module ActiveAdmin
|
|
|
7
7
|
def input_name
|
|
8
8
|
return method if seems_searchable?
|
|
9
9
|
|
|
10
|
-
searchable_method_name + (multiple? ?
|
|
10
|
+
searchable_method_name + (multiple? ? "_in" : "_eq")
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def searchable_method_name
|
|
@@ -22,7 +22,7 @@ module ActiveAdmin
|
|
|
22
22
|
|
|
23
23
|
# Provide the AA translation to the blank input field.
|
|
24
24
|
def include_blank
|
|
25
|
-
I18n.t
|
|
25
|
+
I18n.t "active_admin.any" if super
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def input_html_options_name
|
|
@@ -19,16 +19,16 @@ module ActiveAdmin
|
|
|
19
19
|
|
|
20
20
|
def translate(key, options = {})
|
|
21
21
|
scope = options.delete(:scope)
|
|
22
|
-
specific_key = array_to_key(
|
|
22
|
+
specific_key = array_to_key("resources", @model_name, scope, key)
|
|
23
23
|
defaults = [array_to_key(scope, key), key.to_s.titleize]
|
|
24
|
-
::I18n.t specific_key, **options.reverse_merge(model: @model, default: defaults, scope:
|
|
24
|
+
::I18n.t specific_key, **options.reverse_merge(model: @model, default: defaults, scope: "active_admin")
|
|
25
25
|
end
|
|
26
26
|
alias_method :t, :translate
|
|
27
27
|
|
|
28
28
|
protected
|
|
29
29
|
|
|
30
30
|
def array_to_key(*arr)
|
|
31
|
-
arr.flatten.compact.join(
|
|
31
|
+
arr.flatten.compact.join(".").to_sym
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
data/lib/active_admin/menu.rb
CHANGED
|
@@ -47,7 +47,7 @@ module ActiveAdmin
|
|
|
47
47
|
super() # MenuNode
|
|
48
48
|
@label = options[:label]
|
|
49
49
|
@dirty_id = options[:id] || options[:label]
|
|
50
|
-
@url = options[:url] ||
|
|
50
|
+
@url = options[:url] || "#"
|
|
51
51
|
@priority = options[:priority] || 10
|
|
52
52
|
@html_options = options[:html_options] || {}
|
|
53
53
|
@should_display = options[:if] || proc { true }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "active_admin/resource_collection"
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
|
|
@@ -31,7 +31,7 @@ module ActiveAdmin
|
|
|
31
31
|
end
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
RegisterEvent =
|
|
34
|
+
RegisterEvent = "active_admin.namespace.register".freeze
|
|
35
35
|
|
|
36
36
|
attr_reader :application, :resources, :menus
|
|
37
37
|
|
|
@@ -149,8 +149,8 @@ module ActiveAdmin
|
|
|
149
149
|
def add_logout_button_to_menu(menu, priority = 20, html_options = {})
|
|
150
150
|
if logout_link_path
|
|
151
151
|
html_options = html_options.reverse_merge(method: logout_link_method || :get)
|
|
152
|
-
menu.add id:
|
|
153
|
-
label: -> { I18n.t
|
|
152
|
+
menu.add id: "logout", priority: priority, html_options: html_options,
|
|
153
|
+
label: -> { I18n.t "active_admin.logout" },
|
|
154
154
|
url: -> { render_or_call_method_or_proc_on self, active_admin_namespace.logout_link_path },
|
|
155
155
|
if: :current_active_admin_user?
|
|
156
156
|
end
|
|
@@ -164,7 +164,7 @@ module ActiveAdmin
|
|
|
164
164
|
#
|
|
165
165
|
def add_current_user_to_menu(menu, priority = 10, html_options = {})
|
|
166
166
|
if current_user_method
|
|
167
|
-
menu.add id:
|
|
167
|
+
menu.add id: "current_user", priority: priority, html_options: html_options,
|
|
168
168
|
label: -> { display_name current_active_admin_user },
|
|
169
169
|
url: -> { auto_url_for(current_active_admin_user) },
|
|
170
170
|
if: :current_active_admin_user?
|
|
@@ -211,8 +211,8 @@ module ActiveAdmin
|
|
|
211
211
|
|
|
212
212
|
def unload_resources!
|
|
213
213
|
resources.each do |resource|
|
|
214
|
-
parent = (module_name ||
|
|
215
|
-
name = resource.controller_name.split(
|
|
214
|
+
parent = (module_name || "Object").constantize
|
|
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
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require "active_admin/dynamic_settings_node"
|
|
2
2
|
|
|
3
3
|
module ActiveAdmin
|
|
4
4
|
class NamespaceSettings < DynamicSettingsNode
|
|
@@ -57,7 +57,7 @@ module ActiveAdmin
|
|
|
57
57
|
register :filters, true
|
|
58
58
|
|
|
59
59
|
# The namespace root
|
|
60
|
-
register :root_to,
|
|
60
|
+
register :root_to, "dashboard#index"
|
|
61
61
|
|
|
62
62
|
# Options that are passed to root_to
|
|
63
63
|
register :root_to_options, {}
|
|
@@ -73,7 +73,7 @@ module ActiveAdmin
|
|
|
73
73
|
register :create_another, false
|
|
74
74
|
|
|
75
75
|
# Default CSV options
|
|
76
|
-
register :csv_options, { col_sep:
|
|
76
|
+
register :csv_options, { col_sep: ",", byte_order_mark: "\xEF\xBB\xBF" }
|
|
77
77
|
|
|
78
78
|
# Default Download Links options
|
|
79
79
|
register :download_links, true
|
|
@@ -102,7 +102,7 @@ module ActiveAdmin
|
|
|
102
102
|
]
|
|
103
103
|
|
|
104
104
|
# Set flash message keys that shouldn't show in ActiveAdmin
|
|
105
|
-
register :flash_keys_to_except, [
|
|
105
|
+
register :flash_keys_to_except, ["timedout"]
|
|
106
106
|
|
|
107
107
|
# Include association filters by default
|
|
108
108
|
register :include_default_association_filters, true
|
|
@@ -118,7 +118,7 @@ module ActiveAdmin
|
|
|
118
118
|
:title,
|
|
119
119
|
:email,
|
|
120
120
|
]
|
|
121
|
-
register :filter_method_for_large_association,
|
|
121
|
+
register :filter_method_for_large_association, "_starts_with"
|
|
122
122
|
|
|
123
123
|
# Switch between asset pipeline and webpacker assets
|
|
124
124
|
register :use_webpacker, false
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "active_admin/views"
|
|
2
|
+
require "active_admin/views/components/panel"
|
|
3
3
|
|
|
4
4
|
module ActiveAdmin
|
|
5
5
|
module Comments
|
|
@@ -22,13 +22,13 @@ module ActiveAdmin
|
|
|
22
22
|
protected
|
|
23
23
|
|
|
24
24
|
def title
|
|
25
|
-
I18n.t
|
|
25
|
+
I18n.t "active_admin.comments.title_content", count: @comments.total_count
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
def build_comments
|
|
29
29
|
if @comments.any?
|
|
30
30
|
@comments.each(&method(:build_comment))
|
|
31
|
-
div page_entries_info(@comments).html_safe, class:
|
|
31
|
+
div page_entries_info(@comments).html_safe, class: "pagination_information"
|
|
32
32
|
else
|
|
33
33
|
build_empty_message
|
|
34
34
|
end
|
|
@@ -42,39 +42,39 @@ module ActiveAdmin
|
|
|
42
42
|
|
|
43
43
|
def build_comment(comment)
|
|
44
44
|
div for: comment do
|
|
45
|
-
div class:
|
|
46
|
-
h4 class:
|
|
47
|
-
comment.author ? auto_link(comment.author) : I18n.t(
|
|
45
|
+
div class: "active_admin_comment_meta" do
|
|
46
|
+
h4 class: "active_admin_comment_author" do
|
|
47
|
+
comment.author ? auto_link(comment.author) : I18n.t("active_admin.comments.author_missing")
|
|
48
48
|
end
|
|
49
49
|
span pretty_format comment.created_at
|
|
50
50
|
if authorized?(ActiveAdmin::Auth::DESTROY, comment)
|
|
51
|
-
text_node link_to I18n.t(
|
|
51
|
+
text_node link_to I18n.t("active_admin.comments.delete"), comments_url(comment.id), method: :delete, data: { confirm: I18n.t("active_admin.comments.delete_confirmation") }
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
|
-
div class:
|
|
54
|
+
div class: "active_admin_comment_body" do
|
|
55
55
|
simple_format comment.body
|
|
56
56
|
end
|
|
57
57
|
end
|
|
58
58
|
end
|
|
59
59
|
|
|
60
60
|
def build_empty_message
|
|
61
|
-
span I18n.t(
|
|
61
|
+
span I18n.t("active_admin.comments.no_comments_yet"), class: "empty"
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def comments_url(*args)
|
|
65
65
|
parts = []
|
|
66
66
|
parts << active_admin_namespace.name unless active_admin_namespace.root?
|
|
67
67
|
parts << active_admin_namespace.comments_registration_name.underscore
|
|
68
|
-
parts <<
|
|
69
|
-
send parts.join(
|
|
68
|
+
parts << "path"
|
|
69
|
+
send parts.join("_"), *args
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
def comment_form_url
|
|
73
73
|
parts = []
|
|
74
74
|
parts << active_admin_namespace.name unless active_admin_namespace.root?
|
|
75
75
|
parts << active_admin_namespace.comments_registration_name.underscore.pluralize
|
|
76
|
-
parts <<
|
|
77
|
-
send parts.join
|
|
76
|
+
parts << "path"
|
|
77
|
+
send parts.join "_"
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
def build_comment_form
|
|
@@ -82,16 +82,16 @@ module ActiveAdmin
|
|
|
82
82
|
f.inputs do
|
|
83
83
|
f.input :resource_type, as: :hidden, input_html: { value: ActiveAdmin::Comment.resource_type(parent.resource) }
|
|
84
84
|
f.input :resource_id, as: :hidden, input_html: { value: parent.resource.id }
|
|
85
|
-
f.input :body, label: false, input_html: { size:
|
|
85
|
+
f.input :body, label: false, input_html: { size: "80x8" }
|
|
86
86
|
end
|
|
87
87
|
f.actions do
|
|
88
|
-
f.action :submit, label: I18n.t(
|
|
88
|
+
f.action :submit, label: I18n.t("active_admin.comments.add")
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
def default_id_for_prefix
|
|
94
|
-
|
|
94
|
+
"active_admin_comments_for"
|
|
95
95
|
end
|
|
96
96
|
end
|
|
97
97
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require
|
|
2
|
-
require
|
|
1
|
+
require "active_admin/views"
|
|
2
|
+
require "active_admin/orm/active_record/comments/views/active_admin_comments"
|