activeadmin 3.2.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0548655f225688960699146ba45dcacd0b22375225cd51a835e0226a9347c0a
4
- data.tar.gz: accc8e86bd98b8c7d2f1dca258f528e6a36941e3c7cc8633605cfbb05fd652d6
3
+ metadata.gz: e080845beb483b8364c49bb199ac8b4ba61975854316d053df39b39208d863bf
4
+ data.tar.gz: c30bcfde594fb30c2a8796741451f245b77ddeaa66c6a66ecbfbcbec3064918a
5
5
  SHA512:
6
- metadata.gz: 9fdd7e6072424d783695be0cf5887800d894bd83a18511177d06bd16604b99b04ae491bcd281efb4acffd425b95fc747e2ede748574c07adc507a18380096184
7
- data.tar.gz: 3756bf37298eab6a6227e56a76cf4ebfa4563f718a9f8c67feeb34446c56e1b2bce8243cbf5f267801e3aa42ff12f56acf01e37bef409a80a1f6180072c2aa38
6
+ metadata.gz: fe64d783c2ac39dbbc74df16985dabcbee5e300039f8b703df6ccedf7dee24dcda09dd59b154383ba0dc593310f163dd6ca51af5f59d26b11646683158eeae4a
7
+ data.tar.gz: f4e988b7bf89e2cb291822c62d891d958ec48400e3ccee31fc2480b47ee1c8ab80608c939abb80733378c2f27a245044d1f89c68fe04c8fd850264df072ae8d1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,54 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.3.0 [☰](https://github.com/activeadmin/activeadmin/compare/v3.2.5..v3.3.0)
6
+
7
+ ### Enhancements
8
+
9
+ * Improve v3 docs regarding compatibility with vite_rails [#8548] by [@mattbrictson]
10
+ * Backport test against Rails 8.0 [#8556] by [@mgrunberg] and [@tagliala]
11
+ * Test against Ruby 3.4 [#8614] by [@tagliala]
12
+ * Backport Support sortable argument in id_column [#8650] by [@jaynetics]
13
+ * Backport Support title for id_column [#8652] by [@mgrunberg]
14
+
15
+ ### Bug Fixes
16
+
17
+ * Backport Fix attributes passed to form has_many not being set on new record form items [#8551] by [@Fs00]
18
+ * Backport Fix deprecation warning in Ruby 3.4 [#8596] by [@tagliala]
19
+ * Backport Fix circular require warning in belongs_to.rb [#8601] by [@tagliala]
20
+
21
+ ## 3.2.5 [☰](https://github.com/activeadmin/activeadmin/compare/v3.2.4..v3.2.5)
22
+
23
+ ### Enhancements
24
+
25
+ * Backport Add favicon to template app to fix Rails 7.2 test suite run [#8468] by [@mgrunberg]
26
+ * Backport Use attribute_types instead of columns_hash to determine type [#8469] by [@mgrunberg]
27
+ * Backport Optimize count query for pagination_total: false option [#8470] by [@mgrunberg]
28
+
29
+ ### Bug Fixes
30
+
31
+ * Restore inner span tag to form inputs legend [#8467] by [@denisahearn]
32
+
33
+ ## 3.2.4 [☰](https://github.com/activeadmin/activeadmin/compare/v3.2.3..v3.2.4)
34
+
35
+ ### Enhancements
36
+
37
+ * Test against Rails 7.2 [#8434] by [@mgrunberg]
38
+
39
+ ### Bug Fixes
40
+
41
+ * Backport Improve form f.inputs attributes rendering [#8446] by [@amiel]
42
+
43
+ ## 3.2.3 [☰](https://github.com/activeadmin/activeadmin/compare/v3.2.2..v3.2.3)
44
+
45
+ ### Enhancements
46
+
47
+ * Backport better implementation of counter-cache-column check [#8412] by [@plashchynski]
48
+
49
+ ### Bug Fixes
50
+
51
+ * Remove deprecation warnings when building with dart sass >= 1.77.7 [#8405] by [@mgrunberg]
52
+
5
53
  ## 3.2.2 [☰](https://github.com/activeadmin/activeadmin/compare/v3.2.1..v3.2.2)
6
54
 
7
55
  ### Security Fixes
@@ -920,6 +968,22 @@ Please check [0-6-stable] for previous changes.
920
968
  [#8311]: https://github.com/activeadmin/activeadmin/pull/8311
921
969
  [#8329]: https://github.com/activeadmin/activeadmin/pull/8329
922
970
  [#8349]: https://github.com/activeadmin/activeadmin/pull/8349
971
+ [#8405]: https://github.com/activeadmin/activeadmin/pull/8405
972
+ [#8412]: https://github.com/activeadmin/activeadmin/pull/8412
973
+ [#8434]: https://github.com/activeadmin/activeadmin/pull/8434
974
+ [#8446]: https://github.com/activeadmin/activeadmin/pull/8446
975
+ [#8467]: https://github.com/activeadmin/activeadmin/pull/8467
976
+ [#8468]: https://github.com/activeadmin/activeadmin/pull/8468
977
+ [#8469]: https://github.com/activeadmin/activeadmin/pull/8469
978
+ [#8470]: https://github.com/activeadmin/activeadmin/pull/8470
979
+ [#8548]: https://github.com/activeadmin/activeadmin/pull/8548
980
+ [#8551]: https://github.com/activeadmin/activeadmin/pull/8551
981
+ [#8556]: https://github.com/activeadmin/activeadmin/pull/8556
982
+ [#8596]: https://github.com/activeadmin/activeadmin/pull/8596
983
+ [#8601]: https://github.com/activeadmin/activeadmin/pull/8601
984
+ [#8614]: https://github.com/activeadmin/activeadmin/pull/8614
985
+ [#8650]: https://github.com/activeadmin/activeadmin/pull/8650
986
+ [#8652]: https://github.com/activeadmin/activeadmin/pull/8652
923
987
 
924
988
  [@1000ship]: https://github.com/1000ship
925
989
  [@5t111111]: https://github.com/5t111111
@@ -948,6 +1012,7 @@ Please check [0-6-stable] for previous changes.
948
1012
  [@craigmcnamara]: https://github.com/craigmcnamara
949
1013
  [@DanielHeath]: https://github.com/DanielHeath
950
1014
  [@deivid-rodriguez]: https://github.com/deivid-rodriguez
1015
+ [@denisahearn]: https://github.com/denisahearn
951
1016
  [@dennisvdvliet]: https://github.com/dennisvdvliet
952
1017
  [@dhyegofernando]: https://github.com/dhyegofernando
953
1018
  [@dkniffin]: https://github.com/dkniffin
@@ -999,6 +1064,7 @@ Please check [0-6-stable] for previous changes.
999
1064
  [@Looooong]: https://github.com/Looooong
1000
1065
  [@lubosch]: https://github.com/lubosch
1001
1066
  [@markstory]: https://github.com/markstory
1067
+ [@mattbrictson]: https://github.com/mattbrictson
1002
1068
  [@mauriciopasquier]: https://github.com/mauriciopasquier
1003
1069
  [@mconiglio]: https://github.com/mconiglio
1004
1070
  [@mgrunberg]: https://github.com/mgrunberg
@@ -1014,6 +1080,7 @@ Please check [0-6-stable] for previous changes.
1014
1080
  [@orkhan]: https://github.com/orkhan
1015
1081
  [@panasyuk]: https://github.com/panasyuk
1016
1082
  [@PChambino]: https://github.com/PChambino
1083
+ [@plashchynski]: https://github.com/plashchynski
1017
1084
  [@potatosalad]: https://github.com/potatosalad
1018
1085
  [@pranas]: https://github.com/pranas
1019
1086
  [@ray-curran]: https://github.com/ray-curran
data/README.md CHANGED
@@ -85,8 +85,8 @@ Thanks to [Tidelift][tidelift] and all our Tidelift subscribers.
85
85
  Thanks to [Open Collective][opencollective contributors] and all our Open Collective contributors.
86
86
 
87
87
  [Arbre]: https://github.com/activeadmin/arbre
88
- [Devise]: https://github.com/plataformatec/devise
89
- [Formtastic]: https://github.com/justinfrench/formtastic
88
+ [Devise]: https://github.com/heartcombo/devise
89
+ [Formtastic]: https://github.com/formtastic/formtastic
90
90
  [Inherited Resources]: https://github.com/activeadmin/inherited_resources
91
91
  [Kaminari]: https://github.com/kaminari/kaminari
92
92
  [Ransack]: https://github.com/activerecord-hackery/ransack
@@ -220,9 +220,8 @@ form {
220
220
  /* Buttons */
221
221
 
222
222
  input[type=submit], input[type=button], button {
223
- @include dark-button;
224
223
  cursor: pointer;
225
-
224
+ @include dark-button;
226
225
  }
227
226
 
228
227
  .buttons, .actions {
@@ -2,10 +2,10 @@
2
2
  .comments {
3
3
 
4
4
  .active_admin_comment {
5
- @include clearfix;
6
5
  margin-top: 10px;
7
6
  margin-bottom: 20px;
8
7
  max-width: 700px;
8
+ @include clearfix;
9
9
 
10
10
  .active_admin_comment_meta {
11
11
  width: 130px;
@@ -3,9 +3,12 @@
3
3
 
4
4
  .dropdown_menu_button {
5
5
  @include light-button;
6
- position: relative;
7
- padding-right: 22px !important;
8
- cursor: pointer;
6
+
7
+ & {
8
+ position: relative;
9
+ padding-right: 22px !important;
10
+ cursor: pointer;
11
+ }
9
12
 
10
13
  &:before {
11
14
  content: ' ';
@@ -139,11 +142,11 @@
139
142
  }
140
143
 
141
144
  &:last-child {
145
+ border: none;
142
146
  a {
143
147
  border-bottom-left-radius: 2px;
144
148
  border-bottom-right-radius: 2px;
145
149
  }
146
- border: none;
147
150
  }
148
151
  }
149
152
  }
@@ -38,8 +38,11 @@
38
38
  margin-left: 4px;
39
39
  select {
40
40
  @include light-button;
41
- @include rounded(0px);
42
- padding: 1px 5px;
41
+
42
+ & {
43
+ @include rounded(0px);
44
+ padding: 1px 5px;
45
+ }
43
46
  }
44
47
  }
45
48
 
@@ -1,6 +1,6 @@
1
1
  .table_tools {
2
- @include clearfix;
3
2
  margin-bottom: 16px;
3
+ @include clearfix;
4
4
  }
5
5
 
6
6
  .table_tools .dropdown_menu {
@@ -9,11 +9,14 @@
9
9
 
10
10
  a.table_tools_button, .table_tools .dropdown_menu_button {
11
11
  @include light-button;
12
- @include gradient(#FFFFFF, #F0F0F0);
13
- @include border-colors(#d9d9d9, #d0d0d0, #c5c5c5);
14
- font-size: 0.9em;
15
- padding: 4px 14px 4px;
16
- margin: 0;
12
+
13
+ & {
14
+ @include gradient(#FFFFFF, #F0F0F0);
15
+ @include border-colors(#d9d9d9, #d0d0d0, #c5c5c5);
16
+ font-size: 0.9em;
17
+ padding: 4px 14px 4px;
18
+ margin: 0;
19
+ }
17
20
 
18
21
  &:not(.disabled) {
19
22
  &:hover {
@@ -28,13 +28,16 @@
28
28
 
29
29
  a {
30
30
  @include light-button;
31
- @include gradient(#FFFFFF, #F0F0F0);
32
- @include border-colors(#d9d9d9, #d0d0d0, #c5c5c5);
33
- text-decoration: none;
34
- border-radius: 0;
35
- border-width: 1px .5px 1px .5px;
36
- margin-right: 0;
37
- padding: 4px 14px 4px;
31
+
32
+ & {
33
+ @include gradient(#FFFFFF, #F0F0F0);
34
+ @include border-colors(#d9d9d9, #d0d0d0, #c5c5c5);
35
+ text-decoration: none;
36
+ border-radius: 0;
37
+ border-width: 1px .5px 1px .5px;
38
+ margin-right: 0;
39
+ padding: 4px 14px 4px;
40
+ }
38
41
 
39
42
  &:not(.disabled) {
40
43
  &:hover {
@@ -17,13 +17,13 @@
17
17
  }
18
18
 
19
19
  @mixin default-button {
20
- @include basic-button;
21
20
  @include gradient(lighten($primary-color, 15%), darken($primary-color, 12%));
22
21
  @include text-shadow(#000);
23
22
  box-shadow: 0 1px 1px rgba(0,0,0,0.10), 0 1px 0 0px rgba(255,255,255, 0.2) inset;
24
23
  border: solid 1px #484e53;
25
24
  @include border-colors(#616a71, #484e53, #363b3f);
26
25
  color: #efefef;
26
+ @include basic-button;
27
27
 
28
28
  &:not(.disabled) {
29
29
  &:hover{
@@ -38,13 +38,13 @@
38
38
  }
39
39
 
40
40
  @mixin light-button {
41
- @include basic-button;
42
41
  @include gradient(#FFFFFF, #E7E7E7);
43
42
  box-shadow: 0 1px 1px rgba(0,0,0,0.10), 0 1px 0 0 rgba(255,255,255, 0.8) inset;
44
43
  border: solid 1px #c7c7c7;
45
44
  @include border-colors(#d3d3d3, #c7c7c7, #c2c2c2);
46
45
  @include text-shadow;
47
46
  color: $primary-color;
47
+ @include basic-button;
48
48
 
49
49
  &:not(.disabled) {
50
50
  &:hover {
@@ -28,13 +28,13 @@ body.logged_out {
28
28
  @include no-shadow;
29
29
  background: none;
30
30
  padding: 0;
31
+ margin-bottom: 0;
31
32
  li { padding: 10px 0; }
32
33
 
33
34
  input[type=text], input[type=email], input[type=password] {
34
35
  width: 70%;
35
36
  }
36
37
  &.buttons { margin-left: 20%; }
37
- margin-bottom: 0;
38
38
  }
39
39
  }
40
40
 
@@ -10,10 +10,10 @@
10
10
 
11
11
  // -------------------------------------- Index Footer (Under Table)
12
12
  #index_footer {
13
- @include clearfix;
14
13
  padding-top: 5px;
15
14
  text-align: right;
16
15
  font-size: 0.85em;
16
+ @include clearfix;
17
17
  }
18
18
 
19
19
  .index_content { clear: both; }
@@ -1,6 +1,5 @@
1
1
  #title_bar {
2
2
  @include section-header;
3
- @include clearfix;
4
3
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.37);
5
4
  display: table;
6
5
  border-bottom-color: #EEE;
@@ -9,6 +8,7 @@
9
8
  margin: 0;
10
9
  padding: 10px $horizontal-page-margin;
11
10
  z-index: 800;
11
+ @include clearfix;
12
12
 
13
13
  #titlebar_left, #titlebar_right {
14
14
  height: 50px;
@@ -32,8 +32,11 @@
32
32
  span.action_item {
33
33
  & > a, & > .dropdown_menu > a {
34
34
  @include light-button;
35
- padding: 12px 17px 10px;
36
- margin: 0px;
35
+
36
+ & {
37
+ padding: 12px 17px 10px;
38
+ margin: 0px;
39
+ }
37
40
  }
38
41
  }
39
42
  }
@@ -95,7 +95,7 @@ module ActiveAdmin
95
95
  contents = without_wrapper { inputs(options, &form_block) }
96
96
  contents ||= "".html_safe
97
97
 
98
- js = new_record ? js_for_has_many(options[:class], &form_block) : ""
98
+ js = new_record ? js_for_has_many(&form_block) : ""
99
99
  contents << js
100
100
  end
101
101
 
@@ -159,14 +159,13 @@ module ActiveAdmin
159
159
  end
160
160
 
161
161
  # Capture the ADD JS
162
- def js_for_has_many(class_string, &form_block)
162
+ def js_for_has_many(&form_block)
163
163
  assoc_name = assoc_klass.model_name
164
- placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.gsub(/\//, '_')}_RECORD"
165
- opts = {
164
+ placeholder = "NEW_#{assoc_name.to_s.underscore.upcase.tr('/', '_')}_RECORD"
165
+ opts = options.merge(
166
166
  for: [assoc, assoc_klass.new],
167
- class: class_string,
168
167
  for_options: { child_index: placeholder }
169
- }
168
+ )
170
169
  html = template.capture { __getobj__.send(:inputs_for_nested_attributes, opts, &form_block) }
171
170
  text = new_record.is_a?(String) ? new_record : I18n.t("active_admin.has_many_new", model: assoc_name.human)
172
171
 
@@ -15,9 +15,7 @@ module ActiveAdmin
15
15
  if searchable_has_many_through?
16
16
  "#{reflection.through_reflection.name}_#{reflection.foreign_key}"
17
17
  else
18
- name = method.to_s
19
- name.concat "_#{reflection.association_primary_key}" if reflection_searchable?
20
- name
18
+ reflection_searchable? ? "#{method}_#{reflection.association_primary_key}" : method.to_s
21
19
  end
22
20
  end
23
21
 
@@ -42,7 +42,7 @@ module ActiveAdmin
42
42
  end
43
43
 
44
44
  def format_action(action, subject)
45
- # https://github.com/varvet/pundit/blob/master/lib/generators/pundit/install/templates/application_policy.rb
45
+ # https://github.com/varvet/pundit/blob/main/lib/generators/pundit/install/templates/application_policy.rb
46
46
  case action
47
47
  when Auth::READ then subject.is_a?(Class) ? :index? : :show?
48
48
  when Auth::DESTROY then subject.is_a?(Class) ? :destroy_all? : :destroy?
@@ -37,7 +37,14 @@ module ActiveAdmin
37
37
  end
38
38
 
39
39
  def counter_cache_col?(c)
40
- c.name.end_with?("_count")
40
+ # This helper is called inside a loop. Let's memoize the result.
41
+ @counter_cache_columns ||= begin
42
+ resource_class.reflect_on_all_associations(:has_many)
43
+ .select(&:has_cached_counter?)
44
+ .map(&:counter_cache_column)
45
+ end
46
+
47
+ @counter_cache_columns.include?(c.name)
41
48
  end
42
49
 
43
50
  def filtered_col?(c)
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
- require "active_admin/resource"
3
2
 
4
3
  module ActiveAdmin
5
4
  class Resource
@@ -61,7 +61,7 @@ module ActiveAdmin
61
61
  def self.wrap!(parent, name)
62
62
  ::Class.new parent do
63
63
  delegate :reorder, :page, :current_page, :total_pages, :limit_value,
64
- :total_count, :total_pages, :offset, :to_key, :group_values,
64
+ :total_count, :offset, :to_key, :group_values,
65
65
  :except, :find_each, :ransack, to: :object
66
66
 
67
67
  define_singleton_method(:name) { name }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ActiveAdmin
3
- VERSION = "3.2.2"
3
+ VERSION = "3.3.0"
4
4
  end
@@ -108,8 +108,8 @@ module ActiveAdmin
108
108
  when TrueClass, FalseClass
109
109
  true
110
110
  else
111
- if resource.class.respond_to? :columns_hash
112
- column = resource.class.columns_hash[attr.to_s] and column.type == :boolean
111
+ if resource.class.respond_to? :attribute_types
112
+ resource.class.attribute_types[attr.to_s].is_a?(ActiveModel::Type::Boolean)
113
113
  end
114
114
  end
115
115
  end
@@ -127,12 +127,24 @@ module ActiveAdmin
127
127
  html_options[:class] ||= "inputs"
128
128
  legend = args.shift if args.first.is_a?(::String)
129
129
  legend = html_options.delete(:name) if html_options.key?(:name)
130
- legend_tag = legend ? "<legend><span>#{ERB::Util.html_escape(legend)}</span></legend>" : ""
131
- fieldset_attrs = html_options.map { |k, v| %Q{#{k}="#{v}"} }.join(" ")
130
+ legend_tag = legend ? helpers.tag.legend(helpers.tag.span(legend), class: "fieldset-title") : ""
131
+ fieldset_attrs = tag_attributes html_options
132
132
  @opening_tag = "<fieldset #{fieldset_attrs}>#{legend_tag}<ol>"
133
133
  @closing_tag = "</ol></fieldset>"
134
134
  super(*(args << html_options), &block)
135
135
  end
136
+
137
+ private
138
+
139
+ def tag_attributes(html_options)
140
+ if Rails::VERSION::MAJOR <= 6
141
+ # Reimplement tag.attributes to backport support for Rails 6.1.
142
+ # TODO: this can be removed when support for Rails 6.x is dropped
143
+ helpers.tag.tag_options(html_options.to_h).to_s.strip.html_safe
144
+ else
145
+ helpers.tag.attributes html_options
146
+ end
147
+ end
136
148
  end
137
149
 
138
150
  class SemanticActionsProxy < FormtasticProxy
@@ -103,7 +103,10 @@ module ActiveAdmin
103
103
  # you pass in the :total_pages option. We issue a query to determine
104
104
  # if there is another page or not, but the limit/offset make this
105
105
  # query fast.
106
- offset = collection.offset(collection.current_page * collection.limit_value).limit(1).count
106
+ offset_scope = collection.offset(collection.current_page * collection.limit_value)
107
+ # Support array collections. Kaminari::PaginatableArray does not respond to except
108
+ offset_scope = offset_scope.except(:select, :order) if offset_scope.respond_to?(:except)
109
+ offset = offset_scope.limit(1).count
107
110
  options[:total_pages] = collection.current_page + offset
108
111
  options[:right] = 0
109
112
  end
@@ -291,9 +291,14 @@ module ActiveAdmin
291
291
  end
292
292
 
293
293
  # Display a column for the id
294
- def id_column
294
+ def id_column(*args)
295
295
  raise "#{resource_class.name} has no primary_key!" unless resource_class.primary_key
296
- column(resource_class.human_attribute_name(resource_class.primary_key), sortable: resource_class.primary_key) do |resource|
296
+
297
+ options = args.extract_options!
298
+ title = args[0].presence || resource_class.human_attribute_name(resource_class.primary_key)
299
+ sortable = options.fetch(:sortable, resource_class.primary_key)
300
+
301
+ column(title, sortable: sortable) do |resource|
297
302
  if controller.action_methods.include?("show")
298
303
  link_to resource.id, resource_path(resource), class: "resource_id_link"
299
304
  elsif controller.action_methods.include?("edit")
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: 3.2.2
4
+ version: 3.3.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: 2024-05-31 00:00:00.000000000 Z
18
+ date: 2025-03-08 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: arbre
@@ -533,7 +533,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
533
533
  - !ruby/object:Gem::Version
534
534
  version: '0'
535
535
  requirements: []
536
- rubygems_version: 3.5.11
536
+ rubygems_version: 3.5.22
537
537
  signing_key:
538
538
  specification_version: 4
539
539
  summary: Active Admin is a Ruby on Rails plugin for generating administration style