active_scaffold 4.2.1 → 4.2.2
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.rdoc +3 -0
- data/lib/active_scaffold/actions/core.rb +10 -0
- data/lib/active_scaffold/actions/nested.rb +1 -7
- data/lib/active_scaffold/constraints.rb +4 -2
- data/lib/active_scaffold/data_structures/association/active_record.rb +3 -3
- data/lib/active_scaffold/data_structures/column.rb +6 -2
- data/lib/active_scaffold/data_structures/nested_info.rb +3 -7
- data/lib/active_scaffold/finder.rb +1 -1
- data/lib/active_scaffold/helpers/controller_helpers.rb +4 -6
- data/lib/active_scaffold/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: a411ae5638102ae3b9052929c30afcb44f769c9eeb528fdddd995ba7407bc5b9
|
|
4
|
+
data.tar.gz: 0171ab0f4fbde3b09cffae2553d7a7d90248bb5529f548e2321acb525610edd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d39d363d9ff5a27b07c124bf7718962d5355c879a77e48f5085f195d739b821276fdbda602078a0995c5385290dd158b2604acf75b863d323ce6ca1ac45d108d
|
|
7
|
+
data.tar.gz: 6afacdeacd3fd4b13d0115a8a7c3faba454c2e755bdea68485ebbbdb2c7a305b7022ca833e8960aa4c5df3258ce72236b5959c450d51306049ab652365429a6c
|
data/CHANGELOG.rdoc
CHANGED
|
@@ -146,6 +146,16 @@ module ActiveScaffold::Actions
|
|
|
146
146
|
"#{params[:parent_controller].camelize}Controller"
|
|
147
147
|
end
|
|
148
148
|
|
|
149
|
+
def create_on_through_singular(record, association, parent_record)
|
|
150
|
+
through = parent_record.send(association.through_reflection.name) ||
|
|
151
|
+
parent_record.send(:"build_#{association.through_reflection.name}")
|
|
152
|
+
if association.source_reflection.reverse_association.collection?
|
|
153
|
+
record.send(association.source_reflection.reverse) << through
|
|
154
|
+
else
|
|
155
|
+
record.send(:"#{association.source_reflection.reverse}=", through)
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
149
159
|
def setup_parent
|
|
150
160
|
cfg = main_form_controller.active_scaffold_config
|
|
151
161
|
parent = cfg.model.new
|
|
@@ -107,13 +107,7 @@ module ActiveScaffold::Actions
|
|
|
107
107
|
if nested.child_association&.singular?
|
|
108
108
|
record.send(:"#{nested.child_association.name}=", nested_parent_record)
|
|
109
109
|
elsif nested.create_through_singular?
|
|
110
|
-
|
|
111
|
-
nested_parent_record.send(:"build_#{nested.association.through_reflection.name}")
|
|
112
|
-
if nested.source_reflection.reverse_association.collection?
|
|
113
|
-
record.send(nested.source_reflection.reverse) << through
|
|
114
|
-
else
|
|
115
|
-
record.send(:"#{nested.source_reflection.reverse}=", through)
|
|
116
|
-
end
|
|
110
|
+
create_on_through_singular(record, nested.association, nested_parent_record)
|
|
117
111
|
else
|
|
118
112
|
record.send(nested.child_association.name) << nested_parent_record
|
|
119
113
|
end
|
|
@@ -171,7 +171,9 @@ module ActiveScaffold
|
|
|
171
171
|
constraints.each do |k, v|
|
|
172
172
|
column = config.columns[k]
|
|
173
173
|
if column&.association
|
|
174
|
-
if column.association.
|
|
174
|
+
if column.association.through_singular? && column.association.source_reflection.reverse
|
|
175
|
+
create_on_through_singular(record, column.association, column.association.klass.find(v))
|
|
176
|
+
elsif column.association.collection?
|
|
175
177
|
record.send(k.to_s).send(:<<, column.association.klass.find(v)) unless column.association.nested?
|
|
176
178
|
elsif column.association.polymorphic?
|
|
177
179
|
unless v.is_a?(Array) && v.size >= 2
|
|
@@ -183,7 +185,7 @@ module ActiveScaffold
|
|
|
183
185
|
else
|
|
184
186
|
record.send(:"#{column.association.foreign_type}=", v[0])
|
|
185
187
|
end
|
|
186
|
-
elsif !column.association.source_reflection&.
|
|
188
|
+
elsif !column.association.source_reflection&.through? && # regular singular association, or one-level through association
|
|
187
189
|
!v.is_a?(Array)
|
|
188
190
|
record.send(:"#{k}=", column.association.klass.find(v))
|
|
189
191
|
|
|
@@ -6,7 +6,7 @@ module ActiveScaffold::DataStructures::Association
|
|
|
6
6
|
klass.reflect_on_all_associations
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
-
delegate :collection?, :polymorphic?, :association_primary_key, :foreign_type, :table_name, :nested?, :scope, to: :@association
|
|
9
|
+
delegate :collection?, :polymorphic?, :association_primary_key, :foreign_type, :table_name, :nested?, :scope, :class_name, to: :@association
|
|
10
10
|
|
|
11
11
|
def through?
|
|
12
12
|
@association.options[:through].present?
|
|
@@ -17,11 +17,11 @@ module ActiveScaffold::DataStructures::Association
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
def through_reflection
|
|
20
|
-
@association.through_reflection if through?
|
|
20
|
+
@through_reflection ||= self.class.new(@association.through_reflection) if through?
|
|
21
21
|
end
|
|
22
22
|
|
|
23
23
|
def source_reflection
|
|
24
|
-
@association.source_reflection if through?
|
|
24
|
+
@source_reflection ||= self.class.new(@association.source_reflection) if through?
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
def inverse_klass
|
|
@@ -746,10 +746,14 @@ module ActiveScaffold::DataStructures
|
|
|
746
746
|
|
|
747
747
|
def valid_action_ui_params?(value)
|
|
748
748
|
if value.is_a?(Array)
|
|
749
|
-
value.size <= 2 && value[0]
|
|
749
|
+
value.size <= 2 && valid_form_ui?(value[0]) && (value[1].nil? || value[1].is_a?(Hash))
|
|
750
750
|
else
|
|
751
|
-
|
|
751
|
+
valid_form_ui?(value)
|
|
752
752
|
end
|
|
753
753
|
end
|
|
754
|
+
|
|
755
|
+
def valid_form_ui?(value)
|
|
756
|
+
value.nil? || value.is_a?(Symbol)
|
|
757
|
+
end
|
|
754
758
|
end
|
|
755
759
|
end
|
|
@@ -104,8 +104,8 @@ module ActiveScaffold::DataStructures
|
|
|
104
104
|
# RatesController has employee in create action columns (reverse is vendor, and through association employee is in create form).
|
|
105
105
|
def readonly_through_association?(columns)
|
|
106
106
|
return false unless through_association?
|
|
107
|
-
return true if association.through_reflection.
|
|
108
|
-
return true if association.source_reflection.
|
|
107
|
+
return true if association.through_reflection.through? # create not possible, too many levels
|
|
108
|
+
return true if association.source_reflection.through? # create not possible, too many levels
|
|
109
109
|
return false if create_through_singular? # create allowed, AS has code for this
|
|
110
110
|
return false unless association.source_reflection.collection? # create allowed if source is singular, rails creates joint model
|
|
111
111
|
|
|
@@ -114,7 +114,7 @@ module ActiveScaffold::DataStructures
|
|
|
114
114
|
end
|
|
115
115
|
|
|
116
116
|
def create_through_singular?
|
|
117
|
-
association.through_singular? && source_reflection.reverse
|
|
117
|
+
association.through_singular? && association.source_reflection.reverse
|
|
118
118
|
end
|
|
119
119
|
|
|
120
120
|
def create_with_parent?
|
|
@@ -125,10 +125,6 @@ module ActiveScaffold::DataStructures
|
|
|
125
125
|
end
|
|
126
126
|
end
|
|
127
127
|
|
|
128
|
-
def source_reflection
|
|
129
|
-
@source_reflection ||= ActiveScaffold::DataStructures::Association::ActiveRecord.new(association.source_reflection)
|
|
130
|
-
end
|
|
131
|
-
|
|
132
128
|
def through_association?
|
|
133
129
|
association.through?
|
|
134
130
|
end
|
|
@@ -245,7 +245,7 @@ module ActiveScaffold
|
|
|
245
245
|
def logical_search_condition(column, search, parser = nil)
|
|
246
246
|
model = column.active_record_class
|
|
247
247
|
subquery = alias_query_for_same_table_exists(model.all) if column.logical_search.any?(Hash)
|
|
248
|
-
query = ::LogicalQueryParser.search(search, subquery || model,
|
|
248
|
+
query = ::LogicalQueryParser.search(search, subquery || model, column.logical_search, parser: parser)
|
|
249
249
|
if subquery
|
|
250
250
|
model.where(same_table_exists_subquery(query))
|
|
251
251
|
else
|
|
@@ -167,15 +167,13 @@ module ActiveScaffold
|
|
|
167
167
|
def build_associated(association, parent_record)
|
|
168
168
|
if association.through? && association.through_reflection.collection?
|
|
169
169
|
# build full chain, only check create_associated on initial parent_record
|
|
170
|
-
parent_record = build_associated(association.
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
save_record_to_association(record, source_assoc.reverse_association, parent_record) # set inverse
|
|
170
|
+
parent_record = build_associated(association.through_reflection, parent_record)
|
|
171
|
+
build_associated(association.source_reflection, parent_record).tap do |record|
|
|
172
|
+
save_record_to_association(record, association.source_reflection.reverse_association, parent_record) # set inverse
|
|
174
173
|
end
|
|
175
174
|
elsif association.through? # through belongs_to/has_one
|
|
176
175
|
parent_record = parent_record.send(association.through_reflection.name)
|
|
177
|
-
|
|
178
|
-
build_associated(source_assoc, parent_record)
|
|
176
|
+
build_associated(association.source_reflection, parent_record)
|
|
179
177
|
elsif association.collection?
|
|
180
178
|
parent_record.send(association.name).build
|
|
181
179
|
elsif association.belongs_to? || parent_record.new_record? || parent_record.send(association.name).nil?
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: active_scaffold
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.2.
|
|
4
|
+
version: 4.2.2
|
|
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: 2026-02-
|
|
11
|
+
date: 2026-02-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: dartsass-sprockets
|