avo 2.25.0 → 2.25.1.pre.1.pr1579
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of avo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Gemfile.lock +75 -66
- data/app/components/avo/base_component.rb +2 -2
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +1 -1
- data/app/components/avo/fields/belongs_to_field/show_component.rb +1 -1
- data/app/components/avo/fields/has_one_field/show_component.rb +3 -3
- data/app/components/avo/fields/index_component.rb +1 -1
- data/app/components/avo/index/grid_item_component.rb +1 -1
- data/app/components/avo/index/ordering/button_component.rb +1 -1
- data/app/components/avo/index/resource_controls_component.rb +2 -2
- data/app/components/avo/resource_component.rb +1 -1
- data/app/components/avo/views/resource_index_component.rb +6 -4
- data/app/controllers/avo/actions_controller.rb +1 -1
- data/app/controllers/avo/application_controller.rb +2 -7
- data/app/controllers/avo/associations_controller.rb +2 -2
- data/app/controllers/avo/base_controller.rb +8 -5
- data/app/views/avo/associations/new.html.erb +6 -1
- data/app/views/layouts/avo/application.html.erb +2 -0
- data/config/master.key +1 -0
- data/lib/avo/base_resource.rb +14 -1
- data/lib/avo/fields/has_one_field.rb +1 -0
- data/lib/avo/services/uri_service.rb +10 -9
- data/lib/avo/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae32fd05a8d35cbd8d5253344b8ebd26a96d98414430020ffa0e1ea80eb4b761
|
4
|
+
data.tar.gz: b5a36ad70462507937a96bf563842b986f086c72fcd8b489fbeafb5779228ed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3e978151ea7f78ce700368e91bfc5bb0a181c12532a693b998a61c0fc93416fb679c59c2bec892caf5b2f356fa7d431c2c6ff1f540435438a5576b04dd4958b
|
7
|
+
data.tar.gz: 801644a98e243eea9ae43728cf4e321baddc19f2703700ed83b6f701be1e2a89bcd086c1b02381dca52fc161650e70c61770c80dd0a3575f93170ace07b8c9e6
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
avo (2.25.
|
4
|
+
avo (2.25.1.pre.1.pr1579)
|
5
5
|
actionview (>= 6.0)
|
6
6
|
active_link_to
|
7
7
|
activerecord (>= 6.0)
|
@@ -19,40 +19,40 @@ PATH
|
|
19
19
|
GEM
|
20
20
|
remote: https://rubygems.org/
|
21
21
|
specs:
|
22
|
-
actioncable (6.1.
|
23
|
-
actionpack (= 6.1.
|
24
|
-
activesupport (= 6.1.
|
22
|
+
actioncable (6.1.7.2)
|
23
|
+
actionpack (= 6.1.7.2)
|
24
|
+
activesupport (= 6.1.7.2)
|
25
25
|
nio4r (~> 2.0)
|
26
26
|
websocket-driver (>= 0.6.1)
|
27
|
-
actionmailbox (6.1.
|
28
|
-
actionpack (= 6.1.
|
29
|
-
activejob (= 6.1.
|
30
|
-
activerecord (= 6.1.
|
31
|
-
activestorage (= 6.1.
|
32
|
-
activesupport (= 6.1.
|
27
|
+
actionmailbox (6.1.7.2)
|
28
|
+
actionpack (= 6.1.7.2)
|
29
|
+
activejob (= 6.1.7.2)
|
30
|
+
activerecord (= 6.1.7.2)
|
31
|
+
activestorage (= 6.1.7.2)
|
32
|
+
activesupport (= 6.1.7.2)
|
33
33
|
mail (>= 2.7.1)
|
34
|
-
actionmailer (6.1.
|
35
|
-
actionpack (= 6.1.
|
36
|
-
actionview (= 6.1.
|
37
|
-
activejob (= 6.1.
|
38
|
-
activesupport (= 6.1.
|
34
|
+
actionmailer (6.1.7.2)
|
35
|
+
actionpack (= 6.1.7.2)
|
36
|
+
actionview (= 6.1.7.2)
|
37
|
+
activejob (= 6.1.7.2)
|
38
|
+
activesupport (= 6.1.7.2)
|
39
39
|
mail (~> 2.5, >= 2.5.4)
|
40
40
|
rails-dom-testing (~> 2.0)
|
41
|
-
actionpack (6.1.
|
42
|
-
actionview (= 6.1.
|
43
|
-
activesupport (= 6.1.
|
41
|
+
actionpack (6.1.7.2)
|
42
|
+
actionview (= 6.1.7.2)
|
43
|
+
activesupport (= 6.1.7.2)
|
44
44
|
rack (~> 2.0, >= 2.0.9)
|
45
45
|
rack-test (>= 0.6.3)
|
46
46
|
rails-dom-testing (~> 2.0)
|
47
47
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
48
|
-
actiontext (6.1.
|
49
|
-
actionpack (= 6.1.
|
50
|
-
activerecord (= 6.1.
|
51
|
-
activestorage (= 6.1.
|
52
|
-
activesupport (= 6.1.
|
48
|
+
actiontext (6.1.7.2)
|
49
|
+
actionpack (= 6.1.7.2)
|
50
|
+
activerecord (= 6.1.7.2)
|
51
|
+
activestorage (= 6.1.7.2)
|
52
|
+
activesupport (= 6.1.7.2)
|
53
53
|
nokogiri (>= 1.8.5)
|
54
|
-
actionview (6.1.
|
55
|
-
activesupport (= 6.1.
|
54
|
+
actionview (6.1.7.2)
|
55
|
+
activesupport (= 6.1.7.2)
|
56
56
|
builder (~> 3.1)
|
57
57
|
erubi (~> 1.4)
|
58
58
|
rails-dom-testing (~> 2.0)
|
@@ -62,22 +62,22 @@ GEM
|
|
62
62
|
addressable
|
63
63
|
active_median (0.3.3)
|
64
64
|
activesupport (>= 5.2)
|
65
|
-
activejob (6.1.
|
66
|
-
activesupport (= 6.1.
|
65
|
+
activejob (6.1.7.2)
|
66
|
+
activesupport (= 6.1.7.2)
|
67
67
|
globalid (>= 0.3.6)
|
68
|
-
activemodel (6.1.
|
69
|
-
activesupport (= 6.1.
|
70
|
-
activerecord (6.1.
|
71
|
-
activemodel (= 6.1.
|
72
|
-
activesupport (= 6.1.
|
73
|
-
activestorage (6.1.
|
74
|
-
actionpack (= 6.1.
|
75
|
-
activejob (= 6.1.
|
76
|
-
activerecord (= 6.1.
|
77
|
-
activesupport (= 6.1.
|
68
|
+
activemodel (6.1.7.2)
|
69
|
+
activesupport (= 6.1.7.2)
|
70
|
+
activerecord (6.1.7.2)
|
71
|
+
activemodel (= 6.1.7.2)
|
72
|
+
activesupport (= 6.1.7.2)
|
73
|
+
activestorage (6.1.7.2)
|
74
|
+
actionpack (= 6.1.7.2)
|
75
|
+
activejob (= 6.1.7.2)
|
76
|
+
activerecord (= 6.1.7.2)
|
77
|
+
activesupport (= 6.1.7.2)
|
78
78
|
marcel (~> 1.0)
|
79
79
|
mini_mime (>= 1.1.0)
|
80
|
-
activesupport (6.1.
|
80
|
+
activesupport (6.1.7.2)
|
81
81
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
82
82
|
i18n (>= 1.6, < 2)
|
83
83
|
minitest (>= 5.1)
|
@@ -142,7 +142,7 @@ GEM
|
|
142
142
|
xpath (~> 3.2)
|
143
143
|
chartkick (4.2.1)
|
144
144
|
childprocess (4.1.0)
|
145
|
-
concurrent-ruby (1.
|
145
|
+
concurrent-ruby (1.2.0)
|
146
146
|
countries (4.2.3)
|
147
147
|
i18n_data (~> 0.16.0)
|
148
148
|
sixarm_ruby_unaccent (~> 1.1)
|
@@ -157,6 +157,7 @@ GEM
|
|
157
157
|
activerecord (>= 5.a)
|
158
158
|
database_cleaner-core (~> 2.0.0)
|
159
159
|
database_cleaner-core (2.0.1)
|
160
|
+
date (3.3.3)
|
160
161
|
devise (4.8.1)
|
161
162
|
bcrypt (~> 3.0)
|
162
163
|
orm_adapter (~> 0.1)
|
@@ -171,7 +172,7 @@ GEM
|
|
171
172
|
railties (>= 3.2)
|
172
173
|
dry-initializer (3.1.1)
|
173
174
|
erb-formatter (0.3.0)
|
174
|
-
erubi (1.
|
175
|
+
erubi (1.12.0)
|
175
176
|
factory_bot (6.2.1)
|
176
177
|
activesupport (>= 5.0.0)
|
177
178
|
factory_bot_rails (6.2.0)
|
@@ -186,7 +187,7 @@ GEM
|
|
186
187
|
rspec-core (~> 3.0)
|
187
188
|
ruby-progressbar (~> 1.4)
|
188
189
|
gem-release (2.2.2)
|
189
|
-
globalid (1.
|
190
|
+
globalid (1.1.0)
|
190
191
|
activesupport (>= 5.0)
|
191
192
|
groupdate (6.1.0)
|
192
193
|
activesupport (>= 5.2)
|
@@ -237,8 +238,11 @@ GEM
|
|
237
238
|
loofah (2.19.1)
|
238
239
|
crass (~> 1.0.2)
|
239
240
|
nokogiri (>= 1.5.9)
|
240
|
-
mail (2.
|
241
|
+
mail (2.8.0.1)
|
241
242
|
mini_mime (>= 0.1.1)
|
243
|
+
net-imap
|
244
|
+
net-pop
|
245
|
+
net-smtp
|
242
246
|
manifester (0.1.8)
|
243
247
|
rails (>= 6.0)
|
244
248
|
zeitwerk
|
@@ -249,19 +253,24 @@ GEM
|
|
249
253
|
method_source (1.0.0)
|
250
254
|
mini_magick (4.12.0)
|
251
255
|
mini_mime (1.1.2)
|
252
|
-
mini_portile2 (2.8.
|
256
|
+
mini_portile2 (2.8.1)
|
253
257
|
minitest (5.17.0)
|
254
258
|
msgpack (1.5.6)
|
255
259
|
multi_xml (0.6.0)
|
260
|
+
net-imap (0.3.4)
|
261
|
+
date
|
262
|
+
net-protocol
|
263
|
+
net-pop (0.1.2)
|
264
|
+
net-protocol
|
256
265
|
net-protocol (0.1.3)
|
257
266
|
timeout
|
258
267
|
net-smtp (0.3.3)
|
259
268
|
net-protocol
|
260
269
|
nio4r (2.5.8)
|
261
|
-
nokogiri (1.
|
270
|
+
nokogiri (1.14.1)
|
262
271
|
mini_portile2 (~> 2.8.0)
|
263
272
|
racc (~> 1.4)
|
264
|
-
nokogiri (1.
|
273
|
+
nokogiri (1.14.1-x86_64-linux)
|
265
274
|
racc (~> 1.4)
|
266
275
|
orm_adapter (0.5.0)
|
267
276
|
pagy (6.0.1)
|
@@ -274,24 +283,24 @@ GEM
|
|
274
283
|
nio4r (~> 2.0)
|
275
284
|
pundit (2.2.0)
|
276
285
|
activesupport (>= 3.0.0)
|
277
|
-
racc (1.6.
|
278
|
-
rack (2.2.
|
286
|
+
racc (1.6.2)
|
287
|
+
rack (2.2.6.2)
|
279
288
|
rack-test (2.0.2)
|
280
289
|
rack (>= 1.3)
|
281
|
-
rails (6.1.
|
282
|
-
actioncable (= 6.1.
|
283
|
-
actionmailbox (= 6.1.
|
284
|
-
actionmailer (= 6.1.
|
285
|
-
actionpack (= 6.1.
|
286
|
-
actiontext (= 6.1.
|
287
|
-
actionview (= 6.1.
|
288
|
-
activejob (= 6.1.
|
289
|
-
activemodel (= 6.1.
|
290
|
-
activerecord (= 6.1.
|
291
|
-
activestorage (= 6.1.
|
292
|
-
activesupport (= 6.1.
|
290
|
+
rails (6.1.7.2)
|
291
|
+
actioncable (= 6.1.7.2)
|
292
|
+
actionmailbox (= 6.1.7.2)
|
293
|
+
actionmailer (= 6.1.7.2)
|
294
|
+
actionpack (= 6.1.7.2)
|
295
|
+
actiontext (= 6.1.7.2)
|
296
|
+
actionview (= 6.1.7.2)
|
297
|
+
activejob (= 6.1.7.2)
|
298
|
+
activemodel (= 6.1.7.2)
|
299
|
+
activerecord (= 6.1.7.2)
|
300
|
+
activestorage (= 6.1.7.2)
|
301
|
+
activesupport (= 6.1.7.2)
|
293
302
|
bundler (>= 1.15.0)
|
294
|
-
railties (= 6.1.
|
303
|
+
railties (= 6.1.7.2)
|
295
304
|
sprockets-rails (>= 2.0.0)
|
296
305
|
rails-controller-testing (1.0.5)
|
297
306
|
actionpack (>= 5.0.1.rc1)
|
@@ -300,14 +309,14 @@ GEM
|
|
300
309
|
rails-dom-testing (2.0.3)
|
301
310
|
activesupport (>= 4.2.0)
|
302
311
|
nokogiri (>= 1.6)
|
303
|
-
rails-html-sanitizer (1.
|
312
|
+
rails-html-sanitizer (1.5.0)
|
304
313
|
loofah (~> 2.19, >= 2.19.1)
|
305
314
|
rails-i18n (7.0.5)
|
306
315
|
i18n (>= 0.7, < 2)
|
307
316
|
railties (>= 6.0.0, < 8)
|
308
|
-
railties (6.1.
|
309
|
-
actionpack (= 6.1.
|
310
|
-
activesupport (= 6.1.
|
317
|
+
railties (6.1.7.2)
|
318
|
+
actionpack (= 6.1.7.2)
|
319
|
+
activesupport (= 6.1.7.2)
|
311
320
|
method_source
|
312
321
|
rake (>= 12.2)
|
313
322
|
thor (~> 1.0)
|
@@ -404,7 +413,7 @@ GEM
|
|
404
413
|
actionpack (>= 6.0.0)
|
405
414
|
activejob (>= 6.0.0)
|
406
415
|
railties (>= 6.0.0)
|
407
|
-
tzinfo (2.0.
|
416
|
+
tzinfo (2.0.6)
|
408
417
|
concurrent-ruby (~> 1.0)
|
409
418
|
unicode-display_width (2.4.0)
|
410
419
|
view_component (2.82.0)
|
@@ -431,7 +440,7 @@ GEM
|
|
431
440
|
websocket-extensions (0.1.5)
|
432
441
|
xpath (3.2.0)
|
433
442
|
nokogiri (~> 1.8)
|
434
|
-
zeitwerk (2.6.
|
443
|
+
zeitwerk (2.6.6)
|
435
444
|
|
436
445
|
PLATFORMS
|
437
446
|
ruby
|
@@ -23,10 +23,10 @@ class Avo::BaseComponent < ViewComponent::Base
|
|
23
23
|
|
24
24
|
model_klass = ::Avo::BaseResource.valid_model_class model_class_name
|
25
25
|
|
26
|
-
model = model_klass.find params[:via_resource_id]
|
27
|
-
|
28
26
|
resource = ::Avo::App.get_resource_by_model_name model_klass if resource.blank?
|
29
27
|
|
28
|
+
model = resource.find_record params[:via_resource_id], query: model_klass
|
29
|
+
|
30
30
|
resource.dup.hydrate model: model
|
31
31
|
end
|
32
32
|
|
@@ -44,7 +44,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
44
44
|
|
45
45
|
return @polymorphic_record if @polymorphic_record.present?
|
46
46
|
|
47
|
-
@polymorphic_record = polymorphic_class.safe_constantize
|
47
|
+
@polymorphic_record = @resource.find_record polymorphic_id, query: polymorphic_class.safe_constantize
|
48
48
|
|
49
49
|
@polymorphic_record
|
50
50
|
end
|
@@ -6,7 +6,7 @@ class Avo::Fields::BelongsToField::ShowComponent < Avo::Fields::ShowComponent
|
|
6
6
|
model: @field.value,
|
7
7
|
resource: @field.target_resource,
|
8
8
|
via_resource_class: @resource.class.to_s,
|
9
|
-
via_resource_id: @resource.model.
|
9
|
+
via_resource_id: @resource.model.to_param
|
10
10
|
)
|
11
11
|
end
|
12
12
|
end
|
@@ -21,11 +21,11 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def attach_path
|
24
|
-
helpers.avo.resources_associations_new_path(@resource.singular_model_key, @resource.model.
|
24
|
+
helpers.avo.resources_associations_new_path(@resource.singular_model_key, @resource.model.to_param, @field.id)
|
25
25
|
end
|
26
26
|
|
27
27
|
def can_see_the_create_button?
|
28
|
-
create = "create_#{@field.id
|
28
|
+
create = "create_#{@field.id}?"
|
29
29
|
|
30
30
|
authorization_service = @resource.authorization
|
31
31
|
|
@@ -39,7 +39,7 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
|
|
39
39
|
args = {
|
40
40
|
via_relation: @resource.singular_model_key,
|
41
41
|
via_relation_class: @resource.model_class.to_s,
|
42
|
-
via_resource_id: @resource.model.
|
42
|
+
via_resource_id: @resource.model.to_param
|
43
43
|
}
|
44
44
|
helpers.new_resource_path(resource: @field.target_resource, **args)
|
45
45
|
end
|
@@ -18,6 +18,6 @@ class Avo::Index::Ordering::ButtonComponent < Avo::Index::Ordering::BaseComponen
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def order_path(args)
|
21
|
-
Avo::App.view_context.avo.reorder_order_path(resource.route_key, resource.model.
|
21
|
+
Avo::App.view_context.avo.reorder_order_path(resource.route_key, resource.model.to_param, **args)
|
22
22
|
end
|
23
23
|
end
|
@@ -37,7 +37,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
37
37
|
if @parent_model.present?
|
38
38
|
args = {
|
39
39
|
via_resource_class: parent_resource.class.to_s,
|
40
|
-
via_resource_id: @parent_model.
|
40
|
+
via_resource_id: @parent_model.to_param
|
41
41
|
}
|
42
42
|
end
|
43
43
|
|
@@ -51,7 +51,7 @@ class Avo::Index::ResourceControlsComponent < Avo::ResourceComponent
|
|
51
51
|
if @parent_model.present?
|
52
52
|
args = {
|
53
53
|
via_resource_class: parent_resource.class.to_s,
|
54
|
-
via_resource_id: @parent_model.
|
54
|
+
via_resource_id: @parent_model.to_param
|
55
55
|
}
|
56
56
|
end
|
57
57
|
|
@@ -26,7 +26,7 @@ class Avo::ResourceComponent < Avo::BaseComponent
|
|
26
26
|
def detach_path
|
27
27
|
return "/" if @reflection.blank?
|
28
28
|
|
29
|
-
helpers.resource_detach_path(params[:resource_name], params[:id], @reflection.name.to_s, @resource.model.
|
29
|
+
helpers.resource_detach_path(params[:resource_name], params[:id], @reflection.name.to_s, @resource.model.to_param)
|
30
30
|
end
|
31
31
|
|
32
32
|
def can_see_the_edit_button?
|
@@ -74,7 +74,7 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
74
74
|
if @reflection.present?
|
75
75
|
args = {
|
76
76
|
via_relation_class: reflection_model_class,
|
77
|
-
via_resource_id: @parent_model.
|
77
|
+
via_resource_id: @parent_model.to_param
|
78
78
|
}
|
79
79
|
|
80
80
|
if @reflection.is_a? ActiveRecord::Reflection::ThroughReflection
|
@@ -98,7 +98,9 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def attach_path
|
101
|
-
|
101
|
+
current_path = CGI.unescape(request.env["PATH_INFO"]).split("/").select(&:present?)
|
102
|
+
|
103
|
+
Avo::App.root_path(paths: [*current_path, "new"])
|
102
104
|
end
|
103
105
|
|
104
106
|
def singular_resource_name
|
@@ -142,10 +144,10 @@ class Avo::Views::ResourceIndexComponent < Avo::ResourceComponent
|
|
142
144
|
return unless @reflection.present?
|
143
145
|
|
144
146
|
{
|
145
|
-
association:
|
147
|
+
association: "has_many",
|
146
148
|
association_id: @reflection.name,
|
147
149
|
class: reflection_model_class,
|
148
|
-
id: @parent_model.
|
150
|
+
id: @parent_model.to_param
|
149
151
|
}
|
150
152
|
end
|
151
153
|
end
|
@@ -128,11 +128,7 @@ module Avo
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def set_model
|
131
|
-
@model =
|
132
|
-
end
|
133
|
-
|
134
|
-
def record_id
|
135
|
-
params.permit(:id).dig(:id)
|
131
|
+
@model = @resource.find_record(params[:id], query: model_find_scope)
|
136
132
|
end
|
137
133
|
|
138
134
|
def model_find_scope
|
@@ -145,11 +141,10 @@ module Avo
|
|
145
141
|
|
146
142
|
def set_related_model
|
147
143
|
association_name = BaseResource.valid_association_name(@model, params[:related_name])
|
148
|
-
|
149
144
|
@related_model = if @field.is_a? Avo::Fields::HasOneField
|
150
145
|
@model.send association_name
|
151
146
|
else
|
152
|
-
eager_load_files(@related_resource, @model.send(association_name))
|
147
|
+
@related_resource.find_record params[:related_id], query: eager_load_files(@related_resource, @model.send(association_name))
|
153
148
|
end
|
154
149
|
end
|
155
150
|
|
@@ -21,7 +21,7 @@ module Avo
|
|
21
21
|
def index
|
22
22
|
@parent_resource = @resource.dup
|
23
23
|
@resource = @related_resource
|
24
|
-
@parent_model = @parent_resource.
|
24
|
+
@parent_model = @parent_resource.find_record(params[:id])
|
25
25
|
@parent_resource.hydrate(model: @parent_model)
|
26
26
|
association_name = BaseResource.valid_association_name(@parent_model, params[:related_name])
|
27
27
|
@query = @related_authorization.apply_policy @parent_model.send(association_name)
|
@@ -113,7 +113,7 @@ module Avo
|
|
113
113
|
end
|
114
114
|
|
115
115
|
def set_attachment_model
|
116
|
-
@attachment_model = @
|
116
|
+
@attachment_model = @related_resource.find_record attachment_id
|
117
117
|
end
|
118
118
|
|
119
119
|
def set_reflection_field
|
@@ -90,7 +90,7 @@ module Avo
|
|
90
90
|
# If we're accessing this resource via another resource add the parent to the breadcrumbs.
|
91
91
|
if params[:via_resource_class].present? && params[:via_resource_id].present?
|
92
92
|
via_resource = Avo::App.get_resource(params[:via_resource_class]).dup
|
93
|
-
via_model = via_resource.
|
93
|
+
via_model = via_resource.find_record params[:via_resource_id]
|
94
94
|
via_resource.hydrate model: via_model
|
95
95
|
|
96
96
|
add_breadcrumb via_resource.plural_name, resources_path(resource: via_resource)
|
@@ -113,7 +113,7 @@ module Avo
|
|
113
113
|
|
114
114
|
if is_associated_record?
|
115
115
|
via_resource = Avo::App.get_resource_by_model_name(params[:via_relation_class]).dup
|
116
|
-
via_model = via_resource.
|
116
|
+
via_model = via_resource.find_record params[:via_resource_id]
|
117
117
|
via_resource.hydrate model: via_model
|
118
118
|
|
119
119
|
add_breadcrumb via_resource.plural_name, resources_path(resource: via_resource)
|
@@ -137,7 +137,10 @@ module Avo
|
|
137
137
|
# Fills in the required infor for belongs_to and has_many
|
138
138
|
# Get the foreign key and set it to the id we received in the params
|
139
139
|
if @reflection.is_a?(ActiveRecord::Reflection::BelongsToReflection) || @reflection.is_a?(ActiveRecord::Reflection::HasManyReflection)
|
140
|
-
|
140
|
+
related_resource = Avo::App.get_resource_by_model_name params[:via_relation_class]
|
141
|
+
related_record = related_resource.find_record params[:via_resource_id]
|
142
|
+
|
143
|
+
@model.send("#{@reflection.foreign_key}=", related_record.id)
|
141
144
|
@model.save
|
142
145
|
end
|
143
146
|
|
@@ -145,7 +148,7 @@ module Avo
|
|
145
148
|
if @reflection.is_a? ActiveRecord::Reflection::ThroughReflection
|
146
149
|
# find the record
|
147
150
|
via_resource = ::Avo::App.get_resource_by_model_name(params[:via_relation_class]).dup
|
148
|
-
@related_record = via_resource.
|
151
|
+
@related_record = via_resource.find_record params[:via_resource_id]
|
149
152
|
association_name = BaseResource.valid_association_name(@model, params[:via_relation])
|
150
153
|
|
151
154
|
@model.send(association_name) << @related_record
|
@@ -385,7 +388,7 @@ module Avo
|
|
385
388
|
# If we're accessing this resource via another resource add the parent to the breadcrumbs.
|
386
389
|
if params[:via_resource_class].present? && params[:via_resource_id].present?
|
387
390
|
via_resource = Avo::App.get_resource(params[:via_resource_class]).dup
|
388
|
-
via_model = via_resource.
|
391
|
+
via_model = via_resource.find_record params[:via_resource_id]
|
389
392
|
via_resource.hydrate model: via_model
|
390
393
|
|
391
394
|
add_breadcrumb via_resource.plural_name, resources_path(resource: @resource)
|
@@ -1,6 +1,11 @@
|
|
1
1
|
<%= turbo_frame_tag 'attach_modal' do %>
|
2
|
+
<%
|
3
|
+
url = Avo::Services::URIService.parse(avo.root_url.to_s)
|
4
|
+
.append_paths('resources', params[:resource_name], params[:id], params[:related_name])
|
5
|
+
.to_s
|
6
|
+
%>
|
2
7
|
<%= form_with scope: 'fields',
|
3
|
-
url:
|
8
|
+
url: url,
|
4
9
|
local: true,
|
5
10
|
data: {
|
6
11
|
'turbo-frame': '_top'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
<!DOCTYPE html>
|
2
|
+
<!-- ✨ Built with Avo • https://www.avohq.io/ -->
|
2
3
|
<html>
|
3
4
|
<head>
|
4
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
@@ -62,3 +63,4 @@
|
|
62
63
|
<!-- License valid?: <%= Avo::App.license.valid ? "valid" : "invalid" %> -->
|
63
64
|
</body>
|
64
65
|
</html>
|
66
|
+
<!-- ✨ Built with Avo • https://www.avohq.io/ -->
|
data/config/master.key
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2aeb23d82b909d9c6b5abb62f7058c2a
|
data/lib/avo/base_resource.rb
CHANGED
@@ -42,6 +42,9 @@ module Avo
|
|
42
42
|
class_attribute :unscoped_queries_on_index, default: false
|
43
43
|
class_attribute :resolve_query_scope
|
44
44
|
class_attribute :resolve_find_scope
|
45
|
+
class_attribute :find_record_method, default: ->(model_class:, id:) {
|
46
|
+
model_class.find id
|
47
|
+
}
|
45
48
|
class_attribute :ordering
|
46
49
|
class_attribute :hide_from_global_search, default: false
|
47
50
|
class_attribute :after_create_path, default: :show
|
@@ -379,7 +382,11 @@ module Avo
|
|
379
382
|
# set the value to the actual record
|
380
383
|
value = @params[:via_relation_class].safe_constantize.find(@params[:via_resource_id])
|
381
384
|
elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
|
382
|
-
|
385
|
+
resource = Avo::App.get_resource_by_model_name params[:via_relation_class]
|
386
|
+
model = resource.find_record @params[:via_resource_id]
|
387
|
+
id_param = reflection.options[:primary_key] || :id
|
388
|
+
|
389
|
+
value = model.send(id_param)
|
383
390
|
end
|
384
391
|
end
|
385
392
|
|
@@ -488,5 +495,11 @@ module Avo
|
|
488
495
|
def has_model_id?
|
489
496
|
model.present? && model.id.present?
|
490
497
|
end
|
498
|
+
|
499
|
+
def find_record(id, query: nil)
|
500
|
+
query ||= self.class.find_scope
|
501
|
+
|
502
|
+
self.class.find_record_method.call(model_class: query, id: id)
|
503
|
+
end
|
491
504
|
end
|
492
505
|
end
|
@@ -3,13 +3,13 @@ module Avo
|
|
3
3
|
class URIService
|
4
4
|
class << self
|
5
5
|
def parse(path)
|
6
|
-
|
6
|
+
new path
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
10
|
attr_reader :uri
|
11
11
|
|
12
|
-
def initialize(path =
|
12
|
+
def initialize(path = "")
|
13
13
|
@uri = Addressable::URI.parse(path)
|
14
14
|
end
|
15
15
|
|
@@ -56,19 +56,20 @@ module Avo
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def join_paths(paths)
|
59
|
-
paths
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
paths
|
60
|
+
.map do |path|
|
61
|
+
sanitize_path path
|
62
|
+
end
|
63
|
+
.join("/")
|
63
64
|
end
|
64
65
|
|
65
66
|
# Removes the forward slash if it's present at the start of the path
|
66
67
|
def sanitize_path(path)
|
67
|
-
if path.to_s.starts_with?
|
68
|
-
path = path[1
|
68
|
+
if path.to_s.starts_with? "/"
|
69
|
+
path = path[1..]
|
69
70
|
end
|
70
71
|
|
71
|
-
path
|
72
|
+
ERB::Util.url_encode path
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
data/lib/avo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: avo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.25.
|
4
|
+
version: 2.25.1.pre.1.pr1579
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-02-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -1695,6 +1695,7 @@ files:
|
|
1695
1695
|
- config/credentials.yml.enc
|
1696
1696
|
- config/i18n-tasks.yml
|
1697
1697
|
- config/initializers/pagy.rb
|
1698
|
+
- config/master.key
|
1698
1699
|
- config/routes.rb
|
1699
1700
|
- config/spring.rb
|
1700
1701
|
- db/factories.rb
|
@@ -1950,9 +1951,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1950
1951
|
version: 2.6.0
|
1951
1952
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1952
1953
|
requirements:
|
1953
|
-
- - "
|
1954
|
+
- - ">"
|
1954
1955
|
- !ruby/object:Gem::Version
|
1955
|
-
version:
|
1956
|
+
version: 1.3.1
|
1956
1957
|
requirements: []
|
1957
1958
|
rubygems_version: 3.3.3
|
1958
1959
|
signing_key:
|