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 +4 -4
- data/CHANGELOG +4 -0
- data/lib/autoforme/model.rb +50 -22
- data/lib/autoforme/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9b33c734d416c94f39143bda38c834ac0df5845b825427cac13f240649e888c4
|
|
4
|
+
data.tar.gz: 6c9e8a0f6d777e9d696c5aa2c4e4aba6eaa3fdde5dff9f457527b92e4d099c1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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)
|
data/lib/autoforme/model.rb
CHANGED
|
@@ -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 = (
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
170
|
+
handle_model_proc(order, :order_for, type, request)
|
|
171
171
|
end
|
|
172
172
|
|
|
173
173
|
def eager_for(type, request)
|
|
174
|
-
|
|
174
|
+
handle_local_proc(eager, type, request)
|
|
175
175
|
end
|
|
176
176
|
|
|
177
177
|
def eager_graph_for(type, request)
|
|
178
|
-
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
data/lib/autoforme/version.rb
CHANGED
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.
|
|
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:
|
|
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: []
|