activeadmin 1.0.0.pre1 → 1.0.0.pre2
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/.travis.yml +18 -16
- data/CHANGELOG.md +18 -1013
- data/Gemfile +18 -11
- data/LICENSE +0 -5
- data/README.md +0 -2
- data/activeadmin.gemspec +3 -1
- data/app/assets/javascripts/active_admin/application.js.coffee +8 -3
- data/app/assets/javascripts/active_admin/base.js.coffee +1 -6
- data/app/assets/javascripts/active_admin/jquery_ui.js.erb +11 -0
- data/app/assets/javascripts/active_admin/lib/flash.js.coffee +1 -1
- data/app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee +11 -3
- data/app/assets/javascripts/active_admin/lib/per_page.js.coffee +5 -1
- data/app/assets/stylesheets/active_admin/_base.scss +1 -4
- data/app/assets/stylesheets/active_admin/_forms.scss +13 -8
- data/app/assets/stylesheets/active_admin/components/_buttons.scss +0 -5
- data/app/assets/stylesheets/active_admin/mixins/_all.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_sections.scss +0 -1
- data/app/assets/stylesheets/active_admin/mixins/_typography.scss +1 -1
- data/app/assets/stylesheets/active_admin/mixins/_variables.scss +1 -1
- data/app/assets/stylesheets/active_admin/structure/_title_bar.scss +0 -5
- data/app/views/layouts/active_admin_logged_out.html.erb +4 -0
- data/config/locales/ar.yml +14 -2
- data/config/locales/de-CH.yml +2 -0
- data/config/locales/de.yml +15 -0
- data/config/locales/en.yml +10 -2
- data/config/locales/es.yml +26 -4
- data/config/locales/fr.yml +5 -0
- data/config/locales/id.yml +135 -0
- data/config/locales/ja.yml +21 -3
- data/config/locales/ko.yml +66 -36
- data/config/locales/nl.yml +14 -1
- data/config/locales/pt-BR.yml +11 -0
- data/config/locales/ru.yml +15 -1
- data/config/locales/sv-SE.yml +45 -5
- data/config/locales/uk.yml +16 -4
- data/config/locales/zh-CN.yml +5 -0
- data/config/locales/zh-TW.yml +32 -1
- data/docs/0-installation.md +7 -1
- data/docs/1-general-configuration.md +9 -0
- data/docs/10-custom-pages.md +10 -0
- data/docs/12-arbre-components.md +1 -1
- data/docs/14-gotchas.md +2 -2
- data/docs/2-resource-customization.md +5 -3
- data/docs/3-index-pages.md +7 -0
- data/docs/3-index-pages/index-as-table.md +4 -0
- data/docs/6-show-pages.md +1 -1
- data/docs/7-sidebars.md +8 -0
- data/features/index/batch_actions.feature +21 -2
- data/features/index/pagination.feature +16 -12
- data/features/meta_tags.feature +21 -0
- data/features/registering_assets.feature +1 -2
- data/features/show/columns.feature +40 -0
- data/features/show/default_content.feature +2 -1
- data/features/step_definitions/asset_steps.rb +3 -3
- data/features/step_definitions/batch_action_steps.rb +11 -2
- data/features/step_definitions/column_steps.rb +8 -0
- data/features/step_definitions/configuration_steps.rb +2 -2
- data/features/step_definitions/factory_steps.rb +3 -2
- data/features/step_definitions/meta_tag_steps.rb +3 -0
- data/features/step_definitions/pagination_steps.rb +8 -0
- data/features/step_definitions/table_steps.rb +2 -1
- data/lib/active_admin.rb +3 -3
- data/lib/active_admin/application.rb +66 -16
- data/lib/active_admin/batch_actions.rb +0 -1
- data/lib/active_admin/batch_actions/controller.rb +2 -2
- data/lib/active_admin/batch_actions/resource_extension.rb +3 -1
- data/lib/active_admin/callbacks.rb +1 -1
- data/lib/active_admin/csv_builder.rb +2 -2
- data/lib/active_admin/dependency.rb +18 -16
- data/lib/active_admin/devise.rb +1 -1
- data/lib/active_admin/dsl.rb +1 -1
- data/lib/active_admin/event.rb +8 -17
- data/lib/active_admin/filters/active.rb +29 -0
- data/lib/active_admin/filters/forms.rb +6 -1
- data/lib/active_admin/filters/humanized.rb +68 -0
- data/lib/active_admin/filters/resource_extension.rb +48 -1
- data/lib/active_admin/form_builder.rb +4 -4
- data/lib/active_admin/generators/boilerplate.rb +37 -0
- data/lib/active_admin/helpers/routes/url_helpers.rb +1 -1
- data/lib/active_admin/inputs.rb +1 -0
- data/lib/active_admin/inputs/filters/date_picker_input.rb +13 -0
- data/lib/active_admin/inputs/filters/date_range_input.rb +1 -1
- data/lib/active_admin/menu.rb +1 -0
- data/lib/active_admin/menu_item.rb +1 -1
- data/lib/active_admin/namespace.rb +5 -5
- data/lib/active_admin/orm/active_record/comments.rb +10 -1
- data/lib/active_admin/orm/active_record/comments/comment.rb +1 -1
- data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +11 -0
- data/lib/active_admin/resource.rb +9 -3
- data/lib/active_admin/resource/action_items.rb +13 -3
- data/lib/active_admin/resource/belongs_to.rb +6 -2
- data/lib/active_admin/resource/pagination.rb +4 -0
- data/lib/active_admin/resource_collection.rb +3 -1
- data/lib/active_admin/resource_controller/data_access.rb +6 -11
- data/lib/active_admin/resource_controller/decorators.rb +1 -1
- data/lib/active_admin/resource_dsl.rb +8 -2
- data/lib/active_admin/sidebar_section.rb +4 -12
- data/lib/active_admin/version.rb +1 -1
- data/lib/active_admin/view_factory.rb +1 -2
- data/lib/active_admin/view_helpers.rb +0 -1
- data/lib/active_admin/view_helpers/display_helper.rb +3 -4
- data/lib/active_admin/view_helpers/method_or_proc_helper.rb +3 -3
- data/lib/active_admin/views/components/active_admin_form.rb +3 -3
- data/lib/active_admin/views/components/columns.rb +9 -4
- data/lib/active_admin/views/components/dropdown_menu.rb +0 -2
- data/lib/active_admin/views/components/paginated_collection.rb +35 -13
- data/lib/active_admin/views/components/panel.rb +1 -3
- data/lib/active_admin/views/components/sidebar_section.rb +6 -1
- data/lib/active_admin/views/components/status_tag.rb +3 -2
- data/lib/active_admin/views/components/table_for.rb +2 -1
- data/lib/active_admin/views/index_as_table.rb +2 -2
- data/lib/active_admin/views/pages/base.rb +4 -0
- data/lib/active_admin/views/pages/show.rb +1 -1
- data/lib/generators/active_admin/assets/assets_generator.rb +1 -1
- data/lib/generators/active_admin/assets/templates/{active_admin.css.scss → active_admin.scss} +0 -0
- data/lib/generators/active_admin/devise/devise_generator.rb +7 -19
- data/lib/generators/active_admin/install/templates/active_admin.rb.erb +29 -0
- data/lib/generators/active_admin/page/templates/page.rb +1 -1
- data/lib/generators/active_admin/resource/resource_generator.rb +6 -0
- data/lib/generators/active_admin/resource/templates/admin.rb +34 -13
- data/spec/rails_helper.rb +6 -2
- data/spec/requests/memory_spec.rb +1 -3
- data/spec/support/active_admin_request_helpers.rb +27 -0
- data/spec/support/detect_rails_version.rb +1 -1
- data/spec/support/rails_template.rb +7 -0
- data/spec/unit/application_spec.rb +29 -4
- data/spec/unit/batch_actions/resource_spec.rb +5 -0
- data/spec/unit/belongs_to_spec.rb +14 -0
- data/spec/unit/comments_spec.rb +24 -2
- data/spec/unit/controller_filters_spec.rb +25 -28
- data/spec/unit/dsl_spec.rb +1 -1
- data/spec/unit/filters/humanized_spec.rb +56 -0
- data/spec/unit/filters/resource_spec.rb +1 -1
- data/spec/unit/form_builder_spec.rb +71 -11
- data/spec/unit/generators/install_spec.rb +3 -2
- data/spec/unit/pretty_format_spec.rb +15 -1
- data/spec/unit/resource_collection_spec.rb +17 -0
- data/spec/unit/resource_controller_spec.rb +2 -2
- data/spec/unit/resource_registration_spec.rb +3 -3
- data/spec/unit/resource_spec.rb +53 -2
- data/spec/unit/view_factory_spec.rb +0 -2
- data/spec/unit/view_helpers/display_name_spec.rb +6 -4
- data/spec/unit/views/components/{batch_action_popover_spec.rb → batch_action_selector_spec.rb} +9 -13
- data/spec/unit/views/components/columns_spec.rb +17 -0
- data/spec/unit/views/components/paginated_collection_spec.rb +16 -2
- data/spec/unit/views/components/panel_spec.rb +1 -5
- data/spec/unit/views/components/sidebar_section_spec.rb +21 -0
- data/spec/unit/views/components/status_tag_spec.rb +15 -1
- data/spec/unit/views/components/table_for_spec.rb +45 -0
- data/tasks/parallel_tests.rake +1 -1
- data/tasks/test.rake +4 -4
- metadata +29 -30
- data/app/assets/javascripts/active_admin/lib/popover.js.coffee +0 -68
- data/app/assets/stylesheets/active_admin/components/_popovers.scss +0 -122
- data/app/assets/stylesheets/active_admin/mixins/_icons.scss +0 -20
- data/lib/active_admin/batch_actions/views/batch_action_popover.rb +0 -28
- data/lib/active_admin/iconic.rb +0 -53
- data/lib/active_admin/iconic/icons.rb +0 -142
- data/lib/active_admin/view_helpers/icon_helper.rb +0 -12
- data/lib/active_admin/views/components/action_list_popover.rb +0 -29
- data/lib/active_admin/views/components/popover.rb +0 -27
- data/spec/javascripts/coffeescripts/jquery.aa.popover-spec.js.coffee +0 -82
- data/spec/support/integration_example_group.rb +0 -31
- data/spec/unit/event_spec.rb +0 -47
- data/spec/unit/views/components/action_list_popover_spec.rb +0 -40
- data/spec/unit/views/components/popover_spec.rb +0 -33
data/lib/active_admin/inputs.rb
CHANGED
data/lib/active_admin/menu.rb
CHANGED
@@ -79,7 +79,7 @@ module ActiveAdmin
|
|
79
79
|
true
|
80
80
|
end
|
81
81
|
|
82
|
-
# Returns an array of the
|
82
|
+
# Returns an array of the ancestry of this menu item.
|
83
83
|
# The first item is the immediate parent of the item.
|
84
84
|
def ancestors
|
85
85
|
parent ? [parent, parent.ancestors].flatten : []
|
@@ -49,7 +49,7 @@ module ActiveAdmin
|
|
49
49
|
reset_menu!
|
50
50
|
|
51
51
|
# Dispatch a registration event
|
52
|
-
|
52
|
+
ActiveSupport::Notifications.publish ActiveAdmin::Resource::RegisterEvent, config
|
53
53
|
|
54
54
|
# Return the config
|
55
55
|
config
|
@@ -110,13 +110,13 @@ module ActiveAdmin
|
|
110
110
|
# Add a callback to be ran when we build the menu
|
111
111
|
#
|
112
112
|
# @param [Symbol] name The name of the menu. Default: :default
|
113
|
-
# @
|
113
|
+
# @yield [ActiveAdmin::Menu] The block to be ran when the menu is built
|
114
114
|
#
|
115
115
|
# @return [void]
|
116
|
-
def build_menu(name = DEFAULT_MENU
|
116
|
+
def build_menu(name = DEFAULT_MENU)
|
117
117
|
@menus.before_build do |menus|
|
118
118
|
menus.menu name do |menu|
|
119
|
-
|
119
|
+
yield menu
|
120
120
|
end
|
121
121
|
end
|
122
122
|
end
|
@@ -157,7 +157,7 @@ module ActiveAdmin
|
|
157
157
|
def build_menu_collection
|
158
158
|
@menus = MenuCollection.new
|
159
159
|
|
160
|
-
@menus.on_build do
|
160
|
+
@menus.on_build do
|
161
161
|
build_default_utility_nav
|
162
162
|
|
163
163
|
resources.each do |resource|
|
@@ -7,6 +7,7 @@ require 'active_admin/orm/active_record/comments/resource_helper'
|
|
7
7
|
ActiveAdmin::Application.inheritable_setting :comments, true
|
8
8
|
ActiveAdmin::Application.inheritable_setting :show_comments_in_menu, true
|
9
9
|
ActiveAdmin::Application.inheritable_setting :comments_registration_name, 'Comment'
|
10
|
+
ActiveAdmin::Application.inheritable_setting :comments_order, "created_at ASC"
|
10
11
|
|
11
12
|
# Insert helper modules
|
12
13
|
ActiveAdmin::Namespace.send :include, ActiveAdmin::Comments::NamespaceHelper
|
@@ -20,7 +21,7 @@ ActiveAdmin.autoload :Comment, 'active_admin/orm/active_record/comments/comment'
|
|
20
21
|
ActiveAdmin.after_load do |app|
|
21
22
|
app.namespaces.each do |namespace|
|
22
23
|
namespace.register ActiveAdmin::Comment, as: namespace.comments_registration_name do
|
23
|
-
actions :index, :show, :create
|
24
|
+
actions :index, :show, :create, :destroy
|
24
25
|
|
25
26
|
menu false unless namespace.comments && namespace.show_comments_in_menu
|
26
27
|
|
@@ -60,6 +61,13 @@ ActiveAdmin.after_load do |app|
|
|
60
61
|
redirect_to :back
|
61
62
|
end
|
62
63
|
end
|
64
|
+
|
65
|
+
def destroy
|
66
|
+
destroy! do |success, failure|
|
67
|
+
success.html { redirect_to :back }
|
68
|
+
failure.html { redirect_to :back }
|
69
|
+
end
|
70
|
+
end
|
63
71
|
end
|
64
72
|
end
|
65
73
|
|
@@ -74,6 +82,7 @@ ActiveAdmin.after_load do |app|
|
|
74
82
|
column I18n.t('active_admin.comments.resource'), :resource
|
75
83
|
column I18n.t('active_admin.comments.author'), :author
|
76
84
|
column I18n.t('active_admin.comments.body'), :body
|
85
|
+
column I18n.t('active_admin.comments.created_at'), :created_at
|
77
86
|
actions
|
78
87
|
end
|
79
88
|
end
|
@@ -29,7 +29,7 @@ module ActiveAdmin
|
|
29
29
|
resource_type: resource_type(resource),
|
30
30
|
resource_id: resource_id_cast(resource),
|
31
31
|
namespace: namespace.to_s
|
32
|
-
).order(
|
32
|
+
).order(ActiveAdmin.application.namespaces[namespace.to_sym].comments_order)
|
33
33
|
end
|
34
34
|
|
35
35
|
def self.resource_id_type
|
@@ -35,6 +35,9 @@ module ActiveAdmin
|
|
35
35
|
comment.author ? auto_link(comment.author) : I18n.t('active_admin.comments.author_missing')
|
36
36
|
end
|
37
37
|
span pretty_format comment.created_at
|
38
|
+
if authorized?(ActiveAdmin::Auth::DESTROY, comment)
|
39
|
+
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') }
|
40
|
+
end
|
38
41
|
end
|
39
42
|
div class: 'active_admin_comment_body' do
|
40
43
|
simple_format comment.body
|
@@ -46,6 +49,14 @@ module ActiveAdmin
|
|
46
49
|
span I18n.t('active_admin.comments.no_comments_yet'), class: 'empty'
|
47
50
|
end
|
48
51
|
|
52
|
+
def comments_url(*args)
|
53
|
+
parts = []
|
54
|
+
parts << active_admin_namespace.name unless active_admin_namespace.root?
|
55
|
+
parts << active_admin_namespace.comments_registration_name.underscore
|
56
|
+
parts << 'path'
|
57
|
+
send parts.join('_'), *args
|
58
|
+
end
|
59
|
+
|
49
60
|
def comment_form_url
|
50
61
|
parts = []
|
51
62
|
parts << active_admin_namespace.name unless active_admin_namespace.root?
|
@@ -144,14 +144,20 @@ module ActiveAdmin
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def find_resource(id)
|
147
|
-
resource = resource_class.public_send(
|
147
|
+
resource = resource_class.public_send *method_for_find(id)
|
148
148
|
decorator_class ? decorator_class.new(resource) : resource
|
149
149
|
end
|
150
150
|
|
151
151
|
private
|
152
152
|
|
153
|
-
def method_for_find
|
154
|
-
resources_configuration[:self][:finder]
|
153
|
+
def method_for_find(id)
|
154
|
+
if finder = resources_configuration[:self][:finder]
|
155
|
+
[finder, id]
|
156
|
+
elsif Rails::VERSION::MAJOR >= 4
|
157
|
+
[:find_by, { resource_class.primary_key => id }]
|
158
|
+
else
|
159
|
+
[:"find_by_#{resource_class.primary_key}", id]
|
160
|
+
end
|
155
161
|
end
|
156
162
|
|
157
163
|
def default_csv_builder
|
@@ -55,21 +55,31 @@ module ActiveAdmin
|
|
55
55
|
|
56
56
|
# Adds the default action items to each resource
|
57
57
|
def add_default_action_items
|
58
|
-
|
58
|
+
add_default_new_action_item
|
59
|
+
add_default_edit_action_item
|
60
|
+
add_default_show_action_item
|
61
|
+
end
|
62
|
+
|
63
|
+
# Adds the default New link on index
|
64
|
+
def add_default_new_action_item
|
59
65
|
add_action_item :new, only: :index do
|
60
66
|
if controller.action_methods.include?('new') && authorized?(ActiveAdmin::Auth::CREATE, active_admin_config.resource_class)
|
61
67
|
link_to I18n.t('active_admin.new_model', model: active_admin_config.resource_label), new_resource_path
|
62
68
|
end
|
63
69
|
end
|
70
|
+
end
|
64
71
|
|
65
|
-
|
72
|
+
# Adds the default Edit link on show
|
73
|
+
def add_default_edit_action_item
|
66
74
|
add_action_item :edit, only: :show do
|
67
75
|
if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
|
68
76
|
link_to I18n.t('active_admin.edit_model', model: active_admin_config.resource_label), edit_resource_path(resource)
|
69
77
|
end
|
70
78
|
end
|
79
|
+
end
|
71
80
|
|
72
|
-
|
81
|
+
# Adds the default Destroy link on show
|
82
|
+
def add_default_show_action_item
|
73
83
|
add_action_item :destroy, only: :show do
|
74
84
|
if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
|
75
85
|
link_to I18n.t('active_admin.delete_model', model: active_admin_config.resource_label), resource_path(resource),
|
@@ -20,8 +20,12 @@ module ActiveAdmin
|
|
20
20
|
|
21
21
|
# Returns the target resource class or raises an exception if it doesn't exist
|
22
22
|
def target
|
23
|
-
|
24
|
-
|
23
|
+
resource or raise TargetNotFound.new (@options[:class_name] || @target_name.to_s.camelize), namespace
|
24
|
+
end
|
25
|
+
|
26
|
+
def resource
|
27
|
+
namespace.resources[@options[:class_name]] ||
|
28
|
+
namespace.resources[@target_name.to_s.camelize]
|
25
29
|
end
|
26
30
|
|
27
31
|
def namespace
|
@@ -6,6 +6,9 @@ module ActiveAdmin
|
|
6
6
|
# The default number of records to display per page
|
7
7
|
attr_accessor :per_page
|
8
8
|
|
9
|
+
# The default number of records to display per page
|
10
|
+
attr_accessor :max_per_page
|
11
|
+
|
9
12
|
# Enable / disable pagination (defaults to true)
|
10
13
|
attr_accessor :paginate
|
11
14
|
|
@@ -13,6 +16,7 @@ module ActiveAdmin
|
|
13
16
|
super
|
14
17
|
@paginate = true
|
15
18
|
@per_page = namespace.default_per_page
|
19
|
+
@max_per_page = namespace.max_per_page
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -33,7 +33,9 @@ module ActiveAdmin
|
|
33
33
|
# Finds a resource based on the resource name, resource class, or base class.
|
34
34
|
def find_resource(obj)
|
35
35
|
resources.detect do |r|
|
36
|
-
r.resource_name.to_s == obj.to_s
|
36
|
+
r.resource_name.to_s == obj.to_s
|
37
|
+
end || resources.detect do |r|
|
38
|
+
r.resource_class.to_s == obj.to_s
|
37
39
|
end ||
|
38
40
|
if obj.respond_to? :base_class
|
39
41
|
resources.detect{ |r| r.resource_class.to_s == obj.base_class.to_s }
|
@@ -277,14 +277,17 @@ module ActiveAdmin
|
|
277
277
|
def collection_applies(options = {})
|
278
278
|
only = Array(options.fetch(:only, COLLECTION_APPLIES))
|
279
279
|
except = Array(options.fetch(:except, []))
|
280
|
-
|
280
|
+
|
281
|
+
# see #4074 for code reasons
|
282
|
+
COLLECTION_APPLIES.select { |applier| only.include? applier }
|
283
|
+
.reject { |applier| except.include? applier }
|
281
284
|
end
|
282
285
|
|
283
286
|
def per_page
|
284
287
|
if active_admin_config.paginate
|
285
288
|
dynamic_per_page || configured_per_page
|
286
289
|
else
|
287
|
-
max_per_page
|
290
|
+
active_admin_config.max_per_page
|
288
291
|
end
|
289
292
|
end
|
290
293
|
|
@@ -293,15 +296,7 @@ module ActiveAdmin
|
|
293
296
|
end
|
294
297
|
|
295
298
|
def configured_per_page
|
296
|
-
|
297
|
-
active_admin_config.per_page[0]
|
298
|
-
else
|
299
|
-
active_admin_config.per_page
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
def max_per_page
|
304
|
-
10_000
|
299
|
+
Array(active_admin_config.per_page).first
|
305
300
|
end
|
306
301
|
|
307
302
|
end
|
@@ -68,7 +68,7 @@ module ActiveAdmin
|
|
68
68
|
::Class.new parent do
|
69
69
|
delegate :reorder, :page, :current_page, :total_pages, :limit_value,
|
70
70
|
:total_count, :num_pages, :to_key, :group_values, :except,
|
71
|
-
:find_each
|
71
|
+
:find_each, :ransack
|
72
72
|
|
73
73
|
define_singleton_method(:name) { name }
|
74
74
|
end
|
@@ -160,8 +160,14 @@ module ActiveAdmin
|
|
160
160
|
delegate :before_destroy, :after_destroy, to: :controller
|
161
161
|
|
162
162
|
# Standard rails filters
|
163
|
-
delegate :before_filter,
|
164
|
-
|
163
|
+
delegate :before_filter, :skip_before_filter, to: :controller
|
164
|
+
delegate :after_filter, :skip_after_filter, to: :controller
|
165
|
+
delegate :around_filter, :skip_filter, to: :controller
|
166
|
+
if Rails::VERSION::MAJOR == 4
|
167
|
+
delegate :before_action, :skip_before_action, to: :controller
|
168
|
+
delegate :after_action, :skip_after_action, to: :controller
|
169
|
+
delegate :around_action, :skip_action, to: :controller
|
170
|
+
end
|
165
171
|
|
166
172
|
# Specify which actions to create in the controller
|
167
173
|
#
|
@@ -6,31 +6,23 @@ module ActiveAdmin
|
|
6
6
|
attr_accessor :name, :options, :block
|
7
7
|
|
8
8
|
def initialize(name, options = {}, &block)
|
9
|
-
@name, @options, @block = name, options, block
|
9
|
+
@name, @options, @block = name.to_s, options, block
|
10
10
|
normalize_display_options!
|
11
11
|
end
|
12
12
|
|
13
13
|
# The id gets used for the div in the view
|
14
14
|
def id
|
15
|
-
"#{name.
|
16
|
-
end
|
17
|
-
|
18
|
-
def icon?
|
19
|
-
!!options[:icon]
|
20
|
-
end
|
21
|
-
|
22
|
-
def icon
|
23
|
-
options[:icon] if icon?
|
15
|
+
"#{name.downcase.underscore}_sidebar_section".parameterize
|
24
16
|
end
|
25
17
|
|
26
18
|
# The title gets displayed within the section in the view
|
27
19
|
def title
|
28
|
-
I18n.t("active_admin.sidebars.#{name
|
20
|
+
I18n.t("active_admin.sidebars.#{name}", default: name.titlecase)
|
29
21
|
end
|
30
22
|
|
31
23
|
# If a block is not passed in, the name of the partial to render
|
32
24
|
def partial_name
|
33
|
-
options[:partial] || "#{name.
|
25
|
+
options[:partial] || "#{name.downcase.tr(' ', '_')}_sidebar"
|
34
26
|
end
|
35
27
|
|
36
28
|
def custom_class
|
data/lib/active_admin/version.rb
CHANGED
@@ -13,8 +13,7 @@ module ActiveAdmin
|
|
13
13
|
header: ActiveAdmin::Views::Header,
|
14
14
|
footer: ActiveAdmin::Views::Footer,
|
15
15
|
index_scopes: ActiveAdmin::Views::Scopes,
|
16
|
-
blank_slate: ActiveAdmin::Views::BlankSlate
|
17
|
-
action_list_popover: ActiveAdmin::Views::ActionListPopover
|
16
|
+
blank_slate: ActiveAdmin::Views::BlankSlate
|
18
17
|
|
19
18
|
# Register All The Pages
|
20
19
|
register index_page: ActiveAdmin::Views::Pages::Index,
|
@@ -15,7 +15,7 @@ module ActiveAdmin
|
|
15
15
|
# Attempts to call any known display name methods on the resource.
|
16
16
|
# See the setting in `application.rb` for the list of methods and their priority.
|
17
17
|
def display_name(resource)
|
18
|
-
render_in_context resource, display_name_method_for(resource)
|
18
|
+
render_in_context resource, display_name_method_for(resource) unless resource.nil?
|
19
19
|
end
|
20
20
|
|
21
21
|
# Looks up and caches the first available display name method.
|
@@ -43,10 +43,10 @@ module ActiveAdmin
|
|
43
43
|
# Attempts to create a human-readable string for any object
|
44
44
|
def pretty_format(object)
|
45
45
|
case object
|
46
|
-
when String, Numeric, Arbre::Element
|
46
|
+
when String, Numeric, Symbol, Arbre::Element
|
47
47
|
object.to_s
|
48
48
|
when Date, Time
|
49
|
-
localize object, format:
|
49
|
+
localize object, format: active_admin_application.localize_format
|
50
50
|
else
|
51
51
|
if defined?(::ActiveRecord) && object.is_a?(ActiveRecord::Base) ||
|
52
52
|
defined?(::Mongoid) && object.class.include?(Mongoid::Document)
|
@@ -56,7 +56,6 @@ module ActiveAdmin
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
60
59
|
end
|
61
60
|
end
|
62
61
|
end
|
@@ -76,11 +76,11 @@ module MethodOrProcHelper
|
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
# This method is different from the others in that it calls `instance_exec` on the
|
80
|
-
# passing it the proc. This evaluates the proc in the context of the
|
79
|
+
# This method is different from the others in that it calls `instance_exec` on the receiver,
|
80
|
+
# passing it the proc. This evaluates the proc in the context of the receiver, thus changing
|
81
81
|
# what `self` means inside the proc.
|
82
82
|
def render_in_context(context, obj, *args)
|
83
|
-
context
|
83
|
+
context = self if context.nil? # default to `self` only when nil
|
84
84
|
case obj
|
85
85
|
when Proc
|
86
86
|
context.instance_exec *args, &obj
|