avo 2.29.0 → 2.29.1.pre.pr1652
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 +1 -1
- data/app/components/avo/fields/belongs_to_field/edit_component.rb +5 -1
- data/app/components/avo/fields/has_one_field/show_component.rb +6 -2
- data/app/components/avo/referrer_params_component.html.erb +2 -0
- data/app/controllers/avo/base_controller.rb +6 -1
- data/config/master.key +1 -0
- data/lib/avo/base_resource.rb +2 -1
- data/lib/avo/fields/has_one_field.rb +2 -1
- data/lib/avo/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d2125434870241611526a666d97850dd666741c17ebe191c8496dfc0804faf0
|
4
|
+
data.tar.gz: f05693aeee46a349b98329592a9f4bc0ae1b35f6922e8fd83d7ef7dd120bbc3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70967faaf46f6552646994b4cf3d5d080b8059d2909826169ac63021b11699875d4c3d81282eb9f65e074b208711b2260d220656cde4aa422503569070176421
|
7
|
+
data.tar.gz: 300be7ff2c5c9d04ada4995820318ec3076c6a1ba5954c1ccc88792d35117e1db13d3e89f84d41c8db44f322cc1df19fe7625b3d86772813e96a58f11cb1379a
|
data/Gemfile.lock
CHANGED
@@ -31,6 +31,10 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
31
31
|
@resource.model["#{@field.foreign_key}_type"]
|
32
32
|
end
|
33
33
|
|
34
|
+
def polymorphic_resource
|
35
|
+
::Avo::App.get_resource_by_model_name(polymorphic_class)
|
36
|
+
end
|
37
|
+
|
34
38
|
# Get the polymorphic id
|
35
39
|
def polymorphic_id
|
36
40
|
@resource.model["#{@field.foreign_key}_id"]
|
@@ -44,7 +48,7 @@ class Avo::Fields::BelongsToField::EditComponent < Avo::Fields::EditComponent
|
|
44
48
|
|
45
49
|
return @polymorphic_record if @polymorphic_record.present?
|
46
50
|
|
47
|
-
@polymorphic_record =
|
51
|
+
@polymorphic_record = polymorphic_resource.find_record polymorphic_id, query: polymorphic_class.safe_constantize, params: params
|
48
52
|
|
49
53
|
@polymorphic_record
|
50
54
|
end
|
@@ -36,11 +36,15 @@ class Avo::Fields::HasOneField::ShowComponent < Avo::Fields::ShowComponent
|
|
36
36
|
end
|
37
37
|
|
38
38
|
def create_path
|
39
|
+
association_id = @field.resource.model_class._reflections[@field.id.to_s].inverse_of.name
|
40
|
+
|
39
41
|
args = {
|
40
|
-
via_relation:
|
42
|
+
via_relation: association_id,
|
41
43
|
via_relation_class: @resource.model_class.to_s,
|
42
|
-
via_resource_id: @resource.model.to_param
|
44
|
+
via_resource_id: @resource.model.to_param,
|
45
|
+
via_association_type: :has_one
|
43
46
|
}
|
47
|
+
|
44
48
|
helpers.new_resource_path(resource: @field.target_resource, **args)
|
45
49
|
end
|
46
50
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
<%# via_association_type is used in has_one create actions %>
|
2
|
+
<%= hidden_field_tag :via_association_type, params[:via_association_type] if params[:via_association_type] %>
|
1
3
|
<%= hidden_field_tag :via_resource_class, params[:via_resource_class] if params[:via_resource_class] %>
|
2
4
|
<%= hidden_field_tag :via_resource_id, params[:via_resource_id] if params[:via_resource_id] %>
|
3
5
|
<%= hidden_field_tag :via_relation, params[:via_relation] if params[:via_relation] %>
|
@@ -151,7 +151,12 @@ module Avo
|
|
151
151
|
@related_record = via_resource.find_record params[:via_resource_id], params: params
|
152
152
|
association_name = BaseResource.valid_association_name(@model, params[:via_relation])
|
153
153
|
|
154
|
-
|
154
|
+
if params[:via_association_type] == "has_one"
|
155
|
+
# On has_one scenarios we should switch the @record and @related_record
|
156
|
+
@related_record.send("#{@reflection.parent_reflection.inverse_of.name}=", @model)
|
157
|
+
else
|
158
|
+
@model.send(association_name) << @related_record
|
159
|
+
end
|
155
160
|
end
|
156
161
|
end
|
157
162
|
|
data/config/master.key
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2aeb23d82b909d9c6b5abb62f7058c2a
|
data/lib/avo/base_resource.rb
CHANGED
@@ -382,7 +382,8 @@ module Avo
|
|
382
382
|
|
383
383
|
if field.polymorphic_as.present? && field.types.map(&:to_s).include?(@params[:via_relation_class])
|
384
384
|
# set the value to the actual record
|
385
|
-
|
385
|
+
via_resource = ::Avo::App.get_resource_by_model_name(@params[:via_relation_class])
|
386
|
+
value = via_resource.find_record(@params[:via_resource_id])
|
386
387
|
elsif reflection.present? && reflection.foreign_key.present? && field.id.to_s == @params[:via_relation].to_s
|
387
388
|
resource = Avo::App.get_resource_by_model_name params[:via_relation_class]
|
388
389
|
model = resource.find_record @params[:via_resource_id], params: params
|
@@ -33,7 +33,8 @@ module Avo
|
|
33
33
|
related_model = nil
|
34
34
|
else
|
35
35
|
related_class = model.class.reflections[name.to_s.downcase].class_name
|
36
|
-
|
36
|
+
related_resource = ::Avo::App.get_resource_by_model_name(related_class)
|
37
|
+
related_model = related_resource.find_record value
|
37
38
|
end
|
38
39
|
|
39
40
|
model.public_send("#{key}=", related_model)
|
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.29.
|
4
|
+
version: 2.29.1.pre.pr1652
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrian Marin
|
@@ -1696,6 +1696,7 @@ files:
|
|
1696
1696
|
- config/credentials.yml.enc
|
1697
1697
|
- config/i18n-tasks.yml
|
1698
1698
|
- config/initializers/pagy.rb
|
1699
|
+
- config/master.key
|
1699
1700
|
- config/routes.rb
|
1700
1701
|
- config/spring.rb
|
1701
1702
|
- db/factories.rb
|
@@ -1956,9 +1957,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
1956
1957
|
version: 2.6.0
|
1957
1958
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
1958
1959
|
requirements:
|
1959
|
-
- - "
|
1960
|
+
- - ">"
|
1960
1961
|
- !ruby/object:Gem::Version
|
1961
|
-
version:
|
1962
|
+
version: 1.3.1
|
1962
1963
|
requirements: []
|
1963
1964
|
rubygems_version: 3.3.3
|
1964
1965
|
signing_key:
|