activeadmin 2.0.0 → 2.4.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.
Files changed (100) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -6
  3. data/CONTRIBUTING.md +3 -5
  4. data/README.md +8 -1
  5. data/app/assets/javascripts/active_admin/lib/batch_actions.es6 +5 -1
  6. data/app/views/kaminari/active_admin_countless/_first_page.html.erb +11 -0
  7. data/app/views/kaminari/active_admin_countless/_gap.html.erb +8 -0
  8. data/app/views/kaminari/active_admin_countless/_next_page.html.erb +11 -0
  9. data/app/views/kaminari/active_admin_countless/_page.html.erb +12 -0
  10. data/app/views/kaminari/active_admin_countless/_paginator.html.erb +24 -0
  11. data/app/views/kaminari/active_admin_countless/_prev_page.html.erb +11 -0
  12. data/config/locales/ar.yml +3 -2
  13. data/config/locales/bg.yml +1 -0
  14. data/config/locales/bs.yml +1 -0
  15. data/config/locales/ca.yml +1 -1
  16. data/config/locales/cs.yml +1 -0
  17. data/config/locales/da.yml +1 -0
  18. data/config/locales/de-CH.yml +1 -0
  19. data/config/locales/de.yml +19 -0
  20. data/config/locales/el.yml +1 -0
  21. data/config/locales/en-CA.yml +1 -0
  22. data/config/locales/en-GB.yml +1 -0
  23. data/config/locales/en.yml +1 -0
  24. data/config/locales/eo.yml +1 -0
  25. data/config/locales/es-MX.yml +1 -0
  26. data/config/locales/es.yml +1 -0
  27. data/config/locales/fa.yml +1 -0
  28. data/config/locales/fi.yml +1 -0
  29. data/config/locales/fr.yml +2 -1
  30. data/config/locales/he.yml +1 -0
  31. data/config/locales/hr.yml +1 -0
  32. data/config/locales/hu.yml +1 -0
  33. data/config/locales/id.yml +1 -0
  34. data/config/locales/it.yml +1 -0
  35. data/config/locales/ja.yml +1 -0
  36. data/config/locales/ko.yml +1 -0
  37. data/config/locales/lt.yml +1 -0
  38. data/config/locales/lv.yml +1 -0
  39. data/config/locales/mk.yml +134 -0
  40. data/config/locales/nb.yml +1 -0
  41. data/config/locales/nl.yml +1 -0
  42. data/config/locales/pl.yml +1 -0
  43. data/config/locales/pt-BR.yml +1 -0
  44. data/config/locales/pt-PT.yml +1 -0
  45. data/config/locales/ro.yml +1 -0
  46. data/config/locales/ru.yml +1 -0
  47. data/config/locales/sk.yml +60 -0
  48. data/config/locales/sv-SE.yml +1 -0
  49. data/config/locales/tr.yml +1 -0
  50. data/config/locales/uk.yml +1 -0
  51. data/config/locales/vi.yml +1 -0
  52. data/config/locales/zh-CN.yml +1 -0
  53. data/config/locales/zh-TW.yml +1 -0
  54. data/docs/12-arbre-components.md +13 -0
  55. data/docs/13-authorization-adapter.md +2 -2
  56. data/docs/2-resource-customization.md +1 -1
  57. data/docs/3-index-pages/index-as-table.md +7 -0
  58. data/docs/Gemfile +0 -1
  59. data/docs/Gemfile.lock +4 -5
  60. data/docs/_config.yml +2 -0
  61. data/docs/_includes/top-menu.html +2 -2
  62. data/docs/index.html +108 -7
  63. data/docs/stylesheets/main.css +29 -0
  64. data/lib/active_admin.rb +1 -0
  65. data/lib/active_admin/application.rb +3 -4
  66. data/lib/active_admin/base_controller/authorization.rb +1 -0
  67. data/lib/active_admin/batch_actions/resource_extension.rb +5 -1
  68. data/lib/active_admin/controller_action.rb +2 -1
  69. data/lib/active_admin/csv_builder.rb +3 -2
  70. data/lib/active_admin/dependency.rb +0 -4
  71. data/lib/active_admin/error.rb +3 -1
  72. data/lib/active_admin/filters/active_filter.rb +2 -3
  73. data/lib/active_admin/filters/resource_extension.rb +24 -0
  74. data/lib/active_admin/generators/boilerplate.rb +12 -4
  75. data/lib/active_admin/namespace_settings.rb +13 -0
  76. data/lib/active_admin/order_clause.rb +1 -1
  77. data/lib/active_admin/page_presenter.rb +2 -1
  78. data/lib/active_admin/pundit_adapter.rb +7 -3
  79. data/lib/active_admin/resource.rb +15 -1
  80. data/lib/active_admin/resource/belongs_to.rb +6 -1
  81. data/lib/active_admin/resource/model.rb +15 -0
  82. data/lib/active_admin/resource/routes.rb +11 -3
  83. data/lib/active_admin/resource_controller.rb +2 -0
  84. data/lib/active_admin/resource_controller/decorators.rb +2 -2
  85. data/lib/active_admin/resource_controller/polymorphic_routes.rb +36 -0
  86. data/lib/active_admin/resource_dsl.rb +1 -1
  87. data/lib/active_admin/router.rb +2 -1
  88. data/lib/active_admin/scope.rb +7 -3
  89. data/lib/active_admin/sidebar_section.rb +3 -1
  90. data/lib/active_admin/version.rb +1 -1
  91. data/lib/active_admin/view_helpers/breadcrumb_helper.rb +2 -2
  92. data/lib/active_admin/view_helpers/display_helper.rb +3 -2
  93. data/lib/active_admin/views/components/paginated_collection.rb +2 -2
  94. data/lib/active_admin/views/components/status_tag.rb +5 -1
  95. data/lib/active_admin/views/index_as_table.rb +7 -0
  96. data/lib/generators/active_admin/install/templates/active_admin.rb.erb +18 -2
  97. data/lib/generators/active_admin/resource/templates/admin.rb.erb +40 -37
  98. data/lib/ransack_ext.rb +2 -2
  99. metadata +17 -9
  100. data/lib/active_admin/reloader.rb +0 -25
@@ -28,7 +28,8 @@ module ActiveAdmin
28
28
  # # => Scope with the group :status
29
29
  #
30
30
  def initialize(name, method = nil, options = {}, &block)
31
- @name, @scope_method = name, method.try(:to_sym)
31
+ @name = name
32
+ @scope_method = method.try(:to_sym)
32
33
 
33
34
  if name.is_a? Proc
34
35
  raise "A string/symbol is required as the second argument if your label is a proc." unless method
@@ -38,8 +39,11 @@ module ActiveAdmin
38
39
  @id = name.to_s.parameterize(separator: "_")
39
40
  end
40
41
 
41
- @scope_method = nil if @scope_method == :all
42
- @scope_method, @scope_block = nil, block if block_given?
42
+ @scope_method = nil if @scope_method == :all
43
+ if block_given?
44
+ @scope_method = nil
45
+ @scope_block = block
46
+ end
43
47
 
44
48
  @localizer = options[:localizer]
45
49
  @show_count = options.fetch(:show_count, true)
@@ -6,7 +6,9 @@ module ActiveAdmin
6
6
  attr_accessor :name, :options, :block
7
7
 
8
8
  def initialize(name, options = {}, &block)
9
- @name, @options, @block = name.to_s, options, block
9
+ @name = name.to_s
10
+ @options = options
11
+ @block = block
10
12
  normalize_display_options!
11
13
  end
12
14
 
@@ -1,3 +1,3 @@
1
1
  module ActiveAdmin
2
- VERSION = '2.0.0'
2
+ VERSION = '2.4.0'
3
3
  end
@@ -12,9 +12,9 @@ module ActiveAdmin
12
12
  # 1. try using `display_name` if we can locate a DB object
13
13
  # 2. try using the model name translation
14
14
  # 3. default to calling `titlecase` on the URL fragment
15
- if part =~ /\A(\d+|[a-f0-9]{24}|(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}))\z/ && parts[index-1]
15
+ if part =~ /\A(\d+|[a-f0-9]{24}|(?:[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}))\z/ && parts[index - 1]
16
16
  parent = active_admin_config.belongs_to_config.try :target
17
- config = parent && parent.resource_name.route_key == parts[index-1] ? parent : active_admin_config
17
+ config = parent && parent.resource_name.route_key == parts[index - 1] ? parent : active_admin_config
18
18
  name = display_name config.find_resource part
19
19
  end
20
20
  name ||= I18n.t "activerecord.models.#{part.singularize}", count: ::ActiveAdmin::Helpers::I18n::PLURAL_MANY_COUNT, default: part.titlecase
@@ -3,7 +3,8 @@ module ActiveAdmin
3
3
  module DisplayHelper
4
4
 
5
5
  DISPLAY_NAME_FALLBACK = -> {
6
- name, klass = "", self.class
6
+ name = ""
7
+ klass = self.class
7
8
  name << klass.model_name.human if klass.respond_to? :model_name
8
9
  name << " ##{send(klass.primary_key)}" if klass.respond_to? :primary_key
9
10
  name.present? ? name : to_s
@@ -15,7 +16,7 @@ module ActiveAdmin
15
16
  # Attempts to call any known display name methods on the resource.
16
17
  # See the setting in `application.rb` for the list of methods and their priority.
17
18
  def display_name(resource)
18
- sanitize(render_in_context(resource, display_name_method_for(resource)).to_s) unless resource.nil?
19
+ ERB::Util.html_escape(render_in_context(resource, display_name_method_for(resource))) unless resource.nil?
19
20
  end
20
21
 
21
22
  # Looks up and caches the first available display name method.
@@ -92,11 +92,11 @@ module ActiveAdmin
92
92
  end
93
93
 
94
94
  def build_pagination
95
- options = { theme: 'active_admin' }
95
+ options = { theme: @display_total ? 'active_admin' : 'active_admin_countless' }
96
96
  options[:params] = @params if @params
97
97
  options[:param_name] = @param_name if @param_name
98
98
 
99
- if !@display_total && collection.respond_to?(:offset)
99
+ if !@display_total
100
100
  # The #paginate method in kaminari will query the resource with a
101
101
  # count(*) to determine how many pages there should be unless
102
102
  # you pass in the :total_pages option. We issue a query to determine
@@ -51,8 +51,10 @@ module ActiveAdmin
51
51
  case status
52
52
  when true, 'true'
53
53
  'Yes'
54
- when false, 'false', nil
54
+ when false, 'false'
55
55
  'No'
56
+ when nil
57
+ 'Unset'
56
58
  else
57
59
  status
58
60
  end
@@ -60,6 +62,8 @@ module ActiveAdmin
60
62
 
61
63
  def status_to_class(status)
62
64
  case status
65
+ when 'Unset'
66
+ 'unset no'
63
67
  when String, Symbol
64
68
  status.to_s.titleize.gsub(/\s/, '').underscore
65
69
  else
@@ -192,6 +192,13 @@ module ActiveAdmin
192
192
  # end
193
193
  # ```
194
194
  #
195
+ # You can also define associated objects to include outside of the
196
+ # `scoped_collection` method:
197
+ #
198
+ # ```ruby
199
+ # includes :publisher
200
+ # ```
201
+ #
195
202
  # Then it's simple to sort by any Publisher attribute from within the index table:
196
203
  #
197
204
  # ```ruby
@@ -163,7 +163,10 @@ ActiveAdmin.setup do |config|
163
163
  #
164
164
  # Set the localize format to display dates and times.
165
165
  # To understand how to localize your app with I18n, read more at
166
- # https://github.com/svenfuchs/i18n/blob/master/lib%2Fi18n%2Fbackend%2Fbase.rb#L52
166
+ # https://guides.rubyonrails.org/i18n.html
167
+ #
168
+ # You can run `bin/rails runner 'puts I18n.t("date.formats")'` to see the
169
+ # available formats in your application.
167
170
  #
168
171
  config.localize_format = :long
169
172
 
@@ -283,12 +286,25 @@ ActiveAdmin.setup do |config|
283
286
  # config.filters = true
284
287
  #
285
288
  # By default the filters include associations in a select, which means
286
- # that every record will be loaded for each association.
289
+ # that every record will be loaded for each association (up
290
+ # to the value of config.maximum_association_filter_arity).
287
291
  # You can enabled or disable the inclusion
288
292
  # of those filters by default here.
289
293
  #
290
294
  # config.include_default_association_filters = true
291
295
 
296
+ # config.maximum_association_filter_arity = 256 # default value of :unlimited will change to 256 in a future version
297
+ # config.filter_columns_for_large_association, [
298
+ # :display_name,
299
+ # :full_name,
300
+ # :name,
301
+ # :username,
302
+ # :login,
303
+ # :title,
304
+ # :email,
305
+ # ]
306
+ # config.filter_method_for_large_association, '_starts_with'
307
+
292
308
  # == Head
293
309
  #
294
310
  # You can add your own content to the site head like analytics. Make sure
@@ -1,43 +1,46 @@
1
1
  ActiveAdmin.register <%= class_name %> do
2
- # See permitted parameters documentation:
3
- # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
4
- #
5
- # permit_params :list, :of, :attributes, :on, :model
6
- #
7
- # or
8
- #
9
- # permit_params do
10
- # permitted = [:permitted, :attributes]
11
- # permitted << :other if params[:action] == 'create' && current_user.admin?
12
- # permitted
13
- # end
14
- <% if options.include_boilerplate? %>
15
- # Limit actions available to your users by adding them to the 'except' array
16
- # actions :all, except: []
17
2
 
18
- # Add or remove filters (you can use any ActiveRecord scope) to toggle their
19
- # visibility in the sidebar
20
- <%= @boilerplate.filters %>
3
+ # See permitted parameters documentation:
4
+ # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
5
+ #
6
+ # Uncomment all parameters which should be permitted for assignment
7
+ #
8
+ # permit_params <%= @boilerplate.permit_params %>
9
+ #
10
+ # or
11
+ #
12
+ # permit_params do
13
+ # permitted = [<%= @boilerplate.permit_params %>]
14
+ # permitted << :other if params[:action] == 'create' && current_user.admin?
15
+ # permitted
16
+ # end
17
+ <% if options.include_boilerplate? %>
18
+ # Limit actions available to your users by adding them to the 'except' array
19
+ # actions :all, except: []
21
20
 
22
- # Add or remove columns to toggle their visiblity in the index action
23
- # index do
24
- # selectable_column
25
- # id_column
26
- <%= @boilerplate.columns %>
27
- # actions
28
- # end
21
+ # Add or remove filters (you can use any ActiveRecord scope) to toggle their
22
+ # visibility in the sidebar
23
+ <%= @boilerplate.filters %>
29
24
 
30
- # Add or remove rows to toggle their visiblity in the show action
31
- # show do |<%= class_name.downcase %>|
32
- <%= @boilerplate.rows %>
33
- # end
25
+ # Add or remove columns to toggle their visiblity in the index action
26
+ # index do
27
+ # selectable_column
28
+ # id_column
29
+ <%= @boilerplate.columns %>
30
+ # actions
31
+ # end
34
32
 
35
- # Add or remove fields to toggle their visibility in the form
36
- # form do |f|
37
- # f.inputs do
38
- <%= @boilerplate.form_inputs %>
39
- # end
40
- # f.actions
41
- # end
42
- <% end %>
33
+ # Add or remove rows to toggle their visiblity in the show action
34
+ # show do |<%= class_name.downcase %>|
35
+ <%= @boilerplate.rows %>
36
+ # end
37
+
38
+ # Add or remove fields to toggle their visibility in the form
39
+ # form do |f|
40
+ # f.inputs do
41
+ <%= @boilerplate.form_inputs %>
42
+ # end
43
+ # f.actions
44
+ # end
45
+ <% end %>
43
46
  end
@@ -2,11 +2,11 @@
2
2
  # identically to the versions given in Ransack.
3
3
  #
4
4
  Ransack.configure do |config|
5
- { 'contains'=>'cont', 'starts_with'=>'start', 'ends_with'=>'end' }.each do |old, current|
5
+ { 'contains' => 'cont', 'starts_with' => 'start', 'ends_with' => 'end' }.each do |old, current|
6
6
  config.add_predicate old, Ransack::Constants::DERIVED_PREDICATES.detect { |q, _| q == current }[1]
7
7
  end
8
8
 
9
- { 'equals'=>'eq', 'greater_than'=>'gt', 'less_than'=>'lt' }.each do |old, current|
9
+ { 'equals' => 'eq', 'greater_than' => 'gt', 'less_than' => 'lt' }.each do |old, current|
10
10
  config.add_predicate old, arel_predicate: current
11
11
  end
12
12
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charles Maresh
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2019-04-25 00:00:00.000000000 Z
18
+ date: 2019-10-03 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: arbre
@@ -122,7 +122,7 @@ dependencies:
122
122
  version: '5.0'
123
123
  - - "<"
124
124
  - !ruby/object:Gem::Version
125
- version: '6.0'
125
+ version: '6.1'
126
126
  type: :runtime
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
@@ -132,7 +132,7 @@ dependencies:
132
132
  version: '5.0'
133
133
  - - "<"
134
134
  - !ruby/object:Gem::Version
135
- version: '6.0'
135
+ version: '6.1'
136
136
  - !ruby/object:Gem::Dependency
137
137
  name: ransack
138
138
  requirement: !ruby/object:Gem::Requirement
@@ -154,19 +154,19 @@ dependencies:
154
154
  - !ruby/object:Gem::Version
155
155
  version: 2.1.1
156
156
  - !ruby/object:Gem::Dependency
157
- name: sass
157
+ name: sassc-rails
158
158
  requirement: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - "~>"
161
161
  - !ruby/object:Gem::Version
162
- version: '3.4'
162
+ version: '2.1'
163
163
  type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: !ruby/object:Gem::Requirement
166
166
  requirements:
167
167
  - - "~>"
168
168
  - !ruby/object:Gem::Version
169
- version: '3.4'
169
+ version: '2.1'
170
170
  - !ruby/object:Gem::Dependency
171
171
  name: sprockets
172
172
  requirement: !ruby/object:Gem::Requirement
@@ -302,6 +302,12 @@ files:
302
302
  - app/views/kaminari/active_admin/_page.html.erb
303
303
  - app/views/kaminari/active_admin/_paginator.html.erb
304
304
  - app/views/kaminari/active_admin/_prev_page.html.erb
305
+ - app/views/kaminari/active_admin_countless/_first_page.html.erb
306
+ - app/views/kaminari/active_admin_countless/_gap.html.erb
307
+ - app/views/kaminari/active_admin_countless/_next_page.html.erb
308
+ - app/views/kaminari/active_admin_countless/_page.html.erb
309
+ - app/views/kaminari/active_admin_countless/_paginator.html.erb
310
+ - app/views/kaminari/active_admin_countless/_prev_page.html.erb
305
311
  - app/views/layouts/active_admin.html.arb
306
312
  - app/views/layouts/active_admin_logged_out.html.erb
307
313
  - config/locales/ar.yml
@@ -331,6 +337,7 @@ files:
331
337
  - config/locales/ko.yml
332
338
  - config/locales/lt.yml
333
339
  - config/locales/lv.yml
340
+ - config/locales/mk.yml
334
341
  - config/locales/nb.yml
335
342
  - config/locales/nl.yml
336
343
  - config/locales/pl.yml
@@ -463,7 +470,6 @@ files:
463
470
  - lib/active_admin/page_dsl.rb
464
471
  - lib/active_admin/page_presenter.rb
465
472
  - lib/active_admin/pundit_adapter.rb
466
- - lib/active_admin/reloader.rb
467
473
  - lib/active_admin/resource.rb
468
474
  - lib/active_admin/resource/action_items.rb
469
475
  - lib/active_admin/resource/attributes.rb
@@ -471,6 +477,7 @@ files:
471
477
  - lib/active_admin/resource/controllers.rb
472
478
  - lib/active_admin/resource/includes.rb
473
479
  - lib/active_admin/resource/menu.rb
480
+ - lib/active_admin/resource/model.rb
474
481
  - lib/active_admin/resource/naming.rb
475
482
  - lib/active_admin/resource/ordering.rb
476
483
  - lib/active_admin/resource/page_presenters.rb
@@ -484,6 +491,7 @@ files:
484
491
  - lib/active_admin/resource_controller/action_builder.rb
485
492
  - lib/active_admin/resource_controller/data_access.rb
486
493
  - lib/active_admin/resource_controller/decorators.rb
494
+ - lib/active_admin/resource_controller/polymorphic_routes.rb
487
495
  - lib/active_admin/resource_controller/resource_class_methods.rb
488
496
  - lib/active_admin/resource_controller/scoping.rb
489
497
  - lib/active_admin/resource_controller/sidebars.rb
@@ -600,7 +608,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
600
608
  requirements:
601
609
  - - ">="
602
610
  - !ruby/object:Gem::Version
603
- version: '2.3'
611
+ version: '2.4'
604
612
  required_rubygems_version: !ruby/object:Gem::Requirement
605
613
  requirements:
606
614
  - - ">="
@@ -1,25 +0,0 @@
1
- module ActiveAdmin
2
- module Reloader
3
- # ActionDispatch::Reloader.to_prepare is deprecated in Rails 5.0 and will be removed from Rails 5.1
4
- #
5
- # Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
6
- def self.to_prepare(*args, &block)
7
- if defined? ActiveSupport::Reloader
8
- ActiveSupport::Reloader.to_prepare(*args, &block)
9
- else
10
- ActionDispatch::Reloader.to_prepare(*args, &block)
11
- end
12
- end
13
-
14
- # ActionDispatch::Reloader.to_cleanup is deprecated in Rails 5.0 and will be removed from Rails 5.1
15
- #
16
- # Use ActiveSupport::Reloader if available for Rails 5, fall back to ActionDispatch::Reloader for earlier Rails
17
- def self.to_complete(*args, &block)
18
- if defined? ActiveSupport::Reloader
19
- ActiveSupport::Reloader.to_complete(*args, &block)
20
- else
21
- ActionDispatch::Reloader.to_cleanup(*args, &block)
22
- end
23
- end
24
- end
25
- end