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.

Files changed (149) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +120 -6
  3. data/CONTRIBUTING.md +11 -57
  4. data/README.md +2 -2
  5. data/app/assets/javascripts/active_admin/base.js +26 -18
  6. data/app/assets/stylesheets/active_admin/_header.scss +37 -3
  7. data/app/assets/stylesheets/active_admin/components/_comments.scss +2 -2
  8. data/app/assets/stylesheets/active_admin/mixins/_variables.scss +3 -0
  9. data/app/javascript/active_admin/base.js +9 -0
  10. data/app/javascript/active_admin/initializers/per-page.js +1 -1
  11. data/app/javascript/active_admin/lib/checkbox-toggler.js +3 -3
  12. data/app/javascript/active_admin/lib/dropdown-menu.js +1 -1
  13. data/app/javascript/active_admin/lib/modal-dialog.js +7 -7
  14. data/app/javascript/active_admin/lib/per-page.js +1 -1
  15. data/app/javascript/active_admin/lib/table-checkbox-toggler.js +1 -1
  16. data/app/views/layouts/active_admin_logged_out.html.erb +15 -5
  17. data/config/locales/ar.yml +6 -6
  18. data/config/locales/en-CA.yml +3 -3
  19. data/config/locales/en-GB.yml +3 -3
  20. data/config/locales/en.yml +3 -3
  21. data/config/locales/es-MX.yml +2 -1
  22. data/config/locales/es.yml +5 -5
  23. data/config/locales/fr.yml +4 -4
  24. data/config/locales/it.yml +18 -0
  25. data/config/locales/ja.yml +3 -3
  26. data/config/locales/lv.yml +2 -2
  27. data/config/locales/vi.yml +6 -5
  28. data/docs/0-installation.md +26 -2
  29. data/docs/11-decorators.md +16 -5
  30. data/docs/2-resource-customization.md +10 -1
  31. data/docs/3-index-pages.md +1 -1
  32. data/docs/9-batch-actions.md +2 -2
  33. data/docs/Gemfile +2 -2
  34. data/docs/Gemfile.lock +93 -84
  35. data/docs/_includes/top-menu.html +1 -1
  36. data/docs/documentation.md +1 -1
  37. data/docs/index.html +6 -6
  38. data/lib/active_admin.rb +60 -60
  39. data/lib/active_admin/application.rb +13 -13
  40. data/lib/active_admin/application_settings.rb +3 -3
  41. data/lib/active_admin/authorization_adapter.rb +3 -3
  42. data/lib/active_admin/base_controller.rb +4 -4
  43. data/lib/active_admin/base_controller/authorization.rb +13 -12
  44. data/lib/active_admin/batch_actions/controller.rb +3 -3
  45. data/lib/active_admin/batch_actions/resource_extension.rb +9 -8
  46. data/lib/active_admin/batch_actions/views/batch_action_form.rb +3 -3
  47. data/lib/active_admin/batch_actions/views/batch_action_selector.rb +6 -6
  48. data/lib/active_admin/batch_actions/views/selection_cells.rb +3 -3
  49. data/lib/active_admin/cancan_adapter.rb +1 -1
  50. data/lib/active_admin/collection_decorator.rb +31 -0
  51. data/lib/active_admin/csv_builder.rb +11 -7
  52. data/lib/active_admin/dependency.rb +11 -11
  53. data/lib/active_admin/devise.rb +5 -5
  54. data/lib/active_admin/dsl.rb +1 -1
  55. data/lib/active_admin/dynamic_settings_node.rb +2 -2
  56. data/lib/active_admin/engine.rb +3 -3
  57. data/lib/active_admin/filters.rb +7 -7
  58. data/lib/active_admin/filters/active.rb +1 -1
  59. data/lib/active_admin/filters/active_filter.rb +5 -4
  60. data/lib/active_admin/filters/active_sidebar.rb +5 -5
  61. data/lib/active_admin/filters/forms.rb +6 -6
  62. data/lib/active_admin/filters/formtastic_addons.rb +1 -6
  63. data/lib/active_admin/filters/resource_extension.rb +1 -1
  64. data/lib/active_admin/form_builder.rb +21 -19
  65. data/lib/active_admin/generators/boilerplate.rb +1 -1
  66. data/lib/active_admin/helpers/optional_display.rb +2 -2
  67. data/lib/active_admin/inputs/datepicker_input.rb +1 -1
  68. data/lib/active_admin/inputs/filters/base.rb +1 -1
  69. data/lib/active_admin/inputs/filters/base/search_method_select.rb +4 -4
  70. data/lib/active_admin/inputs/filters/boolean_input.rb +1 -1
  71. data/lib/active_admin/inputs/filters/check_boxes_input.rb +1 -1
  72. data/lib/active_admin/inputs/filters/date_range_input.rb +12 -9
  73. data/lib/active_admin/inputs/filters/select_input.rb +2 -2
  74. data/lib/active_admin/localizers.rb +1 -1
  75. data/lib/active_admin/localizers/resource_localizer.rb +3 -3
  76. data/lib/active_admin/menu.rb +6 -3
  77. data/lib/active_admin/menu_item.rb +7 -7
  78. data/lib/active_admin/namespace.rb +12 -12
  79. data/lib/active_admin/namespace_settings.rb +8 -5
  80. data/lib/active_admin/order_clause.rb +1 -1
  81. data/lib/active_admin/orm/active_record.rb +1 -1
  82. data/lib/active_admin/orm/active_record/comments.rb +19 -19
  83. data/lib/active_admin/orm/active_record/comments/comment.rb +3 -3
  84. data/lib/active_admin/orm/active_record/comments/views.rb +2 -2
  85. data/lib/active_admin/orm/active_record/comments/views/active_admin_comments.rb +19 -19
  86. data/lib/active_admin/page.rb +1 -1
  87. data/lib/active_admin/pundit_adapter.rb +5 -5
  88. data/lib/active_admin/resource.rb +17 -17
  89. data/lib/active_admin/resource/action_items.rb +5 -5
  90. data/lib/active_admin/resource/attributes.rb +1 -1
  91. data/lib/active_admin/resource/belongs_to.rb +2 -2
  92. data/lib/active_admin/resource/controllers.rb +1 -1
  93. data/lib/active_admin/resource/menu.rb +4 -4
  94. data/lib/active_admin/resource/naming.rb +5 -5
  95. data/lib/active_admin/resource/routes.rb +5 -5
  96. data/lib/active_admin/resource/scope_to.rb +7 -7
  97. data/lib/active_admin/resource/sidebars.rb +1 -1
  98. data/lib/active_admin/resource_controller.rb +12 -11
  99. data/lib/active_admin/resource_controller/data_access.rb +1 -1
  100. data/lib/active_admin/resource_controller/decorators.rb +6 -26
  101. data/lib/active_admin/resource_controller/streaming.rb +7 -6
  102. data/lib/active_admin/resource_dsl.rb +5 -5
  103. data/lib/active_admin/scope.rb +6 -6
  104. data/lib/active_admin/version.rb +1 -1
  105. data/lib/active_admin/view_factory.rb +17 -17
  106. data/lib/active_admin/view_helpers.rb +1 -1
  107. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +3 -3
  108. data/lib/active_admin/view_helpers/display_helper.rb +5 -5
  109. data/lib/active_admin/view_helpers/download_format_links_helper.rb +1 -1
  110. data/lib/active_admin/view_helpers/fields_for.rb +2 -2
  111. data/lib/active_admin/views.rb +1 -1
  112. data/lib/active_admin/views/components/active_admin_form.rb +5 -5
  113. data/lib/active_admin/views/components/attributes_table.rb +5 -5
  114. data/lib/active_admin/views/components/blank_slate.rb +1 -1
  115. data/lib/active_admin/views/components/dropdown_menu.rb +8 -8
  116. data/lib/active_admin/views/components/index_list.rb +3 -3
  117. data/lib/active_admin/views/components/menu.rb +1 -1
  118. data/lib/active_admin/views/components/menu_item.rb +4 -4
  119. data/lib/active_admin/views/components/paginated_collection.rb +18 -18
  120. data/lib/active_admin/views/components/panel.rb +1 -1
  121. data/lib/active_admin/views/components/scopes.rb +7 -5
  122. data/lib/active_admin/views/components/site_title.rb +1 -1
  123. data/lib/active_admin/views/components/status_tag.rb +11 -11
  124. data/lib/active_admin/views/components/table_for.rb +17 -17
  125. data/lib/active_admin/views/components/tabs.rb +3 -3
  126. data/lib/active_admin/views/footer.rb +2 -1
  127. data/lib/active_admin/views/header.rb +2 -2
  128. data/lib/active_admin/views/index_as_blog.rb +1 -1
  129. data/lib/active_admin/views/index_as_grid.rb +1 -1
  130. data/lib/active_admin/views/index_as_table.rb +16 -16
  131. data/lib/active_admin/views/pages/base.rb +14 -10
  132. data/lib/active_admin/views/pages/index.rb +14 -13
  133. data/lib/active_admin/views/tabbed_navigation.rb +2 -2
  134. data/lib/active_admin/views/title_bar.rb +1 -1
  135. data/lib/activeadmin.rb +1 -1
  136. data/lib/generators/active_admin/assets/assets_generator.rb +2 -2
  137. data/lib/generators/active_admin/assets/templates/active_admin.scss +2 -2
  138. data/lib/generators/active_admin/devise/devise_generator.rb +5 -5
  139. data/lib/generators/active_admin/install/install_generator.rb +14 -8
  140. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +9 -2
  141. data/lib/generators/active_admin/page/page_generator.rb +1 -1
  142. data/lib/generators/active_admin/resource/resource_generator.rb +3 -3
  143. data/lib/generators/active_admin/webpacker/plugins/jquery.js +7 -0
  144. data/lib/generators/active_admin/webpacker/templates/active_admin.js +5 -0
  145. data/lib/generators/active_admin/webpacker/templates/active_admin.scss +17 -0
  146. data/lib/generators/active_admin/webpacker/templates/print.scss +2 -0
  147. data/lib/generators/active_admin/webpacker/webpacker_generator.rb +26 -0
  148. data/lib/ransack_ext.rb +8 -8
  149. metadata +20 -8
@@ -65,7 +65,7 @@ module ActiveAdmin
65
65
  end
66
66
 
67
67
  def controller_name
68
- [namespace.module_name, camelized_resource_name + "Controller"].compact.join('::')
68
+ [namespace.module_name, camelized_resource_name + "Controller"].compact.join("::")
69
69
  end
70
70
 
71
71
  # Override from `ActiveAdmin::Resource::Controllers`
@@ -1,6 +1,6 @@
1
1
  ActiveAdmin::Dependency.pundit!
2
2
 
3
- require 'pundit'
3
+ require "pundit"
4
4
 
5
5
  # Add a setting to the application to configure the pundit default policy
6
6
  ActiveAdmin::Application.inheritable_setting :pundit_default_policy, nil
@@ -31,7 +31,7 @@ module ActiveAdmin
31
31
 
32
32
  def retrieve_policy(subject)
33
33
  case subject
34
- when nil then Pundit.policy!(user, namespace(resource))
34
+ when nil then Pundit.policy!(user, namespace(resource))
35
35
  when Class then Pundit.policy!(user, namespace(subject.new))
36
36
  else Pundit.policy!(user, namespace(subject))
37
37
  end
@@ -46,9 +46,9 @@ module ActiveAdmin
46
46
  def format_action(action, subject)
47
47
  # https://github.com/varvet/pundit/blob/master/lib/generators/pundit/install/templates/application_policy.rb
48
48
  case action
49
- when Auth::CREATE then :create?
50
- when Auth::UPDATE then :update?
51
- when Auth::READ then subject.is_a?(Class) ? :index? : :show?
49
+ when Auth::CREATE then :create?
50
+ when Auth::UPDATE then :update?
51
+ when Auth::READ then subject.is_a?(Class) ? :index? : :show?
52
52
  when Auth::DESTROY then subject.is_a?(Class) ? :destroy_all? : :destroy?
53
53
  else "#{action}?"
54
54
  end
@@ -1,18 +1,18 @@
1
- require 'active_admin/resource/action_items'
2
- require 'active_admin/resource/attributes'
3
- require 'active_admin/resource/controllers'
4
- require 'active_admin/resource/menu'
5
- require 'active_admin/resource/page_presenters'
6
- require 'active_admin/resource/pagination'
7
- require 'active_admin/resource/routes'
8
- require 'active_admin/resource/naming'
9
- require 'active_admin/resource/scopes'
10
- require 'active_admin/resource/includes'
11
- require 'active_admin/resource/scope_to'
12
- require 'active_admin/resource/sidebars'
13
- require 'active_admin/resource/belongs_to'
14
- require 'active_admin/resource/ordering'
15
- require 'active_admin/resource/model'
1
+ require "active_admin/resource/action_items"
2
+ require "active_admin/resource/attributes"
3
+ require "active_admin/resource/controllers"
4
+ require "active_admin/resource/menu"
5
+ require "active_admin/resource/page_presenters"
6
+ require "active_admin/resource/pagination"
7
+ require "active_admin/resource/routes"
8
+ require "active_admin/resource/naming"
9
+ require "active_admin/resource/scopes"
10
+ require "active_admin/resource/includes"
11
+ require "active_admin/resource/scope_to"
12
+ require "active_admin/resource/sidebars"
13
+ require "active_admin/resource/belongs_to"
14
+ require "active_admin/resource/ordering"
15
+ require "active_admin/resource/model"
16
16
 
17
17
  module ActiveAdmin
18
18
 
@@ -27,7 +27,7 @@ module ActiveAdmin
27
27
  class Resource
28
28
 
29
29
  # Event dispatched when a new resource is registered
30
- RegisterEvent = 'active_admin.resource.register'.freeze
30
+ RegisterEvent = "active_admin.resource.register".freeze
31
31
 
32
32
  # The namespace this config belongs to
33
33
  attr_reader :namespace
@@ -44,7 +44,7 @@ module ActiveAdmin
44
44
  # The default sort order to use in the controller
45
45
  attr_writer :sort_order
46
46
  def sort_order
47
- @sort_order ||= (resource_class.respond_to?(:primary_key) ? resource_class.primary_key.to_s : 'id') + '_desc'
47
+ @sort_order ||= (resource_class.respond_to?(:primary_key) ? resource_class.primary_key.to_s : "id") + "_desc"
48
48
  end
49
49
 
50
50
  # Set the configuration for the CSV
@@ -1,4 +1,4 @@
1
- require 'active_admin/helpers/optional_display'
1
+ require "active_admin/helpers/optional_display"
2
2
 
3
3
  module ActiveAdmin
4
4
 
@@ -64,7 +64,7 @@ module ActiveAdmin
64
64
  # Adds the default New link on index
65
65
  def add_default_new_action_item
66
66
  add_action_item :new, only: :index do
67
- if controller.action_methods.include?('new') && authorized?(ActiveAdmin::Auth::CREATE, active_admin_config.resource_class)
67
+ if controller.action_methods.include?("new") && authorized?(ActiveAdmin::Auth::CREATE, active_admin_config.resource_class)
68
68
  localizer = ActiveAdmin::Localizers.resource(active_admin_config)
69
69
  link_to localizer.t(:new_model), new_resource_path
70
70
  end
@@ -74,7 +74,7 @@ module ActiveAdmin
74
74
  # Adds the default Edit link on show
75
75
  def add_default_edit_action_item
76
76
  add_action_item :edit, only: :show do
77
- if controller.action_methods.include?('edit') && authorized?(ActiveAdmin::Auth::UPDATE, resource)
77
+ if controller.action_methods.include?("edit") && authorized?(ActiveAdmin::Auth::UPDATE, resource)
78
78
  localizer = ActiveAdmin::Localizers.resource(active_admin_config)
79
79
  link_to localizer.t(:edit_model), edit_resource_path(resource)
80
80
  end
@@ -84,10 +84,10 @@ module ActiveAdmin
84
84
  # Adds the default Destroy link on show
85
85
  def add_default_show_action_item
86
86
  add_action_item :destroy, only: :show do
87
- if controller.action_methods.include?('destroy') && authorized?(ActiveAdmin::Auth::DESTROY, resource)
87
+ if controller.action_methods.include?("destroy") && authorized?(ActiveAdmin::Auth::DESTROY, resource)
88
88
  localizer = ActiveAdmin::Localizers.resource(active_admin_config)
89
89
  link_to localizer.t(:delete_model), resource_path(resource), method: :delete,
90
- data: { confirm: localizer.t(:delete_confirmation) }
90
+ data: { confirm: localizer.t(:delete_confirmation) }
91
91
  end
92
92
  end
93
93
  end
@@ -36,7 +36,7 @@ module ActiveAdmin
36
36
  end
37
37
 
38
38
  def counter_cache_col?(c)
39
- c.name.end_with?('_count')
39
+ c.name.end_with?("_count")
40
40
  end
41
41
 
42
42
  def filtered_col?(c)
@@ -1,4 +1,4 @@
1
- require 'active_admin/resource'
1
+ require "active_admin/resource"
2
2
 
3
3
  module ActiveAdmin
4
4
  class Resource
@@ -46,7 +46,7 @@ module ActiveAdmin
46
46
  end
47
47
 
48
48
  def to_param
49
- :"#{@target_name}_id"
49
+ (@options[:param] || "#{@target_name}_id").to_sym
50
50
  end
51
51
  end
52
52
  end
@@ -6,7 +6,7 @@ module ActiveAdmin
6
6
  # Returns a properly formatted controller name for this
7
7
  # config within its namespace
8
8
  def controller_name
9
- [namespace.module_name, resource_name.plural.camelize + "Controller"].compact.join('::')
9
+ [namespace.module_name, resource_name.plural.camelize + "Controller"].compact.join("::")
10
10
  end
11
11
 
12
12
  # Returns the controller for this config
@@ -7,12 +7,12 @@ module ActiveAdmin
7
7
  # To disable this menu item, call `menu(false)` from the DSL
8
8
  def menu_item_options=(options)
9
9
  if options == false
10
- @include_in_menu = false
10
+ @include_in_menu = false
11
11
  @menu_item_options = {}
12
12
  else
13
13
  @include_in_menu = true
14
14
  @navigation_menu_name = options[:menu_name]
15
- @menu_item_options = default_menu_options.merge options
15
+ @menu_item_options = default_menu_options.merge options
16
16
  end
17
17
  end
18
18
 
@@ -27,8 +27,8 @@ module ActiveAdmin
27
27
  {
28
28
  id: resource_name.plural,
29
29
  label: proc { resource.plural_resource_label },
30
- url: proc { resource.route_collection_path(params, url_options) },
31
- if: proc { authorized?(Auth::READ, menu_resource_class) }
30
+ url: proc { resource.route_collection_path(params, url_options) },
31
+ if: proc { authorized?(Auth::READ, menu_resource_class) }
32
32
  }
33
33
  end
34
34
 
@@ -4,7 +4,7 @@ module ActiveAdmin
4
4
  module Naming
5
5
  def resource_name
6
6
  @resource_name ||= begin
7
- as = @options[:as].gsub /\s/, '' if @options[:as]
7
+ as = @options[:as].gsub /\s/, "" if @options[:as]
8
8
 
9
9
  if as || !resource_class.respond_to?(:model_name)
10
10
  Name.new resource_class, as
@@ -17,13 +17,13 @@ module ActiveAdmin
17
17
  # Returns the name to call this resource such as "Bank Account"
18
18
  def resource_label
19
19
  resource_name.translate count: 1,
20
- default: resource_name.to_s.gsub('::', ' ').titleize
20
+ default: resource_name.to_s.gsub("::", " ").titleize
21
21
  end
22
22
 
23
23
  # Returns the plural version of this resource such as "Bank Accounts"
24
24
  def plural_resource_label(options = {})
25
- defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,
26
- default: resource_label.pluralize.titleize }
25
+ defaults = { count: Helpers::I18n::PLURAL_MANY_COUNT,
26
+ default: resource_label.pluralize.titleize }
27
27
  resource_name.translate defaults.merge options
28
28
  end
29
29
 
@@ -46,7 +46,7 @@ module ActiveAdmin
46
46
  end
47
47
 
48
48
  def translate(options = {})
49
- I18n.t i18n_key, { scope: [:activerecord, :models] }.merge(options)
49
+ I18n.t i18n_key, **{ scope: [:activerecord, :models] }.merge(options)
50
50
  end
51
51
 
52
52
  def route_key
@@ -98,13 +98,13 @@ module ActiveAdmin
98
98
  suffix = options[:suffix] || "path"
99
99
  route = []
100
100
 
101
- route << options[:action] # "batch_action", "edit" or "new"
102
- route << resource.route_prefix # "admin"
101
+ route << options[:action] # "batch_action", "edit" or "new"
102
+ route << resource.route_prefix # "admin"
103
103
  route << belongs_to_name if nested? # "category"
104
- route << resource_path_name # "posts" or "post"
105
- route << suffix # "path" or "index path"
104
+ route << resource_path_name # "posts" or "post"
105
+ route << suffix # "path" or "index path"
106
106
 
107
- route.compact.join('_').to_sym # :admin_category_posts_path
107
+ route.compact.join("_").to_sym # :admin_category_posts_path
108
108
  end
109
109
 
110
110
  # @return params to pass to instance path
@@ -38,10 +38,10 @@ module ActiveAdmin
38
38
  options = args.extract_options!
39
39
  method = args.first
40
40
 
41
- scope_to_config[:method] = block || method
42
- scope_to_config[:association_method] = options[:association_method]
43
- scope_to_config[:if] = options[:if]
44
- scope_to_config[:unless] = options[:unless]
41
+ scope_to_config[:method] = block || method
42
+ scope_to_config[:association_method] = options[:association_method]
43
+ scope_to_config[:if] = options[:if]
44
+ scope_to_config[:unless] = options[:unless]
45
45
 
46
46
  end
47
47
 
@@ -55,10 +55,10 @@ module ActiveAdmin
55
55
 
56
56
  def scope_to_config
57
57
  @scope_to_config ||= {
58
- method: nil,
58
+ method: nil,
59
59
  association_method: nil,
60
- if: nil,
61
- unless: nil
60
+ if: nil,
61
+ unless: nil
62
62
  }
63
63
  end
64
64
 
@@ -1,4 +1,4 @@
1
- require 'active_admin/helpers/optional_display'
1
+ require "active_admin/helpers/optional_display"
2
2
 
3
3
  module ActiveAdmin
4
4
 
@@ -1,11 +1,12 @@
1
- require 'active_admin/resource_controller/action_builder'
2
- require 'active_admin/resource_controller/data_access'
3
- require 'active_admin/resource_controller/decorators'
4
- require 'active_admin/resource_controller/polymorphic_routes'
5
- require 'active_admin/resource_controller/scoping'
6
- require 'active_admin/resource_controller/streaming'
7
- require 'active_admin/resource_controller/sidebars'
8
- require 'active_admin/resource_controller/resource_class_methods'
1
+ require "active_admin/collection_decorator"
2
+ require "active_admin/resource_controller/action_builder"
3
+ require "active_admin/resource_controller/data_access"
4
+ require "active_admin/resource_controller/decorators"
5
+ require "active_admin/resource_controller/polymorphic_routes"
6
+ require "active_admin/resource_controller/scoping"
7
+ require "active_admin/resource_controller/streaming"
8
+ require "active_admin/resource_controller/sidebars"
9
+ require "active_admin/resource_controller/resource_class_methods"
9
10
 
10
11
  module ActiveAdmin
11
12
  # All Resources Controller inherits from this controller.
@@ -24,13 +25,13 @@ module ActiveAdmin
24
25
  include Streaming
25
26
  include Sidebars
26
27
  include ViewHelpers::DownloadFormatLinksHelper
27
- extend ResourceClassMethods
28
+ extend ResourceClassMethods
28
29
 
29
30
  def self.active_admin_config=(config)
30
31
  if @active_admin_config = config
31
32
  defaults resource_class: config.resource_class,
32
- route_prefix: config.route_prefix,
33
- instance_name: config.resource_name.singular
33
+ route_prefix: config.route_prefix,
34
+ instance_name: config.resource_name.singular
34
35
  end
35
36
  end
36
37
 
@@ -258,7 +258,7 @@ module ActiveAdmin
258
258
  end
259
259
 
260
260
  def collection_applies(options = {})
261
- only = Array(options.fetch(:only, COLLECTION_APPLIES))
261
+ only = Array(options.fetch(:only, COLLECTION_APPLIES))
262
262
  except = Array(options.fetch(:except, []))
263
263
 
264
264
  COLLECTION_APPLIES & only - except
@@ -28,7 +28,7 @@ module ActiveAdmin
28
28
 
29
29
  def decorate?
30
30
  case action_name
31
- when 'new', 'edit', 'create', 'update'
31
+ when "new", "edit", "create", "update"
32
32
  form = active_admin_config.get_page_presenter :form
33
33
  form && form.options[:decorate] && decorator_class.present?
34
34
  else
@@ -53,13 +53,8 @@ module ActiveAdmin
53
53
 
54
54
  def self.wrap(decorator)
55
55
  collection_decorator = find_collection_decorator(decorator)
56
-
57
- if draper_collection_decorator? collection_decorator
58
- name = "#{collection_decorator.name} of #{decorator} + ActiveAdmin"
59
- @cache[name] ||= wrap! collection_decorator, name
60
- else
61
- collection_decorator
62
- end
56
+ name = "#{collection_decorator.name} of #{decorator} + ActiveAdmin"
57
+ @cache[name] ||= wrap! collection_decorator, name
63
58
  end
64
59
 
65
60
  private
@@ -68,34 +63,19 @@ module ActiveAdmin
68
63
  ::Class.new parent do
69
64
  delegate :reorder, :page, :current_page, :total_pages, :limit_value,
70
65
  :total_count, :total_pages, :offset, :to_key, :group_values,
71
- :except, :find_each, :ransack
66
+ :except, :find_each, :ransack, to: :object
72
67
 
73
68
  define_singleton_method(:name) { name }
74
69
  end
75
70
  end
76
71
 
77
- # Draper::CollectionDecorator was introduced in 1.0.0
78
- # Draper::Decorator#collection_decorator_class was introduced in 1.3.0
79
72
  def self.find_collection_decorator(decorator)
80
- if Dependency.draper? '>= 1.3.0'
73
+ if decorator.respond_to?(:collection_decorator_class)
81
74
  decorator.collection_decorator_class
82
- elsif Dependency.draper? '>= 1.0.0'
83
- draper_collection_decorator
84
75
  else
85
- decorator
76
+ CollectionDecorator
86
77
  end
87
78
  end
88
-
89
- def self.draper_collection_decorator?(decorator)
90
- decorator && decorator <= draper_collection_decorator
91
- rescue NameError
92
- false
93
- end
94
-
95
- def self.draper_collection_decorator
96
- ::Draper::CollectionDecorator
97
- end
98
-
99
79
  end
100
80
  end
101
81
  end
@@ -1,4 +1,4 @@
1
- require 'csv'
1
+ require "csv"
2
2
 
3
3
  module ActiveAdmin
4
4
  class ResourceController < BaseController
@@ -18,11 +18,12 @@ module ActiveAdmin
18
18
  protected
19
19
 
20
20
  def stream_resource(&block)
21
- headers['X-Accel-Buffering'] = 'no'
22
- headers['Cache-Control'] = 'no-cache'
21
+ headers["X-Accel-Buffering"] = "no"
22
+ headers["Cache-Control"] = "no-cache"
23
+ headers["Last-Modified"] = Time.current.httpdate
23
24
 
24
25
  if ActiveAdmin.application.disable_streaming_in.include? Rails.env
25
- self.response_body = block['']
26
+ self.response_body = block[""]
26
27
  else
27
28
  self.response_body = Enumerator.new &block
28
29
  end
@@ -33,8 +34,8 @@ module ActiveAdmin
33
34
  end
34
35
 
35
36
  def stream_csv
36
- headers['Content-Type'] = 'text/csv; charset=utf-8' # In Rails 5 it's set to HTML??
37
- headers['Content-Disposition'] = %{attachment; filename="#{csv_filename}"}
37
+ headers["Content-Type"] = "text/csv; charset=utf-8" # In Rails 5 it's set to HTML??
38
+ headers["Content-Disposition"] = %{attachment; filename="#{csv_filename}"}
38
39
  stream_resource &active_admin_config.csv_builder.method(:build).to_proc.curry[self]
39
40
  end
40
41
 
@@ -183,16 +183,16 @@ module ActiveAdmin
183
183
  # == Before / After Destroy
184
184
  # Called before and after the object is destroyed from the database.
185
185
  #
186
- delegate :before_build, :after_build, to: :controller
187
- delegate :before_create, :after_create, to: :controller
188
- delegate :before_update, :after_update, to: :controller
189
- delegate :before_save, :after_save, to: :controller
186
+ delegate :before_build, :after_build, to: :controller
187
+ delegate :before_create, :after_create, to: :controller
188
+ delegate :before_update, :after_update, to: :controller
189
+ delegate :before_save, :after_save, to: :controller
190
190
  delegate :before_destroy, :after_destroy, to: :controller
191
191
 
192
192
  # This code defines both *_filter and *_action for Rails 5.0 and *_action for Rails >= 5.1
193
193
  phases = [
194
194
  :before, :skip_before,
195
- :after, :skip_after,
195
+ :after, :skip_after,
196
196
  :around, :skip
197
197
  ]
198
198
  keywords = if Rails::VERSION::MAJOR == 5 && Rails::VERSION::MINOR >= 1
@@ -45,17 +45,17 @@ module ActiveAdmin
45
45
  @scope_block = block
46
46
  end
47
47
 
48
- @localizer = options[:localizer]
49
- @show_count = options.fetch(:show_count, true)
50
- @display_if_block = options[:if] || proc { true }
51
- @default_block = options[:default] || proc { false }
52
- @group = options[:group].try(:to_sym)
48
+ @localizer = options[:localizer]
49
+ @show_count = options.fetch(:show_count, true)
50
+ @display_if_block = options[:if] || proc { true }
51
+ @default_block = options[:default] || proc { false }
52
+ @group = options[:group].try(:to_sym)
53
53
  end
54
54
 
55
55
  def name
56
56
  case @name
57
57
  when String then @name
58
- when Symbol then @localizer ? @localizer.t(@name, scope: 'scopes') : @name.to_s.titleize
58
+ when Symbol then @localizer ? @localizer.t(@name, scope: "scopes") : @name.to_s.titleize
59
59
  else @name
60
60
  end
61
61
  end