autoforme 1.14.0 → 1.15.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: 4a736d797ecc713bf84bca96606007e8eb02c19e83b698365417afcc44fe20f6
4
- data.tar.gz: bb6237775d2413f4d57e6d6c30e458f8b0037d65ea3b87db83bbfa63affae2e5
3
+ metadata.gz: 9b33c734d416c94f39143bda38c834ac0df5845b825427cac13f240649e888c4
4
+ data.tar.gz: 6c9e8a0f6d777e9d696c5aa2c4e4aba6eaa3fdde5dff9f457527b92e4d099c1a
5
5
  SHA512:
6
- metadata.gz: 21db83b2b59a9b71679b21f5d1fffae43f7c73809e5ee3bfe7af70cb14faf768208c794b2adf27c20777f322ef2dfc15b352e88f34b32dc6ca91b036ad88d785
7
- data.tar.gz: 8b0f1295ff5b59334658c34e4d90d80aff5c9778bf3717f7c43eabede1accc7cb95aafca9043ac2fb81eaf667b215bb7f40f45368cdf6c88ce44b8a15a98e202
6
+ metadata.gz: a3d207919ca2cb75e0084132c533262d5c02adbbb45302b607470125e305ce9d1a62de2e3ae054d2cc12089d939be054a496f92a20b34d9640e9dfd06b6ba108
7
+ data.tar.gz: 32ebe7a3aeb2e790facad1b877245b2091a59605af6ce72ff7e2d203193dcc9c1c9c247e9a4fc5d2b486f2c1abc392ab3dd0eb5d961c40946fc5c27ab14a0f5b
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.15.0 (2026-03-04)
2
+
3
+ * Allow model configuration methods to fallback to framework confirmation methods by returning the framework (jeremyevans)
4
+
1
5
  === 1.14.0 (2025-10-02)
2
6
 
3
7
  * Support customizing the searching done for specific columns via column_search_filter (jeremyevans)
@@ -67,7 +67,7 @@ module AutoForme
67
67
 
68
68
  # Whether the given type of action is supported for this model.
69
69
  def supported_action?(type, request)
70
- v = (handle_proc(supported_actions || framework.supported_actions_for(model, request), request) || DEFAULT_SUPPORTED_ACTIONS).include?(type)
70
+ v = (handle_model_proc(supported_actions, :supported_actions_for, request) || DEFAULT_SUPPORTED_ACTIONS).include?(type)
71
71
  if v && type == :mtm_edit
72
72
  assocs = mtm_association_select_options(request)
73
73
  assocs && !assocs.empty?
@@ -78,7 +78,7 @@ module AutoForme
78
78
 
79
79
  # An array of many to many association symbols to handle via a separate mtm_edit page.
80
80
  def mtm_association_select_options(request)
81
- normalize_mtm_associations(handle_proc(mtm_associations || framework.mtm_associations_for(model, request), request))
81
+ normalize_mtm_associations(handle_model_proc(mtm_associations, :mtm_associations_for, request))
82
82
  end
83
83
 
84
84
  # Whether an mtm_edit can be displayed for the given association
@@ -93,19 +93,19 @@ module AutoForme
93
93
 
94
94
  # An array of many to many association symbols to handle inline on the edit forms.
95
95
  def inline_mtm_assocs(request)
96
- normalize_mtm_associations(handle_proc(inline_mtm_associations || framework.inline_mtm_associations_for(model, request), request))
96
+ normalize_mtm_associations(handle_model_proc(inline_mtm_associations, :inline_mtm_associations_for, request))
97
97
  end
98
98
 
99
99
  def columns_for(type, request)
100
- handle_proc(columns || framework.columns_for(model, type, request), type, request) || default_columns
100
+ handle_model_proc(columns, :columns_for, type, request) || default_columns
101
101
  end
102
102
 
103
103
  def pagination_strategy_for(type, request)
104
- handle_proc(pagination_strategy || framework.pagination_strategy_for(model, type, request), type, request) || DEFAULT_PAGINATION_STRATEGY
104
+ handle_model_proc(pagination_strategy, :pagination_strategy_for, type, request) || DEFAULT_PAGINATION_STRATEGY
105
105
  end
106
106
 
107
107
  def column_search_filter_for(dataset, column, value, request)
108
- handle_proc(column_search_filter || framework.column_search_filter_for(model, dataset, column, value, request), dataset, column, value, request)
108
+ handle_model_proc(column_search_filter, :column_search_filter_for, dataset, column, value, request)
109
109
  end
110
110
 
111
111
  # The options to use for the given column and request. Instead of the model options overriding the framework
@@ -159,23 +159,23 @@ module AutoForme
159
159
  end
160
160
 
161
161
  def show_html_for(obj, column, type, request)
162
- handle_proc(show_html || framework.show_html_for(obj, column, type, request), obj, column, type, request)
162
+ handle_direct_proc(show_html, :show_html_for, obj, column, type, request)
163
163
  end
164
164
 
165
165
  def edit_html_for(obj, column, type, request)
166
- handle_proc(edit_html || framework.edit_html_for(obj, column, type, request), obj, column, type, request)
166
+ handle_direct_proc(edit_html, :edit_html_for, obj, column, type, request)
167
167
  end
168
168
 
169
169
  def order_for(type, request)
170
- handle_proc(order || framework.order_for(model, type, request), type, request)
170
+ handle_model_proc(order, :order_for, type, request)
171
171
  end
172
172
 
173
173
  def eager_for(type, request)
174
- handle_proc(eager, type, request)
174
+ handle_local_proc(eager, type, request)
175
175
  end
176
176
 
177
177
  def eager_graph_for(type, request)
178
- handle_proc(eager_graph, type, request)
178
+ handle_local_proc(eager_graph, type, request)
179
179
  end
180
180
 
181
181
  def filter_for
@@ -187,27 +187,27 @@ module AutoForme
187
187
  end
188
188
 
189
189
  def form_attributes_for(type, request)
190
- framework.form_attributes_for(model, type, request).merge(handle_proc(form_attributes, type, request) || {})
190
+ framework.form_attributes_for(model, type, request).merge(handle_local_proc(form_attributes, type, request) || {})
191
191
  end
192
192
 
193
193
  def form_options_for(type, request)
194
- framework.form_options_for(model, type, request).merge(handle_proc(form_options, type, request) || {})
194
+ framework.form_options_for(model, type, request).merge(handle_local_proc(form_options, type, request) || {})
195
195
  end
196
196
 
197
197
  def page_footer_for(type, request)
198
- handle_proc(page_footer || framework.page_footer_for(model, type, request), type, request)
198
+ handle_model_proc(page_footer, :page_footer_for, type, request)
199
199
  end
200
200
 
201
201
  def page_header_for(type, request)
202
- handle_proc(page_header || framework.page_header_for(model, type, request), type, request)
202
+ handle_model_proc(page_header, :page_header_for, type, request)
203
203
  end
204
204
 
205
205
  def table_class_for(type, request)
206
- handle_proc(table_class || framework.table_class_for(model, type, request), type, request) || DEFAULT_TABLE_CLASS
206
+ handle_model_proc(table_class, :table_class_for, type, request) || DEFAULT_TABLE_CLASS
207
207
  end
208
208
 
209
209
  def limit_for(type, request)
210
- handle_proc(per_page || framework.limit_for(model, type, request), type, request) || DEFAULT_LIMIT
210
+ handle_model_proc(per_page, :limit_for, type, request) || DEFAULT_LIMIT
211
211
  end
212
212
 
213
213
  def display_name_for
@@ -215,7 +215,7 @@ module AutoForme
215
215
  end
216
216
 
217
217
  def association_links_for(type, request)
218
- case v = handle_proc(association_links || framework.association_links_for(model, type, request), type, request)
218
+ case v = handle_model_proc(association_links, :association_links_for, type, request)
219
219
  when nil
220
220
  []
221
221
  when Array
@@ -231,7 +231,7 @@ module AutoForme
231
231
 
232
232
  # Whether to lazy load association links for this model.
233
233
  def lazy_load_association_links?(type, request)
234
- v = handle_proc(lazy_load_association_links, type, request)
234
+ v = handle_local_proc(lazy_load_association_links, type, request)
235
235
  v = framework.lazy_load_association_links?(model, type, request) if v.nil?
236
236
  v || false
237
237
  end
@@ -239,7 +239,7 @@ module AutoForme
239
239
  def autocomplete_options_for(type, request)
240
240
  return unless AUTOCOMPLETE_TYPES.include?(type)
241
241
  framework_opts = framework.autocomplete_options_for(model, type, request)
242
- model_opts = handle_proc(autocomplete_options, type, request)
242
+ model_opts = handle_local_proc(autocomplete_options, type, request)
243
243
  if model_opts
244
244
  (framework_opts || {}).merge(model_opts)
245
245
  end
@@ -391,14 +391,42 @@ module AutoForme
391
391
  end
392
392
  end
393
393
 
394
- def handle_proc(v, *a)
394
+ # Handle a proc without a fallback to a framework method.
395
+ def handle_local_proc(v, *a)
396
+ handle_proc(v, nil, nil, *a)
397
+ end
398
+
399
+ def handle_model_proc(v, framework_meth, *a)
400
+ handle_proc(v, framework_meth, true, *a)
401
+ end
402
+
403
+ def handle_direct_proc(v, framework_meth, *a)
404
+ handle_proc(v, framework_meth, false, *a)
405
+ end
406
+
407
+ # Handle a proc, falling back to the framework if the
408
+ # is a nil or is a proc or method that returns the framework.
409
+ def handle_proc(v, framework_meth, add_model, *a)
395
410
  case v
411
+ when nil
412
+ framework_send(framework_meth, add_model, a)
396
413
  when Proc, Method
397
- v.call(*a)
414
+ ret = v.call(*a)
415
+ if framework.equal?(ret)
416
+ framework_send(framework_meth, add_model, a)
417
+ else
418
+ ret
419
+ end
398
420
  else
399
421
  v
400
422
  end
401
423
  end
424
+
425
+ def framework_send(meth, add_model, a)
426
+ return unless meth
427
+ a.unshift(model) if add_model
428
+ framework.public_send(meth, *a)
429
+ end
402
430
 
403
431
  def normalize_mtm_associations(assocs)
404
432
  if assocs == :all
@@ -6,7 +6,7 @@ module AutoForme
6
6
  MAJOR = 1
7
7
 
8
8
  # The minor version of AutoForme, updated for new feature releases of AutoForme.
9
- MINOR = 14
9
+ MINOR = 15
10
10
 
11
11
  # The patch version of AutoForme, updated only for bug fixes from the last
12
12
  # feature release.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autoforme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Evans
@@ -271,7 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
271
271
  - !ruby/object:Gem::Version
272
272
  version: '0'
273
273
  requirements: []
274
- rubygems_version: 3.6.9
274
+ rubygems_version: 4.0.3
275
275
  specification_version: 4
276
276
  summary: Web Administrative Console for Roda/Sinatra/Rails and Sequel::Model
277
277
  test_files: []