active_scaffold 4.0.13 → 4.1.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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.rdoc +19 -0
  3. data/README.md +11 -5
  4. data/app/assets/javascripts/active_scaffold.js.erb +1 -1
  5. data/app/assets/javascripts/jquery/active_scaffold.js +67 -20
  6. data/app/assets/javascripts/jquery/date_picker_bridge.js.erb +1 -1
  7. data/app/assets/javascripts/jquery/draggable_lists.js +1 -1
  8. data/app/assets/javascripts/jquery/tiny_mce_bridge.js +1 -0
  9. data/app/assets/stylesheets/active_scaffold.scss +415 -6
  10. data/app/assets/stylesheets/active_scaffold_layout.css +11 -1
  11. data/app/views/active_scaffold_overrides/_form.html.erb +1 -1
  12. data/app/views/active_scaffold_overrides/_form_association_footer.html.erb +2 -1
  13. data/app/views/active_scaffold_overrides/_form_association_record.html.erb +1 -1
  14. data/app/views/active_scaffold_overrides/_human_filters.html.erb +1 -0
  15. data/app/views/active_scaffold_overrides/_list_header.html.erb +2 -0
  16. data/app/views/active_scaffold_overrides/_list_messages.html.erb +11 -0
  17. data/app/views/active_scaffold_overrides/_render_field.js.erb +1 -1
  18. data/app/views/active_scaffold_overrides/_show_association.html.erb +1 -0
  19. data/app/views/active_scaffold_overrides/_show_columns.html.erb +17 -2
  20. data/app/views/active_scaffold_overrides/_update_field_on_create.js.erb +20 -0
  21. data/app/views/active_scaffold_overrides/add_tab.js.erb +3 -3
  22. data/app/views/active_scaffold_overrides/edit_associated.js.erb +1 -1
  23. data/app/views/active_scaffold_overrides/on_create.js.erb +21 -17
  24. data/app/views/active_scaffold_overrides/on_update.js.erb +1 -1
  25. data/lib/active_scaffold/actions/core.rb +34 -16
  26. data/lib/active_scaffold/actions/field_search.rb +21 -8
  27. data/lib/active_scaffold/actions/list.rb +40 -5
  28. data/lib/active_scaffold/actions/nested.rb +1 -1
  29. data/lib/active_scaffold/actions/subform.rb +2 -1
  30. data/lib/active_scaffold/attribute_params.rb +12 -2
  31. data/lib/active_scaffold/bridges/cancan/cancan_bridge.rb +1 -1
  32. data/lib/active_scaffold/bridges/paper_trail/helper.rb +1 -1
  33. data/lib/active_scaffold/bridges/record_select/helpers.rb +1 -1
  34. data/lib/active_scaffold/config/core.rb +5 -1
  35. data/lib/active_scaffold/config/list.rb +35 -1
  36. data/lib/active_scaffold/constraints.rb +4 -2
  37. data/lib/active_scaffold/data_structures/action_columns.rb +2 -2
  38. data/lib/active_scaffold/data_structures/action_link.rb +16 -11
  39. data/lib/active_scaffold/data_structures/action_links.rb +3 -3
  40. data/lib/active_scaffold/data_structures/actions.rb +2 -2
  41. data/lib/active_scaffold/data_structures/column.rb +21 -0
  42. data/lib/active_scaffold/data_structures/columns.rb +2 -2
  43. data/lib/active_scaffold/data_structures/filter.rb +85 -0
  44. data/lib/active_scaffold/data_structures/filter_option.rb +32 -0
  45. data/lib/active_scaffold/data_structures/filters.rb +51 -0
  46. data/lib/active_scaffold/data_structures/set.rb +2 -2
  47. data/lib/active_scaffold/data_structures/sorting.rb +2 -2
  48. data/lib/active_scaffold/extensions/action_controller_rendering.rb +2 -2
  49. data/lib/active_scaffold/extensions/action_view_rendering.rb +3 -3
  50. data/lib/active_scaffold/finder.rb +16 -6
  51. data/lib/active_scaffold/helpers/action_link_helpers.rb +21 -17
  52. data/lib/active_scaffold/helpers/filter_helpers.rb +36 -0
  53. data/lib/active_scaffold/helpers/form_column_helpers.rb +116 -26
  54. data/lib/active_scaffold/helpers/human_condition_helpers.rb +4 -0
  55. data/lib/active_scaffold/helpers/list_column_helpers.rb +26 -12
  56. data/lib/active_scaffold/helpers/search_column_helpers.rb +4 -2
  57. data/lib/active_scaffold/helpers/show_column_helpers.rb +4 -3
  58. data/lib/active_scaffold/helpers/tabs_helpers.rb +4 -3
  59. data/lib/active_scaffold/helpers/view_helpers.rb +7 -1
  60. data/lib/active_scaffold/registry.rb +1 -1
  61. data/lib/active_scaffold/responds_to_parent.rb +3 -3
  62. data/lib/active_scaffold/tableless.rb +2 -2
  63. data/lib/active_scaffold/version.rb +2 -2
  64. data/lib/active_scaffold.rb +3 -7
  65. metadata +22 -17
  66. data/app/assets/stylesheets/active_scaffold_colors.scss +0 -414
@@ -164,21 +164,34 @@ module ActiveScaffold
164
164
  ##
165
165
  ## Formatting
166
166
  ##
167
+
168
+ def read_value_from_record(record, column, join_text = ' - ')
169
+ if grouped_search? && column == search_group_column
170
+ value =
171
+ if search_group_function
172
+ record[column.name]
173
+ elsif search_group_column.group_by
174
+ safe_join column.group_by.map.with_index { |_, index| record["#{column.name}_#{index}"] }, join_text
175
+ end
176
+ end
177
+ value || record.send(column.name)
178
+ end
179
+
167
180
  FORM_UI_WITH_OPTIONS = %i[select radio].freeze
168
181
  def format_column_value(record, column, value = nil)
169
- value ||= record.send(column.name) unless record.nil?
170
- if column.association.nil?
182
+ value ||= read_value_from_record(record, column) unless record.nil?
183
+ if grouped_search? && column == search_group_column && (search_group_function || search_group_column.group_by)
184
+ format_grouped_search_column(value, column.options)
185
+ elsif column.association.nil?
171
186
  form_ui_options = column.form_ui_options || column.options if FORM_UI_WITH_OPTIONS.include?(column.form_ui)
172
187
  if form_ui_options&.dig(:options)
173
188
  text, val = form_ui_options[:options].find { |t, v| (v.nil? ? t : v).to_s == value.to_s }
174
189
  value = active_scaffold_translated_option(column, text, val).first if text
175
190
  end
176
- if grouped_search? && column == search_group_column && search_group_function
177
- format_grouped_search_column(value, column.options)
178
- elsif value.is_a? Numeric
191
+ if value.is_a? Numeric
179
192
  format_number_value(value, column.options)
180
193
  else
181
- format_value(value, column.options)
194
+ format_value(value, column.options, column)
182
195
  end
183
196
  else
184
197
  if column.association.collection?
@@ -280,15 +293,16 @@ module ActiveScaffold
280
293
  elsif value
281
294
  format_singular_association_value(value, column, method)
282
295
  end
283
- format_value value
296
+ format_value value, nil, column
284
297
  end
285
298
 
286
- def format_value(column_value, options = {})
299
+ def format_value(column_value, options = {}, column = nil)
300
+ options ||= column&.options
287
301
  value =
288
302
  if column_empty?(column_value)
289
- empty_field_text
303
+ empty_field_text(column)
290
304
  elsif column_value.is_a?(Time) || column_value.is_a?(Date)
291
- l(column_value, format: options[:format] || :default)
305
+ l(column_value, format: options&.dig(:format) || :default)
292
306
  elsif !!column_value == column_value # rubocop:disable Style/DoubleNegation fast check for boolean
293
307
  as_(column_value.to_s.to_sym)
294
308
  else
@@ -459,8 +473,8 @@ module ActiveScaffold
459
473
  def column_calculation(column, id_condition: true)
460
474
  if column.calculate.instance_of? Proc
461
475
  column.calculate.call(@records)
462
- else
463
- calculate_query(id_condition: id_condition).calculate(column.calculate, column.name)
476
+ elsif column.calculate.in? %i[count sum average minimum maximum]
477
+ calculate_query(id_condition: id_condition).calculate(column.calculate, column.grouped_select)
464
478
  end
465
479
  end
466
480
 
@@ -76,7 +76,8 @@ module ActiveScaffold
76
76
  if column.association
77
77
  associated.collect!(&:to_i)
78
78
  method = ui_options[:label_method] || :to_label
79
- select_options = sorted_association_options_find(column.association, nil, record).collect do |r|
79
+ helper_method = association_helper_method(column.association, :sorted_association_options_find)
80
+ select_options = send(helper_method, column.association, nil, record).collect do |r|
80
81
  [r.send(method), r.id]
81
82
  end
82
83
  else
@@ -103,7 +104,8 @@ module ActiveScaffold
103
104
  if column.association
104
105
  associated = associated.is_a?(Array) ? associated.map(&:to_i) : associated.to_i unless associated.nil?
105
106
  method = column.association.belongs_to? ? column.association.foreign_key : column.name
106
- select_options = sorted_association_options_find(column.association, false, record)
107
+ helper_method = association_helper_method(column.association, :sorted_association_options_find)
108
+ select_options = send(helper_method, column.association, false, record)
107
109
  else
108
110
  method = column.name
109
111
  enum_options_method = override_helper_per_model(:active_scaffold_enum_options, record.class)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Helpers
3
3
  # Helpers that assist with the rendering of a List Column
4
4
  module ShowColumnHelpers
5
- def show_column_value(record, column)
5
+ def show_column_value(record, column, **tab_options)
6
6
  value_record = column.delegated_association ? record.send(column.delegated_association.name) : record
7
7
  return get_column_value(record, column) unless value_record
8
8
 
@@ -14,7 +14,7 @@ module ActiveScaffold
14
14
  send(method, value_record, column)
15
15
  # second, check if the dev has specified a valid list_ui for this column
16
16
  elsif column.show_ui && (method = override_show_column_ui(column.show_ui))
17
- send(method, value_record, column, ui_options: column.show_ui_options || column.options)
17
+ send(method, value_record, column, ui_options: tab_options.merge(column.show_ui_options || column.options))
18
18
  elsif column.column && (method = override_show_column_ui(column.column_type)) # rubocop:disable Lint/DuplicateBranch
19
19
  send(method, value_record, column)
20
20
  else
@@ -29,7 +29,8 @@ module ActiveScaffold
29
29
  def active_scaffold_show_horizontal(record, column, ui_options: column.options)
30
30
  raise ':horizontal show_ui must be used on association column' unless column.association
31
31
 
32
- render partial: 'show_association', locals: {column: column, parent_record: record, show_partial: :horizontal}
32
+ vars = {column: column, parent_record: record, show_partial: :horizontal}
33
+ render partial: 'show_association', locals: vars.merge(ui_options.slice(:tabbed_by, :tab_value, :tab_id))
33
34
  end
34
35
 
35
36
  def active_scaffold_show_vertical(record, column, ui_options: column.options)
@@ -2,7 +2,7 @@ module ActiveScaffold
2
2
  module Helpers
3
3
  # Helpers that assist with rendering of tabs in forms
4
4
  module TabsHelpers
5
- def active_scaffold_tabbed_by(column, record, scope, subsection_id, &block)
5
+ def active_scaffold_tabbed_by(column, record, scope, subsection_id, &)
6
6
  add_tab_url = params_for(action: 'render_field', tabbed_by: column.tabbed_by, id: record.to_param, column: column.label)
7
7
  refresh_opts = {refresh_link: {text: 'Add tab', class: 'refresh-link add-tab'}}
8
8
  tab_options = send(override_helper_per_model(:active_scaffold_tab_options, record.class), column, record)
@@ -10,7 +10,7 @@ module ActiveScaffold
10
10
  input_helper = override_helper_per_model(:active_scaffold_input_for_tabbed, record.class)
11
11
  send(input_helper, column, record, subsection_id, tab_options, used_tabs.map(&:first)) <<
12
12
  active_scaffold_refresh_link(nil, {'data-update_url' => url_for(add_tab_url)}, record, refresh_opts) <<
13
- active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs, &block)
13
+ active_scaffold_tabs_for(column, record, subsection_id, tab_options, used_tabs, &)
14
14
  end
15
15
 
16
16
  def active_scaffold_input_for_tabbed(column, record, subsection_id, tab_options, used_tabs)
@@ -49,7 +49,8 @@ module ActiveScaffold
49
49
  end
50
50
  if tab_column
51
51
  label_method = (tab_column.form_ui_options || tab_column.options)[:label_method] || :to_label
52
- sorted_association_options_find(tab_column.association, nil, subform_record).map do |opt_record|
52
+ helper_method = association_helper_method(column.association, :sorted_association_options_find)
53
+ send(helper_method, tab_column.association, nil, subform_record).map do |opt_record|
53
54
  [opt_record.send(label_method), opt_record.id, opt_record]
54
55
  end
55
56
  else
@@ -13,6 +13,7 @@ module ActiveScaffold
13
13
  include ActiveScaffold::Helpers::TabsHelpers
14
14
  include ActiveScaffold::Helpers::SearchColumnHelpers
15
15
  include ActiveScaffold::Helpers::HumanConditionHelpers
16
+ include ActiveScaffold::Helpers::FilterHelpers
16
17
 
17
18
  ##
18
19
  ## Delegates
@@ -137,7 +138,8 @@ module ActiveScaffold
137
138
  empty
138
139
  end
139
140
 
140
- def empty_field_text
141
+ def empty_field_text(column = nil)
142
+ return column.empty_field_text if column&.empty_field_text
141
143
  return @_empty_field_text if defined? @_empty_field_text
142
144
 
143
145
  @_empty_field_text = (active_scaffold_config.list.empty_field_text if active_scaffold_config.actions.include?(:list))
@@ -264,6 +266,10 @@ module ActiveScaffold
264
266
  options[:container_tag] ? content_tag(options[:container_tag], contents, html) : contents
265
267
  end
266
268
  end
269
+
270
+ def new_option_from_record(record)
271
+ [record.to_label, record.id]
272
+ end
267
273
  end
268
274
  end
269
275
  end
@@ -18,7 +18,7 @@ module ActiveScaffold
18
18
  RequestStore.store[:column_links] ||= {}
19
19
  end
20
20
 
21
- def self.cache(kind, key = nil, &block)
21
+ def self.cache(kind, key = nil, &)
22
22
  unless key
23
23
  key = kind
24
24
  kind = :cache
@@ -4,14 +4,14 @@ module ActiveScaffold
4
4
  # Executes the response body as JavaScript in the context of the parent window.
5
5
  # Use this method of you are posting a form to a hidden IFRAME or if you would like
6
6
  # to use IFRAME base RPC.
7
- def responds_to_parent(&block)
7
+ def responds_to_parent(&)
8
8
  yield
9
9
  return unless performed?
10
10
 
11
11
  # Either pull out a redirect or the request body
12
12
  script =
13
- if response.headers['Location']
14
- "document.location.href = '#{self.class.helpers.escape_javascript response.headers.delete('Location').to_s}'"
13
+ if response.has_header? 'location'
14
+ "document.location.href = '#{self.class.helpers.escape_javascript response.delete_header('location').to_s}'"
15
15
  else
16
16
  response.body || ''
17
17
  end
@@ -162,8 +162,8 @@ class ActiveScaffold::Tableless < ActiveRecord::Base # rubocop:disable Rails/App
162
162
  ActiveScaffold::Tableless::Relation.new(self)
163
163
  end
164
164
 
165
- def cached_find_by_statement(key, &block)
166
- StatementCache.new(key, self, &block)
165
+ def cached_find_by_statement(key, &)
166
+ StatementCache.new(key, self, &)
167
167
  end
168
168
  end
169
169
 
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffold
2
2
  module Version
3
3
  MAJOR = 4
4
- MINOR = 0
5
- PATCH = 13
4
+ MINOR = 1
5
+ PATCH = 0
6
6
  FIX = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, PATCH, FIX].compact.join('.')
@@ -80,16 +80,12 @@ module ActiveScaffold
80
80
  "#{File.dirname(__FILE__)}/.."
81
81
  end
82
82
 
83
- def self.defaults(&block)
84
- ActiveScaffold::Config::Core.configure(&block)
83
+ def self.defaults(&)
84
+ ActiveScaffold::Config::Core.configure(&)
85
85
  end
86
86
 
87
87
  def self.deprecator
88
- @deprecator ||= ActiveSupport::Deprecation.new('4.1', 'ActiveScaffold')
89
- end
90
-
91
- class << self
92
- ActiveScaffold.deprecator.deprecate_methods self, :nested_subforms= => 'is enabled always', threadsafe!: 'is enabled always'
88
+ @deprecator ||= ActiveSupport::Deprecation.new('4.2', 'ActiveScaffold')
93
89
  end
94
90
  end
95
91
  require 'active_scaffold/engine'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.13
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-06-17 00:00:00.000000000 Z
11
+ date: 2025-07-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: rails
14
+ name: dartsass-sprockets
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.2.0
26
+ version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: ice_nine
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -39,33 +39,33 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.11'
41
41
  - !ruby/object:Gem::Dependency
42
- name: request_store
42
+ name: rails
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.3'
47
+ version: 5.2.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.3'
54
+ version: 5.2.0
55
55
  - !ruby/object:Gem::Dependency
56
- name: sassc-rails
56
+ name: request_store
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '2.0'
61
+ version: '1.3'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '2.0'
68
+ version: '1.3'
69
69
  description: Save time and headaches, and create a more easily maintainable set of
70
70
  pages, with ActiveScaffold. ActiveScaffold handles all your CRUD (create, read,
71
71
  update, delete) user interface needs, leaving you more time to focus on more challenging
@@ -103,7 +103,6 @@ files:
103
103
  - app/assets/javascripts/jquery/tiny_mce_bridge.js
104
104
  - app/assets/stylesheets/active_scaffold-ie.scss
105
105
  - app/assets/stylesheets/active_scaffold.scss
106
- - app/assets/stylesheets/active_scaffold_colors.scss
107
106
  - app/assets/stylesheets/active_scaffold_extensions.css.erb
108
107
  - app/assets/stylesheets/active_scaffold_images.scss
109
108
  - app/assets/stylesheets/active_scaffold_jquery_ui.css.erb
@@ -124,6 +123,7 @@ files:
124
123
  - app/views/active_scaffold_overrides/_horizontal_subform_footer.html.erb
125
124
  - app/views/active_scaffold_overrides/_horizontal_subform_header.html.erb
126
125
  - app/views/active_scaffold_overrides/_human_conditions.html.erb
126
+ - app/views/active_scaffold_overrides/_human_filters.html.erb
127
127
  - app/views/active_scaffold_overrides/_list.html.erb
128
128
  - app/views/active_scaffold_overrides/_list_calculations.html.erb
129
129
  - app/views/active_scaffold_overrides/_list_column_headings.html.erb
@@ -153,6 +153,7 @@ files:
153
153
  - app/views/active_scaffold_overrides/_update_actions.html.erb
154
154
  - app/views/active_scaffold_overrides/_update_calculations.js.erb
155
155
  - app/views/active_scaffold_overrides/_update_column.js.erb
156
+ - app/views/active_scaffold_overrides/_update_field_on_create.js.erb
156
157
  - app/views/active_scaffold_overrides/_update_form.html.erb
157
158
  - app/views/active_scaffold_overrides/_update_messages.js.erb
158
159
  - app/views/active_scaffold_overrides/_vertical_subform.html.erb
@@ -285,6 +286,9 @@ files:
285
286
  - lib/active_scaffold/data_structures/bridge.rb
286
287
  - lib/active_scaffold/data_structures/column.rb
287
288
  - lib/active_scaffold/data_structures/columns.rb
289
+ - lib/active_scaffold/data_structures/filter.rb
290
+ - lib/active_scaffold/data_structures/filter_option.rb
291
+ - lib/active_scaffold/data_structures/filters.rb
288
292
  - lib/active_scaffold/data_structures/nested_info.rb
289
293
  - lib/active_scaffold/data_structures/proxy_column.rb
290
294
  - lib/active_scaffold/data_structures/set.rb
@@ -306,6 +310,7 @@ files:
306
310
  - lib/active_scaffold/helpers/action_link_helpers.rb
307
311
  - lib/active_scaffold/helpers/association_helpers.rb
308
312
  - lib/active_scaffold/helpers/controller_helpers.rb
313
+ - lib/active_scaffold/helpers/filter_helpers.rb
309
314
  - lib/active_scaffold/helpers/form_column_helpers.rb
310
315
  - lib/active_scaffold/helpers/human_condition_helpers.rb
311
316
  - lib/active_scaffold/helpers/id_helpers.rb
@@ -363,7 +368,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
363
368
  requirements:
364
369
  - - ">="
365
370
  - !ruby/object:Gem::Version
366
- version: '3.0'
371
+ version: '3.1'
367
372
  required_rubygems_version: !ruby/object:Gem::Requirement
368
373
  requirements:
369
374
  - - ">="