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
@@ -1,4 +1,4 @@
1
- require 'active_admin/component'
1
+ require "active_admin/component"
2
2
 
3
3
  module ActiveAdmin
4
4
  module BatchActions
@@ -31,17 +31,17 @@ module ActiveAdmin
31
31
  confirmation_text = render_or_call_method_or_proc_on(self, batch_action.confirm)
32
32
 
33
33
  options = {
34
- :class => "batch_action",
35
- "data-action" => batch_action.sym,
36
- "data-confirm" => confirmation_text,
37
- "data-inputs" => render_in_context(self, batch_action.inputs).to_json
34
+ class: "batch_action",
35
+ "data-action": batch_action.sym,
36
+ "data-confirm": confirmation_text,
37
+ "data-inputs": render_in_context(self, batch_action.inputs).to_json
38
38
  }
39
39
 
40
40
  default_title = render_or_call_method_or_proc_on(self, batch_action.title)
41
41
  title = I18n.t("active_admin.batch_actions.labels.#{batch_action.sym}", default: default_title)
42
42
  label = I18n.t("active_admin.batch_actions.action_label", title: title)
43
43
 
44
- item label, "#", options
44
+ item label, "#", **options
45
45
  end
46
46
  end
47
47
  end
@@ -1,4 +1,4 @@
1
- require 'active_admin/component'
1
+ require "active_admin/component"
2
2
 
3
3
  module ActiveAdmin
4
4
  module BatchActions
@@ -7,7 +7,7 @@ module ActiveAdmin
7
7
  class ResourceSelectionToggleCell < ActiveAdmin::Component
8
8
  builder_method :resource_selection_toggle_cell
9
9
 
10
- def build(label_text = '')
10
+ def build(label_text = "")
11
11
  label do
12
12
  input type: "checkbox", id: "collection_selection_toggle_all", name: "collection_selection_toggle_all", class: "toggle_all"
13
13
  text_node label_text if label_text.present?
@@ -30,7 +30,7 @@ module ActiveAdmin
30
30
 
31
31
  def build
32
32
  super(id: "collection_selection_toggle_panel")
33
- resource_selection_toggle_cell(I18n.t('active_admin.batch_actions.selection_toggle_explanation', default: "(Toggle Selection)"))
33
+ resource_selection_toggle_cell(I18n.t("active_admin.batch_actions.selection_toggle_explanation", default: "(Toggle Selection)"))
34
34
  end
35
35
  end
36
36
 
@@ -2,7 +2,7 @@ unless ActiveAdmin::Dependency.cancan? || ActiveAdmin::Dependency.cancancan?
2
2
  ActiveAdmin::Dependency.cancan!
3
3
  end
4
4
 
5
- require 'cancan'
5
+ require "cancan"
6
6
 
7
7
  # Add a setting to the application to configure the ability
8
8
  ActiveAdmin::Application.inheritable_setting :cancan_ability_class, "Ability"
@@ -0,0 +1,31 @@
1
+ module ActiveAdmin
2
+ # This class decorates a collection of objects delegating
3
+ # mehods to behave like an Array. It's used to decouple ActiveAdmin
4
+ # from Draper and thus being able to use PORO decorators as well.
5
+ #
6
+ # It's implementation is heavily based on the Draper::CollectionDecorator
7
+ # https://github.com/drapergem/draper/blob/aaa06bd2f1e219838b241a5534e7ca513edd1fe2/lib/draper/collection_decorator.rb
8
+ class CollectionDecorator
9
+ # @return the collection being decorated.
10
+ attr_reader :object
11
+
12
+ # @return [Class] the decorator class used to decorate each item, as set by {#initialize}.
13
+ attr_reader :decorator_class
14
+
15
+ array_methods = Array.instance_methods - Object.instance_methods
16
+ delegate :==, :as_json, *array_methods, to: :decorated_collection
17
+
18
+ def initialize(object, with:)
19
+ @object = object
20
+ @decorator_class = with
21
+ end
22
+
23
+ class << self
24
+ alias_method :decorate, :new
25
+ end
26
+
27
+ def decorated_collection
28
+ @decorated_collection ||= object.map { |item| decorator_class.new(item) }
29
+ end
30
+ end
31
+ end
@@ -42,23 +42,23 @@ module ActiveAdmin
42
42
  end
43
43
 
44
44
  def build(controller, csv)
45
- @collection = controller.send :find_collection, except: :pagination
46
- columns = exec_columns controller.view_context
47
- bom = options.delete :byte_order_mark
45
+ @collection = controller.send :find_collection, except: :pagination
46
+ columns = exec_columns controller.view_context
47
+ bom = options.delete :byte_order_mark
48
48
  column_names = options.delete(:column_names) { true }
49
- csv_options = options.except :encoding_options, :humanize_name
49
+ csv_options = options.except :encoding_options, :humanize_name
50
50
 
51
51
  csv << bom if bom
52
52
 
53
53
  if column_names
54
- csv << CSV.generate_line(columns.map { |c| encode c.name, options }, csv_options)
54
+ csv << CSV.generate_line(columns.map { |c| encode c.name, options }, **csv_options)
55
55
  end
56
56
 
57
57
  ActiveRecord::Base.uncached do
58
58
  (1..paginated_collection.total_pages).each do |page|
59
59
  paginated_collection(page).each do |resource|
60
60
  resource = controller.send :apply_decorator, resource
61
- csv << CSV.generate_line(build_row(resource, columns, options), csv_options)
61
+ csv << CSV.generate_line(build_row(resource, columns, options), **csv_options)
62
62
  end
63
63
  end
64
64
  end
@@ -81,7 +81,11 @@ module ActiveAdmin
81
81
 
82
82
  def encode(content, options)
83
83
  if options[:encoding]
84
- content.to_s.encode options[:encoding], options[:encoding_options]
84
+ if options[:encoding_options]
85
+ content.to_s.encode options[:encoding], **options[:encoding_options]
86
+ else
87
+ content.to_s.encode options[:encoding]
88
+ end
85
89
  else
86
90
  content
87
91
  end
@@ -1,27 +1,27 @@
1
1
  module ActiveAdmin
2
2
  module Dependency
3
3
  module Requirements
4
- DEVISE = '>= 4.0', '< 5'
4
+ DEVISE = ">= 4.0", "< 5"
5
5
  end
6
6
 
7
7
  # Provides a clean interface to check for gem dependencies at runtime.
8
8
  #
9
- # ActiveAdmin::Dependency.draper
10
- # => #<ActiveAdmin::Dependency::Matcher for draper 1.2.1>
9
+ # ActiveAdmin::Dependency.rails
10
+ # => #<ActiveAdmin::Dependency::Matcher for rails 6.0.3.2>
11
11
  #
12
- # ActiveAdmin::Dependency.draper?
12
+ # ActiveAdmin::Dependency.rails?
13
13
  # => true
14
14
  #
15
- # ActiveAdmin::Dependency.draper? '>= 1.5.0'
15
+ # ActiveAdmin::Dependency.rails? '>= 6.1'
16
16
  # => false
17
17
  #
18
- # ActiveAdmin::Dependency.draper? '= 1.2.1'
18
+ # ActiveAdmin::Dependency.rails? '= 6.0.3.2'
19
19
  # => true
20
20
  #
21
- # ActiveAdmin::Dependency.draper? '~> 1.2.0'
21
+ # ActiveAdmin::Dependency.rails? '~> 6.0.3'
22
22
  # => true
23
23
  #
24
- # ActiveAdmin::Dependency.rails? '>= 4.2.7', '<= 5.0.2'
24
+ # ActiveAdmin::Dependency.rails? '>= 6.0.3', '<= 6.1.0'
25
25
  # => true
26
26
  #
27
27
  # ActiveAdmin::Dependency.rails! '5'
@@ -42,9 +42,9 @@ module ActiveAdmin
42
42
  # => false
43
43
  #
44
44
  def self.method_missing(name, *args)
45
- if name[-1] == '?'
45
+ if name[-1] == "?"
46
46
  Matcher.new(name[0..-2]).match? args
47
- elsif name[-1] == '!'
47
+ elsif name[-1] == "!"
48
48
  Matcher.new(name[0..-2]).match! args
49
49
  else
50
50
  Matcher.new name.to_s
@@ -91,7 +91,7 @@ module ActiveAdmin
91
91
  end
92
92
 
93
93
  def inspect
94
- info = spec ? "#{spec.name} #{spec.version}" : '(missing)'
94
+ info = spec ? "#{spec.name} #{spec.version}" : "(missing)"
95
95
  "<ActiveAdmin::Dependency::Matcher for #{info}>"
96
96
  end
97
97
  end
@@ -1,6 +1,6 @@
1
1
  ActiveAdmin::Dependency.devise! ActiveAdmin::Dependency::Requirements::DEVISE
2
2
 
3
- require 'devise'
3
+ require "devise"
4
4
 
5
5
  module ActiveAdmin
6
6
  module Devise
@@ -9,7 +9,7 @@ module ActiveAdmin
9
9
  {
10
10
  path: ActiveAdmin.application.default_namespace || "/",
11
11
  controllers: ActiveAdmin::Devise.controllers,
12
- path_names: { sign_in: 'login', sign_out: "logout" },
12
+ path_names: { sign_in: "login", sign_out: "logout" },
13
13
  sign_out_via: [*::Devise.sign_out_via, ActiveAdmin.application.logout_link_method].uniq
14
14
  }
15
15
  end
@@ -27,14 +27,14 @@ module ActiveAdmin
27
27
  module Controller
28
28
  extend ::ActiveSupport::Concern
29
29
  included do
30
- layout 'active_admin_logged_out'
30
+ layout "active_admin_logged_out"
31
31
  helper ::ActiveAdmin::ViewHelpers
32
32
  end
33
33
 
34
34
  # Redirect to the default namespace on logout
35
35
  def root_path
36
36
  namespace = ActiveAdmin.application.default_namespace.presence
37
- root_path_method = [namespace, :root_path].compact.join('_')
37
+ root_path_method = [namespace, :root_path].compact.join("_")
38
38
 
39
39
  path = if Helpers::Routes.respond_to? root_path_method
40
40
  Helpers::Routes.send root_path_method
@@ -45,7 +45,7 @@ module ActiveAdmin
45
45
 
46
46
  # NOTE: `relative_url_root` is deprecated by Rails.
47
47
  # Remove prefix here if it is removed completely.
48
- prefix = Rails.configuration.action_controller[:relative_url_root] || ''
48
+ prefix = Rails.configuration.action_controller[:relative_url_root] || ""
49
49
  prefix + path
50
50
  end
51
51
  end
@@ -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(' ', '').underscore.to_sym
104
+ sym = title.titleize.tr(" ", "").underscore.to_sym
105
105
  else
106
106
  sym = title
107
107
  title = sym.to_s.titleize
@@ -1,5 +1,5 @@
1
- require 'active_admin/dynamic_setting'
2
- require 'active_admin/settings_node'
1
+ require "active_admin/dynamic_setting"
2
+ require "active_admin/settings_node"
3
3
 
4
4
  module ActiveAdmin
5
5
 
@@ -2,7 +2,7 @@ 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('app/admin', app.root)]
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|
@@ -14,8 +14,8 @@ module ActiveAdmin
14
14
  end
15
15
  end
16
16
 
17
- initializer 'active_admin.routes' do
18
- require 'active_admin/helpers/routes/url_helpers'
17
+ initializer "active_admin.routes" do
18
+ require "active_admin/helpers/routes/url_helpers"
19
19
  end
20
20
  end
21
21
  end
@@ -1,11 +1,11 @@
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'
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
10
- ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
10
+ ActiveAdmin::Resource.send :include, ActiveAdmin::Filters::ResourceExtension
11
11
  ActiveAdmin::ViewHelpers.send :include, ActiveAdmin::Filters::ViewHelper
@@ -1,4 +1,4 @@
1
- require 'active_admin/filters/active_filter'
1
+ require "active_admin/filters/active_filter"
2
2
 
3
3
  module ActiveAdmin
4
4
  module Filters
@@ -39,8 +39,9 @@ module ActiveAdmin
39
39
  end
40
40
 
41
41
  def predicate_name
42
- I18n.t("active_admin.filters.predicates.#{condition.predicate.name}",
43
- default: ransack_predicate_name)
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: ['formtastic', 'labels'], default: nil)
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
- ['eq', 'in'].include? condition.predicate.arel_predicate
87
+ ["eq", "in"].include? condition.predicate.arel_predicate
87
88
  end
88
89
 
89
90
  # detect related class for Ransack::Nodes::Attribute
@@ -1,11 +1,11 @@
1
- require 'active_admin/filters/active'
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 'search_status', sidebar_options
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: 'display: inline'
17
- b scope_name(current_scope), class: 'current_scope_name', style: "display: inline"
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: 'margin-bottom: 10px'
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,15 +48,15 @@ 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: 'filter_form' } }
51
+ html: { class: "filter_form" } }
52
52
  required = { html: { method: :get },
53
53
  as: :q }
54
- options = defaults.deep_merge(options).deep_merge(required)
54
+ options = defaults.deep_merge(options).deep_merge(required)
55
55
 
56
56
  form_for search, options do |f|
57
57
  filters.each do |attribute, opts|
58
- next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
59
- next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
58
+ next if opts.key?(:if) && !call_method_or_proc_on(self, opts[:if])
59
+ next if opts.key?(:unless) && call_method_or_proc_on(self, opts[:unless])
60
60
 
61
61
  filter_opts = opts.except(:if, :unless)
62
62
  filter_opts[:input_html] = instance_exec(&filter_opts[:input_html]) if filter_opts[:input_html].is_a?(Proc)
@@ -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('active_admin.filters.buttons.filter')) +
69
- link_to(I18n.t('active_admin.filters.buttons.clear'), '#', class: 'clear_filters_btn') +
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
@@ -165,7 +165,7 @@ module ActiveAdmin
165
165
 
166
166
  def filters_sidebar_section
167
167
  ActiveAdmin::SidebarSection.new :filters, only: :index, if: -> { active_admin_config.filters.any? } do
168
- active_admin_filters_form_for assigns[:search], active_admin_config.filters
168
+ active_admin_filters_form_for assigns[:search], **active_admin_config.filters
169
169
  end
170
170
  end
171
171
 
@@ -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('active_admin.cancel'), url, html_options
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
 
@@ -47,7 +47,7 @@ module ActiveAdmin
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)]
@@ -69,7 +69,7 @@ module ActiveAdmin
69
69
  def extract_custom_settings!(options)
70
70
  @heading = options.key?(:heading) ? options.delete(:heading) : default_heading
71
71
  @sortable_column = options.delete(:sortable)
72
- @sortable_start = options.delete(:sortable_start) || 0
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
75
  options
@@ -93,7 +93,7 @@ module ActiveAdmin
93
93
  contents = without_wrapper { inputs(options, &form_block) }
94
94
  contents ||= "".html_safe
95
95
 
96
- js = new_record ? js_for_has_many(options[:class], &form_block) : ''
96
+ js = new_record ? js_for_has_many(options[:class], &form_block) : ""
97
97
  contents << js
98
98
  end
99
99
 
@@ -107,19 +107,20 @@ module ActiveAdmin
107
107
  def has_many_actions(form_builder, contents)
108
108
  if form_builder.object.new_record?
109
109
  contents << template.content_tag(:li) do
110
- template.link_to I18n.t('active_admin.has_many_remove'), "#", class: 'button has_many_remove'
110
+ template.link_to I18n.t("active_admin.has_many_remove"), "#", class: "button has_many_remove"
111
111
  end
112
112
  elsif allow_destroy?(form_builder.object)
113
- form_builder.input(:_destroy, as: :boolean,
114
- wrapper_html: { class: 'has_many_delete' },
115
- label: I18n.t('active_admin.has_many_delete'))
113
+ form_builder.input(
114
+ :_destroy, as: :boolean,
115
+ wrapper_html: { class: "has_many_delete" },
116
+ label: I18n.t("active_admin.has_many_delete"))
116
117
  end
117
118
 
118
119
  if sortable_column
119
120
  form_builder.input sortable_column, as: :hidden
120
121
 
121
- contents << template.content_tag(:li, class: 'handle') do
122
- I18n.t('active_admin.move')
122
+ contents << template.content_tag(:li, class: "handle") do
123
+ I18n.t("active_admin.move")
123
124
  end
124
125
  end
125
126
 
@@ -156,27 +157,28 @@ module ActiveAdmin
156
157
 
157
158
  # Capture the ADD JS
158
159
  def js_for_has_many(class_string, &form_block)
159
- assoc_name = assoc_klass.model_name
160
- placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.gsub(/\//, '_')}_RECORD"
160
+ assoc_name = assoc_klass.model_name
161
+ placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.gsub(/\//, '_')}_RECORD"
161
162
  opts = {
162
163
  for: [assoc, assoc_klass.new],
163
164
  class: class_string,
164
165
  for_options: { child_index: placeholder }
165
166
  }
166
167
  html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
167
- text = new_record.is_a?(String) ? new_record : I18n.t('active_admin.has_many_new', model: assoc_name.human)
168
+ text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
168
169
 
169
- template.link_to text, '#', class: "button has_many_add", data: {
170
+ template.link_to text, "#", class: "button has_many_add", data: {
170
171
  html: CGI.escapeHTML(html).html_safe, placeholder: placeholder
171
172
  }
172
173
  end
173
174
 
174
175
  def wrap_div_or_li(html)
175
- template.content_tag(already_in_an_inputs_block ? :li : :div,
176
- html,
177
- class: "has_many_container #{assoc}",
178
- 'data-sortable' => sortable_column,
179
- 'data-sortable-start' => sortable_start)
176
+ template.content_tag(
177
+ already_in_an_inputs_block ? :li : :div,
178
+ html,
179
+ class: "has_many_container #{assoc}",
180
+ "data-sortable" => sortable_column,
181
+ "data-sortable-start" => sortable_start)
180
182
  end
181
183
  end
182
184
  end